/**
 * =====================================================
 * PREMIUM SAAS UI - STYLE GUIDE (AWWWARDS-LEVEL)
 * Typography: Satoshi (Premium Geometric Sans)
 * Layout: Dense Bento Grids, Wide Heroes
 * Motion: GSAP-ready Physics & Glassmorphism
 * =====================================================
 */
/* Font loaded via HTML <link> for performance and CLS optimization */
/* ==========================================================================
   1. CSS VARIABLES (THEME TOKENS)
   ========================================================================== */
:root {
    /* Brand Primary comes from PHP via inline styles: var(--primary-color) */
    /* Fallback if not provided */
    --primary-color: #4f46e5; 
    
    /* Mixins for dynamic colors using CSS color-mix */
    --primary-hover: color-mix(in srgb, var(--primary-color) 85%, black);
    --primary-soft: color-mix(in srgb, var(--primary-color) 10%, transparent);
    --primary-glow: color-mix(in srgb, var(--primary-color) 30%, transparent);
    
    /* Layout Variables */
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 90px;
    --navbar-height: 80px;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px; /* Native corners */
    --border-radius-xl: 24px;
    
    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-physics: 0.6s cubic-bezier(0.16, 1, 0.3, 1); /* Apple-like physics */
}

/* LIGHT MODE TOKENS */
[data-bs-theme="light"], :root {
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    
    --bg-body: var(--bg-app);
    --bg-surface: var(--bg-card);
    --bg-surface-hover: #f1f5f9;
    --bg-sidebar: var(--bg-card);
    --text-muted: #94a3b8;
    
    --border-color: rgba(15, 23, 42, 0.04); /* Borderless UI feel */
    --border-color-strong: rgba(15, 23, 42, 0.08);
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.02), 0 8px 24px -4px rgba(0, 0, 0, 0.03); /* Soft native shadow */
    --shadow-md: 0 16px 32px -4px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 24px 48px -6px rgba(0, 0, 0, 0.06);
    
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
    
    --input-bg: #f8fafc;
    --input-border: #e2e8f0;
}

/* DARK MODE TOKENS */
[data-bs-theme="dark"] {
    --bg-app: #090d16;
    --bg-card: #131a26;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --bg-body: var(--bg-app);
    --bg-surface: var(--bg-card);
    --bg-surface-hover: #1b2535;
    --bg-sidebar: var(--bg-card);
    --text-muted: #64748b;
    
    --border-color: rgba(255, 255, 255, 0.04); /* Borderless dark UI */
    --border-color-strong: rgba(255, 255, 255, 0.08);
    
    --shadow-sm: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 12px 30px -4px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 50px -6px rgba(0, 0, 0, 0.7);
    
    --glass-bg: rgba(19, 26, 38, 0.6);
    --glass-border: rgba(255, 255, 255, 0.03);
    
    --input-bg: #090d16;
    --input-border: #222d3f;
}

/* ==========================================================================
   2. GLOBAL SETUP & TYPOGRAPHY
   ========================================================================== */
html, body {
    height: 100%;
    font-family: 'Satoshi', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary) !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
}

/* Elite Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary) !important;
    font-weight: 700;
    letter-spacing: -0.04em; /* Tight tracking for premium feel */
    line-height: 1.1;
}

/* Bootstrap Text Contrast Fixes */
.text-dark, .text-black {
    color: var(--text-primary) !important;
}
.text-secondary {
    color: var(--text-secondary) !important;
}
.text-muted {
    color: var(--text-secondary) !important;
    opacity: 0.75;
}

/* ==========================================================================
   3. COMPONENTS & PHYSICS
   ========================================================================== */

/* Glassmorphism Defaults */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

.navbar-glass {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* Premium Cards & Hover Physics */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-physics), box-shadow var(--transition-physics), border-color var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-color-strong);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0 !important;
}

.card-body {
    padding: 2rem;
}

/* Interactive Elements Physics */
.hover-physics {
    transition: transform var(--transition-physics), box-shadow var(--transition-physics);
}
.hover-physics:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--shadow-md);
}

/* Inputs & Forms */
.form-control, .form-select {
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    border-radius: var(--border-radius-md);
    padding: 0.8rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.form-control::placeholder, .form-select::placeholder {
    color: var(--text-secondary);
    opacity: 0.55;
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-surface);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-soft);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .form-control:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px var(--input-bg) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
}

/* Buttons */
.btn {
    border-radius: var(--border-radius-md);
    font-weight: 700;
    padding: 0.75rem 1.5rem;
    transition: all var(--transition-physics);
    letter-spacing: -0.01em;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--primary-glow);
    color: #ffffff;
}

