/* =========================================================
   🎨 VARIABLES
========================================================= */
:root {
    --primary: #5348eb;
    --secondary: #26c165;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
  
    --bg: #f5f6fa;
    --text: #1a1a1a;
    --border: #e5e7eb;
    --nav-dropdown-top: 56px;
  }
  
  /* =========================================================
     🔧 RESET + BASE LAYOUT
  ========================================================= */
  body {
    margin: 0;
    font-family: sans-serif;
    background: var(--bg);
    color: var(--text);
  
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
  }
  
  /* =========================================================
     🧱 LAYOUT
  ========================================================= */
  .layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    align-items: stretch;
  }
  
  .layout.sidebar-collapsed {
    grid-template-columns: 1fr;
  }
  
  .layout.sidebar-collapsed .sidebar {
    display: none;
  }
  
  .layout.sidebar-collapsed .footer-container {
    max-width: 100%;
  }
  
  /* Sidebar */
  .sidebar {
    background: #111827;
    color: white;
    padding: 20px;
    height: 100%;
    box-sizing: border-box;
  }

  .sidebar .nav-item {
    color: #e5e7eb;
    text-decoration: none;
  }

  .sidebar .nav-item:hover {
    color: #ffffff;
  }

  .sidebar-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }

  .sidebar-title {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 10px;
  }

  .lang-switch {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .lang-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.06);
    color: #e5e7eb;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
  }

  .lang-pill:hover {
    border-color: rgba(255, 255, 255, 0.32);
    color: #ffffff;
  }

  .lang-pill.active {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.42);
    color: #ffffff;
  }
  
  /* =========================================================
     🧩 HEADER + NAV
  ========================================================= */
  .header {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: space-between;
  }
  
  .header-logo {
    font-weight: bold;
    font-size: 18px;
    color: var(--primary);
  }
  
  .logo {
    margin-bottom: 20px;
  }
  
  .nav-item {
    display: block;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 5px;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
  }

  .nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
  }
  
  .nav-item.active {
    background: var(--primary);
  }
  
  /* =========================================================
     📦 MAIN
  ========================================================= */
  .main {
    display: flex;
    flex-direction: column;
  }
  
  /* Header (ثاني تعريف كما هو) */
  .header {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
  }
  
  .menu-toggle {
    display: block;
    font-size: 20px;
    background: none;
    border: none;
    cursor: pointer;
  }
  
  /* Content */
  .content {
    padding: 20px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
  }
  
  .section {
    margin-bottom: 40px;
  }
  
  /* =========================================================
     🧩 COMPONENTS
  ========================================================= */
  
  /* Alerts */
  .alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 10px;
    position: relative;
    font-size: 14px;
  }
  
  .alert-success {
    background: #dcfce7;
    color: #166534;
  }
  
  .alert-warning {
    background: #fef3c7;
    color: #92400e;
  }
  
  .alert-danger {
    background: #fee2e2;
    color: #991b1b;
  }
  
  .alert-close {
    position: absolute;
    left: 10px;
    top: 8px;
    cursor: pointer;
    font-size: 18px;
  }
  
  /* Cards */
  .card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
  }
  
  /* Grid */
  .grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
  
  /* Buttons */
  .btn {
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    margin: 5px;
  }
  
  .btn-primary {
    background: var(--primary);
    color: white;
  }
  
  .btn-secondary {
    background: var(--secondary);
    color: white;
  }
  
  .btn-outline {
    border: 1px solid var(--border);
    background: transparent;
  }
  
  .btn-danger {
    background: var(--danger);
    color: white;
  }
  
  /* Input */
  .input {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 100%;
    max-width: 300px;
  }
  
  /* Table */
  .table-container {
    overflow-x: auto;
  }
  
  .table {
    width: 100%;
    border-collapse: collapse;
    background: white;
  }
  
  .table th,
  .table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    text-align: right;
  }
  
  /* =========================================================
     🧱 MODAL + OVERLAY
  ========================================================= */
  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    z-index: 90;
  }
  
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
  }
  
  .modal-overlay.active {
    display: flex;
  }
  
  .modal {
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
  }
  
  .modal-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
  }
  
  /* =========================================================
     🧱 FOOTER
  ========================================================= */
  .footer {
    background: #111827;
    color: #d1d5db;
  }

  .footer a {
    color: #e5e7eb;
    text-decoration: none;
  }

  .footer a:hover {
    color: #ffffff;
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.75);
    text-underline-offset: 3px;
  }
  
  .footer-container {
    max-width: 1100px;
    margin: auto;
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    padding: 20px;
  }
  
  .footer-col {
    flex: 1;
    min-width: 200px;
  }
  
  .footer-bottom {
    border-top: 1px solid #374151;
    padding: 10px;
    text-align: center;
    font-size: 13px;
    color: #9ca3af;
  }
  
  /* =========================================================
     📱 MOBILE
  ========================================================= */
  @media (max-width: 768px) {
  
    .content {
      padding: 15px;
      margin: 0;
      max-width: 100%;
    }
  
    .layout {
      grid-template-columns: 1fr;
    }
  
    .menu-toggle {
      display: block;
    }
  
    .grid-3 {
      grid-template-columns: 1fr;
    }
  
    .sidebar {
      position: fixed;
      left: 12px;
      right: 12px;
      top: var(--nav-dropdown-top, 56px);
      width: auto;
      max-width: none;
      height: auto;
      max-height: min(72vh, 420px);
      overflow-y: auto;
      scrollbar-gutter: stable;
      margin: 0;
      padding: 16px 18px;
      border-radius: 0 0 12px 12px;
      box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
      z-index: 100;
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transition: none;
    }

    .sidebar.active {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
    }
  
    .overlay.active {
      display: block;
    }
  
    .footer-container {
      flex-direction: column;
    }
  }
  
  /* =========================================================
     🛠 FIXES
  ========================================================= */
  * {
    box-sizing: border-box;
  }
  
  html, body {
    overflow-x: hidden;
  }