/* 
   SUBOP SYSTEM — app.css
   Modern Dashdark UI Architecture
*/

:root {
    /* Core Palette - Deep Space & Amber */
    --primary: #f59e0b;
    --primary-glow: rgba(245, 158, 11, 0.25);
    --primary-soft: rgba(245, 158, 11, 0.05);
    
    --accent: #0ea5e9;
    --system-red: #ef4444;
    
    /* Neutral Palette */
    --n-50: #f8fafc;
    --n-100: #f1f5f9;
    --n-200: #e2e8f0;
    --n-300: #cbd5e1;
    --n-400: #94a3b8;
    --n-500: #64748b;
    --n-800: #0f172a;
    --n-900: #020617;
    
    /* Layout Constants */
    --navbar-h: 80px;
    --sidebar-w: 80px;
    --sidebar-w-exp: 280px;
    --radius: 16px;
    --input-h: 54px;
    
    /* Glass Effect */
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: blur(12px);
}

/* ─── Global Reset & Typography ────────────────────────── */
* { box-sizing: border-box; }

body {
    background-color: var(--n-900);
    color: var(--n-200);
    font-family: 'Outfit', 'Inter', sans-serif;
    margin: 0;
    line-height: 1.6;
    overflow-x: hidden;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    background: radial-gradient(circle at 50% -20%, #1e293b 0%, var(--n-900) 70%);
}

/* ─── Structural Components ────────────────────────────── */
.panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 32px;
}

.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    background: #020617;
    border-right: 1px solid var(--glass-border);
    position: fixed;
    top: 0; left: 0;
    z-index: 1000;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.sidebar.expanded { width: var(--sidebar-w-exp); box-shadow: 20px 0 50px rgba(0,0,0,0.5); }

/* ─── Sidebar Brand ──────────────────────────────────────── */
.brand {
    height: var(--navbar-h);
    display: flex; align-items: center;
    padding: 0 20px; gap: 15px;
    border-bottom: 1px solid var(--glass-border);
    overflow: hidden; flex-shrink: 0;
}

.brand-mark {
    min-width: 40px; height: 40px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}

.brand-text {
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.sidebar.expanded .brand-text {
    opacity: 1;
}

.brand-text strong {
    font-size: 16px;
    color: var(--neutral--100);
    letter-spacing: 0.5px;
}

.brand-sub {
    font-size: 11px;
    color: var(--neutral--500);
}

/* ─── Navigation Menu ────────────────────────────────────── */
.menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.menu::-webkit-scrollbar { width: 4px; }
.menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.05); border-radius: 10px; }

.menu-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    margin: 4px 12px;
    border-radius: 12px;
    color: var(--n-50);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    position: relative;
    font-weight: 500;
}

.menu-link i {
    font-size: 18px;
    min-width: 24px;
    text-align: center;
    transition: transform 0.2s;
}

.menu-text {
    opacity: 0;
    transition: opacity 0.2s;
}

.sidebar.expanded .menu-text {
    opacity: 1;
}

.menu-link:hover {
    background: rgba(245, 158, 11, 0.08);
    color: var(--primary);
    box-shadow: inset 0 0 15px rgba(245, 158, 11, 0.05);
}

.menu-link:hover i {
    color: var(--primary);
    filter: drop-shadow(0 0 8px var(--primary-glow));
    transform: scale(1.1);
}

.menu-link.active {
    background: var(--primary);
    color: #000;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.menu-link.active i {
    transform: scale(1.1);
}

/* Grouping / Submenus */
.menu-group { margin-bottom: 5px; }

.menu-arrow {
    margin-left: auto;
    font-size: 10px !important;
    opacity: 0;
    transition: transform 0.3s;
}

.sidebar.expanded .menu-arrow { opacity: 0.6; display: block; }
.sidebar:not(.expanded) .menu-arrow { display: none !important; }
.menu-group.open .menu-arrow { transform: rotate(180deg); opacity: 1; }

.submenu {
    display: none;
    flex-direction: column;
    margin: 5px 12px 5px 44px;
    padding-left: 15px;
    border-left: 1px solid var(--secondary--color-4);
}

.sidebar.expanded .menu-group.open .submenu { display: flex; }

.submenu-link {
    padding: 8px 10px;
    font-size: 13px;
    color: var(--neutral--500);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
}