.btn-soft-primary {
    background: var(--primary-soft);
    color: var(--primary-color);
    border: none;
}
.btn-soft-primary:hover {
    background: var(--primary-color);
    color: #ffffff;
}

/* ==========================================================================
   4. BENTO GRID ARCHITECTURE
   ========================================================================== */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    grid-auto-flow: dense;
}

.bento-card {
    background-color: var(--bg-surface);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.2s ease;
    height: 100%;
}

.bento-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-color-strong);
}

.bento-col-12 {
    grid-column: 1 / -1;
}

@media (min-width: 768px) {
    .bento-span-2 {
        grid-column: span 2;
    }
    .bento-col-6 {
        grid-column: span 2;
    }
}

/* Bento Empty States */
.bento-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
}

.bento-empty-state-icon {
    font-size: 2.2rem;
    color: var(--text-secondary);
    opacity: 0.4;
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

.bento-empty-state:hover .bento-empty-state-icon {
    transform: scale(1.1) rotate(5deg);
}

.bento-empty-state-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Tables */
.table {
    color: var(--text-primary);
    margin-bottom: 0;
}

.table th {
    border-top: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1.25rem 1rem;
}

.table td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-secondary);
    font-weight: 500;
}

.table-hover tbody tr {
    transition: background-color var(--transition-fast);
}

.table-hover tbody tr:hover {
    background-color: var(--bg-surface-hover);
}

/* Helpers */
.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary-color) 20%, transparent);
    border: 2px solid var(--border-color-strong);
}
[data-bs-theme="dark"] .avatar {
    border: 2px solid rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   5. MOBILE FIXES (BOTTOM NAV)
   ========================================================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-around;
    padding: 16px 8px 24px 8px; 
    z-index: 1030;
    border-top: 1px solid var(--glass-border);
    transition: background-color var(--transition-fast);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted); 
    font-size: 0.7rem;
    font-weight: 700;
    transition: all var(--transition-physics);
    width: 25%;
}

.bottom-nav-item i { 
    font-size: 1.4rem; 
    margin-bottom: 6px; 
    transition: transform var(--transition-physics), color var(--transition-fast); 
}

.bottom-nav-item.active { 
    color: var(--primary-color); 
}

.bottom-nav-item.active i { 
    transform: translateY(-4px) scale(1.15); 
}



/* ==========================================================================
   5.1 MOBILE RESPONSIVE UTILITIES
   ========================================================================== */
@media (max-width: 767.98px) {
    /* Tabelas responsivas: força scroll horizontal */
    .table-responsive-mobile {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Cards e stats em grid para 2 colunas no mobile */
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .bento-card { font-size: 0.9rem; }
    .bento-card h3 { font-size: 1.5rem; }
    .bento-card h6 { font-size: 0.7rem; }

    /* Form controls mais compactos */
    .form-control, .form-select {
        padding: 0.65rem 0.9rem;
        font-size: 0.95rem;
    }

    /* Botões full-width no mobile */
    .btn-mobile-full {
        width: 100%;
        display: block;
    }

    /* Espaçamento reduzido */
    .container-fluid.py-4 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    /* Títulos menores */
    h2.h3 { font-size: 1.2rem; }
    h3 { font-size: 1.1rem; }
    h5 { font-size: 0.95rem; }

    /* Alerts compactos */
    .alert { padding: 0.75rem 1rem; font-size: 0.85rem; }

    /* Dropdown menu full-width */
    .dropdown-menu {
        min-width: auto;
        width: calc(100vw - 2rem);
        right: 0;
    }
}

/* Safe area para iPhones com notch */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
    }
}

