@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');
@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css");

:root {
    /* Color Palette */
    --bg-dark: #090B10;
    --bg-card: rgba(25, 30, 45, 0.6);
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --accent-primary: #38BDF8; /* Cyan */
    --accent-success: #10B981; /* Emerald */
    --accent-danger: #F43F5E;  /* Rose */
    --accent-warning: #F59E0B; /* Amber */
    
    /* Gradients */
    --gradient-glow: linear-gradient(135deg, #38BDF8 0%, #818CF8 100%);
    --gradient-card: linear-gradient(145deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.8));
    
    /* Glassmorphism and Shadows */
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    /* Spaces */
    --sidebar-width: 260px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    background-image: radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.05) 0%, transparent 50%),
                      radial-gradient(circle at 80% 80%, rgba(129, 140, 248, 0.05) 0%, transparent 50%);
}

/* Utility Utilities */
.glass {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--shadow-glow);
}

/* Layout Structure */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
aside.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border-right: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.95);
    z-index: 1000;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem 0.5rem;
    margin-bottom: 2rem;
}

.logo-icon {
    background: var(--gradient-glow);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
}

.logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    background: -webkit-linear-gradient(white, #CBD5E1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.nav-item a:hover, .nav-item.active a {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-primary);
}

.nav-item a i {
    font-size: 1.2rem;
}

/* Main Content Area */
main.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
}

/* Dashboard Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-glow);
    border: 2px solid var(--glass-border);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.stat-val {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 5px 0;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-change {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 0.85rem;
    padding: 4px 8px;
    border-radius: 6px;
}

.up { background: rgba(16, 185, 129, 0.1); color: var(--accent-success); }
.down { background: rgba(244, 63, 94, 0.1); color: var(--accent-danger); }

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.widget-card {
    padding: 1.5rem;
}

.widget-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* =============================================
   HYPER-RESPONSIVE PATCH (NON-DESTRUCTIVE)
   ============================================= */

/* Mobile Trigger (Hidden on Desktop) */
.mob-trigger {
    display: none;
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: #FFF;
    font-size: 1.2rem;
    cursor: pointer;
    margin-right: 15px;
}

@media (max-width: 1024px) {
    .content-grid { grid-template-columns: 1fr; }
    
    /* Detail Dashboards stack nicely */
    div[style*="grid-template-columns: 1.5fr 1fr"],
    div[style*="grid-template-columns: 2fr 1fr"],
    .hero-wrap { 
        display: flex !important;
        flex-direction: column !important; 
    }
}

@media (max-width: 768px) {
    /* ====================================================
       CRITICAL MOBILE FLAT-VIEW: TOTAL SCROLL ELIMINATION
       ==================================================== */
    body, html, .app-container {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important; /* RIGID CONTAINMENT */
    }
    
    aside.sidebar {
        transform: translateX(-100%);
        width: 80%; 
        transition: transform 0.3s ease-in-out;
        box-shadow: 20px 0 60px rgba(0,0,0,0.7);
        z-index: 999999;
    }
    aside.sidebar.active {
        transform: translateX(0);
    }
    
    main.main-content {
        margin-left: 0;
        padding: 0.8rem; 
        width: 100%;
        overflow-x: hidden; /* DO NOT LET CONTENT PUSH WIDTH */
    }
    
    .mob-trigger {
        display: flex;
    }

    .top-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
        width: 100%;
    }
    
    .user-profile {
        width: 100%;
        justify-content: flex-start;
        border-top: 1px solid rgba(255,255,255,0.05);
        padding-top: 0.8rem;
    }
    
    .flex-between {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem;
    }
    .flex-between div[style*="display:flex"] {
        flex-direction: column !important;
        width: 100%;
        gap: 8px;
    }
    .btn-custom, .btn-action {
        width: 100%;
        justify-content: center;
        padding: 14px; /* Bigger tap targets */
    }

    /* Fluid Text Reduction for Small Viewports */
    .lbl-lg, h1[style*="font-size:3.5rem"], h1[style*="font-size:2rem"] {
        font-size: 1.6rem !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Force dense stat grids to collapse into lists */
    .tile-grid, 
    div[style*="grid-template-columns: 1.5fr 1fr"],
    div[style*="grid-template-columns: 2fr 1fr"],
    div[style*="grid-template-columns: 1.5fr 1fr;"],
    div[style*="grid-template-columns: 2fr 1fr;"] {
        display: flex !important;
        flex-direction: column !important;
        width: 100%;
    }

    /* --- ULTIMATE TABLE-TO-CARD CONVERSION ---
       Completely obliterates horizontal scrolling by turning rows into cards */
    .luxury-table, table.luxury-table {
        display: block !important;
        width: 100% !important;
    }
    .luxury-table thead, table.luxury-table thead {
        display: none !important; /* Hide bulky headers */
    }
    .luxury-table tbody, table.luxury-table tbody {
        display: block !important;
        width: 100%;
    }
    .luxury-table tr, table.luxury-table tr {
        display: flex !important;
        flex-direction: column !important;
        background: rgba(255,255,255,0.02);
        border: 1px solid rgba(255,255,255,0.05) !important;
        border-radius: 15px;
        margin-bottom: 1rem;
        padding: 1rem;
        width: 100%;
    }
    .luxury-table td, table.luxury-table td {
        display: block !important;
        width: 100%;
        padding: 6px 0 !important;
        text-align: left !important;
        border-bottom: none !important;
    }
    .luxury-table td:first-child {
        font-size: 1rem;
        font-weight: 900;
        color: #FFF;
        margin-bottom: 8px;
        border-bottom: 1px dashed rgba(255,255,255,0.05) !important;
        padding-bottom: 10px !important;
    }
    /* Center action columns in card mode */
    .luxury-table td[style*="text-align:center"],
    .luxury-table td:last-child {
        margin-top: 10px;
        display: flex !important;
        justify-content: flex-start !important;
    }

    /* Fix nested grids or charts breaking overflow */
    .glass {
        width: 100%;
        padding: 1rem !important;
    }
    
    form[style*="display:flex"] {
        flex-direction: column;
        align-items: stretch !important;
    }
}