.submenu-link:hover {
    color: var(--neutral--100);
    background: rgba(255, 255, 255, 0.03);
}

.submenu-link.active {
    color: var(--primary) !important;
    font-weight: 700;
    background: rgba(245, 158, 11, 0.05);
}

.submenu-group-wrapper {
    display: flex;
    flex-direction: column;
    padding: 2px 0;
    margin-bottom: 5px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}

.submenu-link-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 15px 4px 45px;
    font-size: 11px;
    color: #94a3b8;
    text-decoration: none;
    transition: 0.2s;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.submenu-link-mini:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.03);
}

.submenu-link-mini i {
    font-size: 10px;
    width: 14px;
    text-align: center;
    opacity: 0.7;
}

.submenu-link-mini.active {
    color: var(--primary);
    font-weight: 700;
    background: rgba(245, 158, 11, 0.05);
}

/* ─── Sidebar Footer ─────────────────────────────────────── */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0,0,0,0.1);
}

.sidebar-footer-text {
    font-size: 11px;
    color: var(--neutral--500);
    margin-bottom: 12px;
    opacity: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.expanded .sidebar-footer-text { opacity: 1; }

.logout-link {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #ef4444;
    text-decoration: none;
    font-weight: 600;
}

.logout-link span { opacity: 0; }
.sidebar.expanded .logout-link span { opacity: 1; }

/* ─── Main Content Wrapper ───────────────────────────────── */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    transition: margin-left 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; flex-direction: column;
    min-width: 0;
}

.sidebar.expanded + .main { margin-left: var(--sidebar-w-exp); }

.topbar {
    height: var(--navbar-h);
    background: rgba(2, 6, 23, 0.5);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 40px; position: sticky; top: 0; z-index: 900;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 16px 6px 6px;
    background: var(--secondary--color-1);
    border: 1px solid var(--secondary--color-4);
    border-radius: 40px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.user-chip:hover { border-color: var(--accent--primary-1); }

.avatar {
    width: 32px;
    height: 32px;
    background: var(--accent--primary-1);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ─── Page Content ───────────────────────────────────────── */
.content {
    padding: 40px;
}

/* ─── Scrollbars ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--secondary--color-4); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--neutral--600); }

/* ─── Mobile Responsiveness ─────────────────────────────── */
@media (max-width: 1024px) {
    :root {
        --navbar-h: 60px;
        --sidebar-w: 0px; /* Force 0 on mobile */
    }

    .app-shell {
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed !important;
        top: 0;
        left: -280px !important; /* Move completely off-screen */
        width: 280px !important;
        height: 100vh !important;
        z-index: 2000 !important;
        transition: left 0.3s ease !important;
        display: flex !important; /* Ensure it exists to be shown */
    }
    
    .sidebar.mobile-visible {
        left: 0 !important;
        box-shadow: 10px 0 30px rgba(0,0,0,0.8) !important;
    }

    .sidebar .menu-text, .sidebar .brand-text, .sidebar .sidebar-footer-text, .sidebar .logout-link span {
        opacity: 1 !important;
        pointer-events: auto !important;
    }
    
    .sidebar .menu-arrow {
        display: block !important;
        opacity: 0.6;
    }

    .main { 
        margin-left: 0 !important; 
        width: 100% !important;
        min-width: 100% !important;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.8);
        backdrop-filter: blur(4px);
        z-index: 1500;
    }
    
    .sidebar-overlay.active { display: block; }

    .content { padding: 15px !important; }
    
    .topbar {
        padding: 0 15px !important;
        height: var(--navbar-h) !important;
        gap: 10px;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255,255,255,0.1);
        border: 1px solid var(--glass-border);
        border-radius: 10px;
        color: white;
        cursor: pointer;
        z-index: 1001;
    }
}

.mobile-menu-toggle { display: none; }

