/* =========================================
   CORE VARIABLES & TOKENS
   ========================================= */
   :root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --glass: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.4);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.75rem;
    --font-heading: "Outfit", sans-serif;
    --font-body: "Inter", sans-serif;
    
    /* Z-Index Layers */
    --z-sidebar: 100;
    --z-header: 90;
    --z-modal: 1000;
  }
  
  /* Dark Mode Toggle Support */
  [data-theme="dark"] {
    --background: #0f172a;
    --surface: #1e293b;
    --text-main: #f8fafc;
    --text-light: #94a3b8;
    --border: #334155;
    --glass: rgba(30, 41, 59, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);
  }

  /* Custom Scrollbar */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  ::-webkit-scrollbar-track {
    background: transparent;
  }
  ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
  }
  [data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #475569;
  }
  [data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
  }
  
  /* Reset & Base */
  * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  
  body {
    font-family: var(--font-body);
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
  }
  
  /* =========================================
     RESPONSIVE LAYOUT SYSTEM
     ========================================= */
  
  /* Mobile First Container */
  .app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
  }
  
  /* Sidebar Mobile - Hidden by default */
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px; /* Off-canvas */
    width: 280px;
    height: 100vh;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    z-index: var(--z-sidebar);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    box-shadow: 4px 0 24px rgba(0,0,0,0.1);
  }
  
  .sidebar.active {
    transform: translateX(280px);
  }
  
  /* Main Content Area */
  .main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    transition: margin-left 0.3s ease;
  }
  
  .main-header {
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: var(--z-header);
  }
  
  .main-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
  }
  
  /* Toggle Button Mobile */
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 1.25rem;
    cursor: pointer;
    margin-right: 0.5rem;
  }
  
  /* Backdrop for mobile sidebar */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 95;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .sidebar-backdrop.active {
    display: block;
    opacity: 1;
  }

  /* =========================================
     UTILITY CLASSES & ANIMATIONS
     ========================================= */
  
  /* Glassmorphism Utility */
  .glass {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
  }

  /* Animations */
  @keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
  }
  
  .fade-in-up {
    animation: fadeInUp 0.5s ease-out forwards;
  }
  
  .delay-100 { animation-delay: 100ms; }
  .delay-200 { animation-delay: 200ms; }
  .delay-300 { animation-delay: 300ms; }

  /* Skeleton Loading */
  .skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    display: inline-block;
    height: 1rem;
    width: 100%;
  }

  @keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  [data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  }
  
  /* =========================================
     DESKTOP ADAPTATION (min-width: 1024px)
     ========================================= */
  @media (min-width: 1024px) {
    .app-container {
      flex-direction: row;
    }
  
    .sidebar {
      position: sticky;
      left: 0;
      transform: none;
      box-shadow: none;
      height: 100vh;
    }
  
    .sidebar-toggle {
      display: none;
    }
  
    .main-wrapper {
      width: calc(100% - 280px); /* Specific width calculation */
    }
  
    .main-content {
      padding: 2rem;
    }
  }
  
  /* =========================================
     COMPONENTS
     ========================================= */
  
  /* Cards */
  .card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
  }
  
  /* Stat Cards */
  .stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Bigger cards on mobile */
    gap: 1rem;
    margin-bottom: 2rem;
  }
  
  .stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  
  .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
    margin: 0.5rem 0;
  }
  
  /* Navigation */
  .nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 1rem;
  }
  
  .nav-link {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem; /* Larger touch target */
    color: var(--text-light);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-weight: 500;
  }
  
  .nav-link:hover,
  .nav-link.active {
    background-color: var(--background);
    color: var(--primary);
  }
  
  .nav-link i {
    width: 24px;
    margin-right: 0.75rem;
    text-align: center;
    font-size: 1.1rem;
  }
  
  /* Tables - Responsive Wrapper */
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap; /* Prevent awkward wrapping in cells */
  }
  
  th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
  }
  
  th {
    background-color: var(--background);
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  
  /* Buttons */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    border-radius: var(--radius);
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    font-size: 0.95rem;
    min-height: 44px; /* Touch target size */
  }
  
  /* Premium Buttons */
  .btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
  }
  
  .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.4);
    filter: brightness(110%);
  }

  .btn-secondary {
    background-color: var(--background);
    color: var(--text-main);
    border: 1px solid var(--border);
  }

  .btn-secondary:hover {
    background-color: var(--border);
    transform: translateY(-2px);
  }

  /* Premium Badges */
  .badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 9999px;
    white-space: nowrap;
  }

  .bg-success { background: rgba(16, 185, 129, 0.2) !important; color: #10b981 !important; }
  .bg-warning { background: rgba(245, 158, 11, 0.2) !important; color: #f59e0b !important; }
  .bg-danger { background: rgba(239, 68, 68, 0.2) !important; color: #ef4444 !important; }
  .bg-info { background: rgba(59, 130, 246, 0.2) !important; color: #3b82f6 !important; }
  .bg-secondary { background: rgba(100, 116, 139, 0.2) !important; color: #94a3b8 !important; }

  /* Dark Mode Overrides for Bootstrap Utilities */
  [data-theme="dark"] .bg-white {
    background-color: var(--surface) !important;
    color: var(--text-main) !important;
  }

  [data-theme="dark"] .border-bottom {
    border-color: var(--border) !important;
  }

  [data-theme="dark"] .text-muted {
    color: #94a3b8 !important;
  }
  
  /* Header Extras */
  .search-bar {
    display: none; /* Hidden on mobile by default */
  }
  
  @media (min-width: 768px) {
    .search-bar {
      display: block;
      position: relative;
      width: 320px;
    }
    
    .search-bar input {
      width: 100%;
      padding: 0.625rem 1rem 0.625rem 2.5rem;
      border-radius: 99px;
      border: 1px solid var(--border);
      background: var(--background);
    }
    
    .search-bar i {
      position: absolute;
      left: 1rem;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-light);
    }
  }
  
  .brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  
  .logo-box {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* User Profile in Sidebar */
  .sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
  }
  
  .user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius);
  }
  
  .user-card .avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
  }
  
  .user-meta {
    display: flex;
    flex-direction: column;
  }
  
  .user-meta .name {
    font-size: 0.875rem;
    font-weight: 600;
  }
  
  .user-meta .role {
    font-size: 0.75rem;
    color: var(--text-light);
  }

  /* Utility Classes */
  .d-none-mobile { display: none; }
  @media(min-width: 768px) { .d-none-mobile { display: block; } }
