/* Elite Light Blue - Design System (Dantas Code Style) */
:root {
    --bg: #f8fafc;               /* Slate 50 - Very Light Background */
    --panel: #ffffff;            /* White Panels */
    --sidebar: #ffffff;          /* Clean White Sidebar */
    --sidebar-text: #1e293b;
    --text: #0f172a;             /* Slate 900 - Dark Text */
    --muted: #64748b;            /* Slate 500 - Muted Text */
    --primary: #2563eb;          /* Royal Blue 600 */
    --primary-light: #eff6ff;
    --primary-glow: rgba(37, 99, 235, 0.1);
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --line: #e2e8f0;             /* Slate 200 - Subtle Borders */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    transition: all 0.2s ease;
}

/* Elite Utility Matriz */
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.text-center { text-align: center; }
.p-0 { padding: 0 !important; }
.p-30 { padding: 30px !important; }
.m-0 { margin: 0 !important; }
.gap-10 { gap: 10px; }
.gap-20 { gap: 20px; }
.w-full { width: 100%; }
.overflow-hidden { overflow: hidden; }

@media (max-width: 640px) {
    .w-full-mobile { width: 100% !important; }
    .p-30 { padding: 20px !important; } /* Responsive padding for small screens */
}

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

/* Sidebar Elite Light */
.sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--line);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.02);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }

.brand { display: flex; gap: 12px; align-items: center; padding-left: 10px; }
.brand-mark {
    width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
    font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--primary), #1d4ed8);
    box-shadow: 0 4px 12px var(--primary-glow);
}
.sidebar h1 { margin: 0; font-size: 1.15rem; color: var(--text); font-weight: 700; }
.sidebar p { margin: 2px 0 0; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

.sidebar nav { display: grid; gap: 6px; margin-top: 20px; }
.sidebar nav a {
    text-decoration: none; color: var(--muted); border-radius: 10px;
    padding: 12px 16px; display: flex; gap: 14px; align-items: center; 
    font-weight: 500; font-size: 0.9rem;
}
.sidebar nav a i { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar nav a.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}
.sidebar nav a:hover:not(.active) {
    background: #f1f5f9;
    color: var(--text);
    transform: translateX(5px);
    box-shadow: -4px 0 0 0 var(--primary); /* Elite Indicator */
}

.cron-note {
    margin-top: auto; border: 1px solid var(--line); border-radius: var(--radius); 
    padding: 16px; background: #f8fafc;
}
.cron-note strong { color: var(--primary); font-size: 0.8rem; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cron-note code { font-size: 0.75rem; color: var(--muted); background: #fff; padding: 4px 8px; border-radius: 4px; border: 1px solid var(--line); display: block; overflow-x: auto; }

/* Main Content Area */
.content { padding: 40px; max-width: 1400px; margin: 0 auto; width: 100%; }

.topbar { margin-bottom: 35px; display: flex; justify-content: space-between; align-items: center; }
.topbar-title { margin: 0; font-size: 1.75rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.topbar-subtitle { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }

/* Buttons & Links */
.btn-primary, .primary-link {
    background: var(--primary); color: #fff; padding: 12px 24px; border-radius: 10px;
    text-decoration: none; font-weight: 600; font-size: 0.9rem; border: none;
    display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
    box-shadow: 0 4px 14px 0 rgba(37, 99, 235, 0.3);
}
.btn-primary:hover { background: #1d4ed8; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4); }

.ghost-btn {
    background: #fff; border: 1px solid var(--line); color: var(--muted);
    padding: 12px 20px; border-radius: 10px; text-decoration: none; font-size: 0.85rem;
    display: inline-flex; align-items: center; gap: 8px; font-weight: 500;
    min-height: 44px; justify-content: center;
}
.btn-primary { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.ghost-btn:hover { background: #f1f5f9; border-color: var(--primary); color: var(--primary); }

/* Panels & KPI Cards - Elite Refinement (Senior Grade) */
.panel { 
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); 
    padding: 30px; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05); margin-bottom: 30px; 
}
.panel h3 { margin: 0 0 25px; font-size: 1.15rem; font-weight: 700; color: var(--text); display: flex; gap: 12px; align-items: center; }
.panel h3 i { color: var(--primary); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 35px; }
.card { 
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%); 
    padding: 25px; border-radius: var(--radius); border: 1px solid var(--line); 
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); position: relative; overflow: hidden;
    display: flex; flex-direction: column; height: 100%; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.card:hover { transform: translateY(-5px); box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); border-color: var(--primary-light); }

.card span { color: var(--muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.card strong { display: block; margin-top: auto; padding-top: 15px; font-size: 2.2rem; font-weight: 800; color: var(--text); letter-spacing: -1px; }

/* Dashboard Background Icons Embebed */
.card i.bg-icon {
    position: absolute; right: -10px; top: -10px; font-size: 4.5rem; 
    opacity: 0.08; transform: rotate(-15deg); transition: all 0.3s ease;
}
.card:hover i.bg-icon { transform: rotate(0deg) scale(1.1); opacity: 0.12; }

/* Data Tables */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
table { width: 100%; border-collapse: collapse; }
th { background: #f8fafc; color: var(--muted); text-align: left; padding: 18px 20px; font-size: 0.7rem; text-transform: uppercase; font-weight: 700; border-bottom: 1px solid var(--line); }
td { padding: 18px 20px; border-bottom: 1px solid var(--line); font-size: 0.9rem; color: #334155; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f1f5f9; }

/* Status Badges */
.badge { padding: 5px 12px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; display: inline-flex; align-items: center; gap: 6px; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* Forms */
.form-grid { display: grid; gap: 20px; }
label { color: #475569; font-size: 0.8rem; font-weight: 600; margin-bottom: 8px; display: block; }
input, select, textarea {
    width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 8px; 
    font-size: 0.9rem; color: var(--text); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

/* Alerts */
.alert { padding: 16px 20px; border-radius: 10px; margin-bottom: 25px; display: flex; align-items: center; gap: 12px; font-weight: 500; font-size: 0.9rem; }
.alert-success, .alert.success { background: #f0fdf4; color: #166534; border: 1px solid #bbfcce; }
.alert-error, .alert.error, .alert.danger { background: #fef2f2; color: #991b1b; border: 1px solid #fee2e2; }
.alert-warning, .alert.warning { background: #fffbeb; color: #92400e; border: 1px solid #fef3c7; }
.alert-info, .alert.info { background: #eff6ff; color: #1e40af; border: 1px solid #dbeafe; }

/* Mobile Header & Responsive Shell */
.mobile-header {
    display: none;
    background: var(--sidebar);
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--primary);
    cursor: pointer;
}

.app-shell { 
    display: grid; 
    grid-template-columns: 280px 1fr; 
    min-height: 100vh;
    background: #f1f5f9; /* Base background */
}

.content { 
    padding: 35px; 
    overflow-y: auto; 
    position: relative;
    background-color: #f1f5f9;
    background-image: radial-gradient(rgba(37, 99, 235, 0.05) 1px, transparent 1px);
    background-size: 30px 30px; /* Subtle Elite Grid */
}

.content::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at 10% 10%, rgba(37, 99, 235, 0.03) 0%, transparent 40%),
                radial-gradient(circle at 90% 90%, rgba(37, 99, 235, 0.03) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

@media (max-width: 1024px) {
    .app-shell { grid-template-columns: 1fr; }
    
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        display: flex !important;
        visibility: hidden;
    }

    .sidebar.open {
        left: 0;
        visibility: visible;
        box-shadow: 0 0 100px rgba(0,0,0,0.5);
    }

    .mobile-header { display: flex; }
    .content { padding: 25px; }
    
    .topbar { flex-direction: column; align-items: flex-start; gap: 15px; }
    .topbar-right { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
    .kpis { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
    .kpis { grid-template-columns: 1fr; }
    .topbar-title { font-size: 1.4rem; }
    
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 600px; } /* Force scroll for readability */
    
    .badge { font-size: 0.65rem; padding: 4px 8px; }
    
    .btn-primary, .primary-link, .ghost-btn { 
        width: 100%; 
        justify-content: center; 
        font-size: 0.85rem;
    }
}

/* Sidebar Backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* Elite Responsive Utilities */
.grid-stack {
    display: grid;
    gap: 25px;
    grid-template-columns: 1fr 1fr;
}

.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
.grid-1-1-5 { grid-template-columns: 1fr 1.5fr; }

@media (max-width: 1024px) {
    .grid-stack, .grid-2-1, .grid-1-2, .grid-1-1-5 { 
        grid-template-columns: 1fr !important; 
    }
}

.flex-between-stack {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Fixed: Crucial for mobile stacking */
    gap: 20px;
}

.profile-avatar-stack {
    display: flex;
    align-items: center;
    gap: 25px;
}

@media (max-width: 768px) {
    .profile-avatar-stack {
        flex-direction: column;
        text-align: center;
        width: 100% !important;
        gap: 15px;
    }
}

@media (max-width: 640px) {
    .flex-between-stack { 
        flex-direction: column; 
        align-items: center; 
        text-align: center; 
    }
    
    .profile-avatar-stack {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .grid-mobile-1 {
        grid-template-columns: 1fr !important;
    }
}

.section-subtitle { color: var(--muted); font-size: 0.85rem; margin-top: -15px; margin-bottom: 25px; display: block; }

/* --- SENIOR MOBILE POLISH (ELITE HYBRID) --- */
@media (max-width: 768px) {
    :root {
        --radius: 10px; /* Slightly smaller radius for mobile density */
    }
    
    .content {
        padding: 15px !important;
        padding-bottom: 80px !important; /* Spacing for thumb reach */
    }

    .panel {
        padding: 18px !important;
        margin-bottom: 20px;
    }

    /* Input & Button Touch Targets */
    input, select, .btn-primary, .ghost-btn {
        min-height: 48px; /* High precision touch target */
        font-size: 16px !important; /* Prevents auto-zoom on iOS */
    }

    .kpis {
        gap: 15px;
    }

    .card {
        padding: 20px;
    }

    /* Scroll indicators for tables */
    .table-wrap::after {
        content: 'Arrastar para ver mais →';
        display: block;
        text-align: center;
        padding: 10px;
        font-size: 0.7rem;
        color: var(--muted);
        background: #f8fafc;
        border-top: 1px solid var(--line);
    }
}

/* Fix for notch/safe areas */
@supports (padding: env(safe-area-inset-bottom)) {
    .content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }
}