/* ─── Universal Intelligent Form System ─────────────────── */
.form-label {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--n-200);
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.form-control {
    width: 100%;
    height: var(--input-h);
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    color: #111827;
    padding: 0 20px;
    font-size: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-select {
    width: 100%;
    height: var(--input-h);
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    color: #111827;
    padding: 0 20px;
    font-size: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control:focus, .form-select:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
    outline: none;
}

.form-control:disabled, .form-select:disabled, .form-control[readonly], .form-select[readonly] {
    background: #f1f5f9;
    color: #64748b;
    border-color: #cbd5e1;
}

textarea.form-control { height: auto; min-height: 120px; padding: 18px 20px; resize: vertical; }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: var(--input-h); padding: 0 32px;
    border-radius: 14px; font-weight: 700; border: none;
    cursor: pointer; transition: 0.3s; gap: 10px; font-family: inherit;
    text-decoration: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #d97706 100%);
    color: #000; box-shadow: 0 8px 20px -5px rgba(245, 158, 11, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px -5px rgba(245, 158, 11, 0.5);
}

.btn-secondary {
    background: rgba(255,255,255,0.05);
    color: white; border: 1px solid rgba(255,255,255,0.1);
}

.btn-secondary:hover { background: rgba(255,255,255,0.15); }

.btn.ghost { background: transparent; border: 1px solid var(--glass-border); color: var(--n-400); }
.btn.ghost:hover { background: rgba(255,255,255,0.05); color: white; }

/* ─── Universal Grid System ─────────────────────────────── */
.row { display: flex; flex-wrap: wrap; margin: -12px; }
.g-4 { margin: -12px; }
.g-4 > [class*="col-"] { padding: 12px; }

.col-12 { width: 100%; }
.col-md-6 { width: 50%; }
.col-md-4 { width: 33.333%; }
.col-md-3 { width: 25%; }
.col-md-2 { width: 20%; }

@media (max-width: 768px) {
    .col-md-6, .col-md-4, .col-md-3, .col-md-2 { width: 100%; }
    .topbar { padding: 0 20px; }
    .panel { padding: 24px; }
}

/* Utilities */
.mt-1 { margin-top: 4px !important; }
.mt-5 { margin-top: 40px !important; }
.mb-4 { margin-bottom: 24px !important; }
.mb-5 { margin-bottom: 32px !important; }
.pt-4 { padding-top: 24px !important; }
.border-top { border-top: 1px solid var(--glass-border) !important; }
.rounded-4 { border-radius: 20px !important; }
.d-flex { display: flex !important; }
.gap-3 { gap: 16px !important; }

/* ─── Premium Selection Components ────────────────────────── */
.check-premium {
    display: flex; align-items: center; gap: 12px;
    cursor: pointer; position: relative; user-select: none;
    padding: 12px 16px; background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border); border-radius: 14px;
    transition: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.check-premium:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.2); }

.check-premium input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; }

.check-box {
    height: 20px; width: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px; transition: 0.3s; position: relative;
}

.check-premium input:checked ~ .check-box {
    background: var(--primary); border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.check-box:after {
    content: ""; position: absolute; display: none;
    left: 6px; top: 2px; width: 5px; height: 10px;
    border: solid #000; border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
}

.check-premium input:checked ~ .check-box:after { display: block; }

.check-text { font-size: 14px; font-weight: 600; color: var(--n-400); transition: 0.2s; }
.check-premium input:checked ~ .check-text { color: white; }

/* Dashboard Cards & Layout */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 40px; }
.page-head h2 { font-size: 28px; font-weight: 800; margin: 0; letter-spacing: -0.5px; }

/* Encoding Fixes for Separators */
.form-section-divider { height: 1px; background: var(--glass-border); margin: 40px 0; }
.form-section-title { font-size: 14px; font-weight: 800; text-transform: uppercase; color: var(--primary); letter-spacing: 1px; margin-bottom: 24px; }