/* Premium Exercise Interactions */
.exercicio-card {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.exercicio-feito { 
    background-color: var(--bg-surface-hover) !important; 
    opacity: 0.65; 
    transform: scale(0.98);
    box-shadow: none !important;
    border-color: var(--border-color) !important;
}

.exercicio-feito .exercicio-titulo { 
    text-decoration: line-through; 
    color: var(--text-secondary) !important; 
}

/* ==========================================================================
   6. BOOTSTRAP OVERRIDES & THEME SEESAW CONTRAST FIXES
   ========================================================================== */

/* Backgrounds & Borders */
.bg-white {
    background-color: var(--bg-card) !important;
}
.bg-light {
    background-color: var(--bg-surface-hover) !important;
}
.bg-dark {
    background-color: var(--bg-app) !important;
}
.border-light {
    border-color: var(--border-color) !important;
}
.border-white {
    border-color: var(--border-color) !important;
}

/* Card Headers */
.card-header.bg-white, 
.card-header.bg-light {
    background-color: transparent !important;
    border-bottom: 1px solid var(--border-color) !important;
}

/* Inputs & Form Controls Override Specificity */
.form-control.bg-light, 
.form-select.bg-light,
.form-control.bg-white, 
.form-select.bg-white {
    background-color: var(--input-bg) !important;
    color: var(--text-primary) !important;
}
.form-control:focus, .form-select:focus {
    background-color: var(--bg-surface) !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px var(--primary-soft) !important;
    color: var(--text-primary) !important;
}

/* Table Themes */
.table {
    --bs-table-bg: transparent !important;
    --bs-table-striped-bg: var(--bg-surface-hover) !important;
    --bs-table-hover-bg: var(--bg-surface-hover) !important;
    color: var(--text-primary) !important;
}
.table td, .table th {
    border-color: var(--border-color) !important;
}
.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--bg-surface-hover) !important;
    color: var(--text-primary) !important;
}
.table-hover > tbody > tr:hover > * {
    background-color: var(--bg-surface-hover) !important;
    color: var(--text-primary) !important;
}

/* Badges */
.badge.bg-light {
    background-color: var(--bg-surface-hover) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color) !important;
}

/* Premium Theme-Aware Alerts */
.alert {
    background-color: var(--bg-surface-hover) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}
.alert-primary {
    background-color: rgba(79, 70, 229, 0.08) !important;
    border-color: rgba(79, 70, 229, 0.25) !important;
    color: var(--primary-color) !important;
}
.alert-success {
    background-color: rgba(16, 185, 129, 0.08) !important;
    border-color: rgba(16, 185, 129, 0.25) !important;
    color: #10b981 !important;
}
.alert-danger {
    background-color: rgba(239, 68, 68, 0.08) !important;
    border-color: rgba(239, 68, 68, 0.25) !important;
    color: #ef4444 !important;
}
.alert-warning {
    background-color: rgba(245, 158, 11, 0.08) !important;
    border-color: rgba(245, 158, 11, 0.25) !important;
    color: #f59e0b !important;
}
.alert-info {
    background-color: rgba(6, 182, 212, 0.08) !important;
    border-color: rgba(6, 182, 212, 0.25) !important;
    color: #06b6d4 !important;
}

/* Premium Theme-Aware Pagination */
.pagination {
    gap: 4px;
}
.page-link {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-secondary) !important;
    border-radius: var(--border-radius-sm) !important;
    padding: 0.5rem 0.75rem !important;
    transition: all var(--transition-fast) !important;
}
.page-link:hover {
    background-color: var(--bg-surface-hover) !important;
    border-color: var(--border-color-strong) !important;
    color: var(--text-primary) !important;
}
.page-item.active .page-link {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: #ffffff !important;
}
.page-item.disabled .page-link {
    background-color: var(--bg-app) !important;
    border-color: var(--border-color) !important;
    opacity: 0.5;
}

/* Animation Entry States */
.main-content > .container-fluid,
.bento-card,
.gsap-title,
.gsap-subtitle,
.gsap-reveal {
    opacity: 1;
}

/* Dropdown Caret Removal (Double Arrow Bug Fix) */
#sidebar .dropdown-toggle::after,
.sidebar .dropdown-toggle::after,
.dropdown-toggle.no-caret::after {
    display: none !important;
}

/* Modal Overrides to Prevent Backdrop Freezes */
.modal {
    z-index: 1060 !important;
}
.modal-backdrop {
    z-index: 1050 !important;
}

/* Dark Mode Dynamic Contrast Filters */
[data-bs-theme="dark"] .brand-logo-img,
[data-bs-theme="dark"] .invert-dark {
    filter: invert(1) brightness(2);
}

/* Premium Native Button Scale Hover Utility */
.btn-premium-scale {
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease !important;
}
.btn-premium-scale:hover {
    transform: translateY(-2px) scale(1.02) !important;
}
.btn-premium-scale:active {
    transform: translateY(0) scale(0.98) !important;
}

/* Sparkline Glowing Pulse Animation */
@keyframes pulse-dot {
    0% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.6); opacity: 0.8; }
    100% { transform: scale(1); opacity: 0.4; }
}
.pulse-sparkline {
    animation: pulse-dot 2s infinite ease-in-out;
    transform-origin: 100px 12px;
}