
:root {
    --primary-color: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #ccfbf1;
    --secondary-color: #f8fafc;
    --accent-color: #f59e0b;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --bg-light: #f1f5f9;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --danger-color: #ef4444;
    --success-color: #10b981;
}

/* Base Reset & Typography */
html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    overflow-x: hidden !important; /* Critical for mobile to prevent horizontal scrolling */
    background-color: var(--bg-light);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-dark);
}

* { box-sizing: border-box; }

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

/* Sidebar Layout */
.sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    height: var(--topbar-height);
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 20px;
    flex-shrink: 0;
}

.sidebar-brand h4 { margin: 0; font-size: 1.2rem; font-weight: 700; }

.sidebar-user {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.sidebar-user img {
    width: 60px; height: 60px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
    margin-bottom: 10px;
}

.sidebar-nav-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.nav-link {
    color: var(--text-dark) !important;
    padding: 12px 20px !important;
    font-weight: 500 !important;
    display: flex !important;
    align-items: center !important;
    border-left: 3px solid transparent;
}

.nav-link i { width: 25px; color: var(--text-muted); margin-right: 10px; }
.nav-link:hover, .nav-link.active {
    background: var(--bg-light) !important;
    color: var(--primary-color) !important;
    border-left-color: var(--primary-color) !important;
}
.nav-link:hover i, .nav-link.active i { color: var(--primary-color); }

/* Top Navbar Layout */
.top-navbar {
    background: #ffffff;
    height: var(--topbar-height);
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    z-index: 1040;
    box-shadow: 0 1px 5px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    transition: left 0.3s ease;
}

/* Toggle Button (Hidden on Desktop) */
.sidebar-toggle-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: var(--text-dark);
    padding: 5px 10px;
}

/* Main Wrapper */
.main-wrapper {
    flex-grow: 1;
    margin-top: var(--topbar-height);
    margin-left: var(--sidebar-width);
    padding: 25px;
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 5px;
}

/* Grid & Cards */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -10px;
    margin-left: -10px;
}

.col-12, .col-md-6, .col-lg-3 {
    padding-right: 10px;
    padding-left: 10px;
    width: 100%;
}

.stat-box {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 20px;
    display: flex;
    align-items: center;
    margin-bottom: 20px; /* Crucial for mobile stacking */
    height: 100%;
    border-left-width: 4px;
    border-left-style: solid;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-right: 15px;
    flex-shrink: 0;
}

.stat-content h3 { margin: 0; font-size: 1.6rem; font-weight: 700; }
.stat-content span { font-size: 0.85rem; color: var(--text-muted); display: block; margin-bottom: 5px; }

.card {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    border: none;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    background: #fff;
    border-radius: 8px 8px 0 0;
}

.card-body { padding: 20px; }

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1045;
}

/* ==========================================================================
   MOBILE MEDIA QUERIES (THE ABSOLUTE FIX)
   ========================================================================== */
@media (min-width: 768px) {
    .col-md-6 { width: 50%; }
}

@media (min-width: 992px) {
    .col-lg-3 { width: 25%; }
}

@media (max-width: 991px) {
    /* Hide sidebar */
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-show { transform: translateX(0); }
    .sidebar-overlay.mobile-show { display: block; }
    
    /* Expand topbar */
    .top-navbar { left: 0; padding: 0 15px; }
    .sidebar-toggle-btn { display: block; }
    
    /* Expand main wrapper */
    .main-wrapper {
        margin-left: 0;
        width: 100%;
        padding: 15px;
    }
    
    /* Ensure proper stacking */
    .col-lg-3, .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}