.text-muted, .muted { color: #f8fafc !important; }
.opacity-50 { opacity: 0.5 !important; }
.opacity-75 { opacity: 0.75 !important; }

/* ─── Premium UI Components (v7) ────────────────────────── */
.btn-premium-primary {
    background: var(--primary);
    color: #000;
    font-weight: 700;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    width: 100%;
    transition: all 0.3s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
}
.btn-premium-primary:hover { background: #fbbf24; transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(245, 158, 11, 0.3); color: #000; }

.btn-premium-dark {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 10px;
    transition: all 0.3s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
}
.btn-premium-dark:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.2); color: #fff; }

.btn-premium-secondary {
    background: rgba(14, 165, 233, 0.1);
    color: var(--accent);
    font-weight: 600;
    border: 1px solid rgba(14, 165, 233, 0.2);
    padding: 10px 20px;
    border-radius: 10px;
    transition: all 0.3s;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
}
.btn-premium-secondary:hover { background: var(--accent); color: #fff; transform: translateY(-2px); }

.form-label-premium { font-size: 11px; text-transform: uppercase; font-weight: 700; color: #64748b; margin-bottom: 8px; display: block; letter-spacing: 0.5px; }
.form-control-premium, .form-select-premium {
    background: #020617;
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    width: 100%;
    transition: all 0.2s;
}
.form-control-premium:focus, .form-select-premium:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1); outline: none; }

.dropdown-menu-premium {
    position: absolute; top: 100%; right: 0; min-width: 220px;
    background: #0f172a; border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px; padding: 8px; margin-top: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5); display: none; z-index: 1000;
}
.dropdown-menu-premium.show { display: block; animation: fadeIn 0.15s ease-out; }
.dropdown-menu-premium a {
    display: block; padding: 10px 16px; color: #94a3b8; text-decoration: none;
    border-radius: 8px; font-size: 13px; transition: all 0.2s;
}
.dropdown-menu-premium a:hover { background: rgba(255,255,255,0.05); color: #fff; }

.filter-panel-premium {
    background: rgba(15, 23, 42, 0.4); border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px; padding: 24px; margin-bottom: 24px;
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    background: rgba(0,0,0,0.1);
    border-radius: 12px;
}

.table-wrap table {
    min-width: 800px;
}

.modern-tabs {
    display: flex; gap: 8px; border-bottom: 2px solid rgba(255, 255, 255, 0.05);
    overflow-x: auto; padding-top: 20px; margin-bottom: 30px;
}
.modern-tabs a { 
    padding: 14px 20px; color: #94a3b8; text-decoration: none; 
    border-bottom: 2px solid transparent; margin-bottom: -2px; 
    transition: all 0.3s; font-weight: 600; font-size: 0.85em;
    text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap;
    display: flex; align-items: center; opacity: 0.7;
}
.modern-tabs a:hover { color: #fff; opacity: 1; background: rgba(255,255,255,0.03); }
.modern-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); background: rgba(245, 158, 11, 0.08); opacity: 1; }

.modal-content-premium {
    background: #0f172a; background-image: linear-gradient(to bottom right, rgba(255,255,255,0.02), transparent);
    width: 95%; max-width: 800px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.1) !important;
    overflow: hidden;
}
.modal-header-premium { padding: 24px 32px; border-bottom: 1px solid rgba(255,255,255,0.05); display: flex; justify-content: space-between; align-items: center; }
.modal-body-premium { padding: 32px; }

.badge-sys { background: rgba(255,255,255,0.05); color: #94a3b8; padding: 2px 8px; border-radius: 4px; font-size: 10px; text-transform: uppercase; border: 1px solid rgba(255,255,255,0.1); }
.badge-custom { background: rgba(14, 165, 233, 0.1); color: var(--accent); padding: 2px 8px; border-radius: 4px; font-size: 10px; text-transform: uppercase; border: 1px solid rgba(14, 165, 233, 0.2); }

/* ─── Custom Premium Switch ─────────────────────────────── */
.form-switch .form-check-input {
    width: 3em;
    height: 1.5em;
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba(255, 255, 255, 0.25)'/%3e%3c/svg%3e");
    transition: background-position .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23000'/%3e%3c/svg%3e");
    box-shadow: 0 0 10px var(--primary-glow);
}

.form-switch .form-check-input:focus {
    box-shadow: 0 0 0 4px var(--primary-soft);
    border-color: var(--primary);
}

/* ─── Pagination Premium ────────────────────────────────── */
.pagination-premium .page-item .page-link {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--n-400);
    padding: 8px 16px;
    border-radius: 8px;
    margin: 0 3px;
    transition: all 0.3s;
}

.pagination-premium .page-item.active .page-link {
    background: var(--primary);
    color: #000;
    border-color: var(--primary);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.pagination-premium .page-item.disabled .page-link {
    background: transparent;
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-premium .page-link:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

/* ── MODAIS PREMIUM ────────────────────────────────────────── */
.modal-overlay-premium {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content-premium {
    position: relative;
    width: 100%;
    animation: modalAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalAppear {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
