/* ===============================
   STYLES.CSS – v3.5
   Majid Engine Pro Dashboard
   Refactored: Tailwind → CSS custom classes
   =============================== */

:root {
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --bg-light: #f8fafc;
  --bg-dark: #111827;
  --card-light: #ffffff;
  --card-dark: #1f2937;
  --border-light: #e2e8f0;
  --border-dark: #374151;
  --text-light: #1e293b;
  --text-dark: #d1d5db;
  --text-muted-light: #64748b;
  --text-muted-dark: #9ca3af;
}

body {
  transition: background-color 0.3s ease, color 0.3s ease;
  font-family: 'Vazirmatn', sans-serif;
  background-color: var(--bg-light);
  color: var(--text-light);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.dark body { background-color: var(--bg-dark); color: var(--text-dark); }

.tab-page { display: none; }
.tab-page.active { display: block; animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.container-main { padding: 1rem; max-width: 80rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1.5rem; padding-bottom: 6rem; }
@media (min-width: 768px) { .container-main { padding: 1.5rem; } }

.badge { padding: 0.25rem 0.6rem; border-radius: 0.375rem; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.3px; display: inline-block; }
.badge-live { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.dark .badge-live { background: rgba(5,150,105,0.2); color: #34d399; border-color: #065f46; }
.badge-mock { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }
.dark .badge-mock { background: rgba(217,119,6,0.2); color: #fbbf24; border-color: #92400e; }
.badge-neutral { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.dark .badge-neutral { background: rgba(37,99,235,0.2); color: #93c5fd; border-color: #1e40af; }
.badge-risk { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.dark .badge-risk { background: rgba(220,38,38,0.2); color: #f87171; border-color: #991b1b; }

.card { background: var(--card-light); border: 1px solid var(--border-light); border-radius: 1rem; padding: 1rem; box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
@media (min-width: 768px) { .card { padding: 1.5rem; } }
.dark .card { background: var(--card-dark); border-color: var(--border-dark); }
.glass-card { background: rgba(255,255,255,0.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.3); }
.dark .glass-card { background: rgba(31,41,55,0.7); border: 1px solid rgba(255,255,255,0.05); }
.card-mb { margin-bottom: 1.5rem; }

.card-title { font-size: 1rem; font-weight: 700; color: var(--text-light); margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.dark .card-title { color: #ffffff; }
.card-title-dot::before { content: ''; display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: #10b981; }
.label-text { font-size: 0.75rem; font-weight: 600; color: var(--text-muted-light); margin-bottom: 0.375rem; display: block; }
.dark .label-text { color: var(--text-muted-dark); }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.625rem 1rem; border-radius: 0.75rem; font-size: 0.875rem; font-weight: 500; transition: background-color 0.2s, color 0.2s; cursor: pointer; border: none; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.btn-primary { background: #2563eb; color: #fff; } .btn-primary:hover { background: #1d4ed8; }
.btn-success { background: #059669; color: #fff; } .btn-success:hover { background: #047857; }
.btn-danger { background: #dc2626; color: #fff; } .btn-danger:hover { background: #b91c1c; }
.btn-purple { background: #9333ea; color: #fff; } .btn-purple:hover { background: #7e22ce; }
.btn-amber { background: #d97706; color: #fff; } .btn-amber:hover { background: #b45309; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.dark .btn-secondary { background: #374151; color: #d1d5db; }
.btn-secondary:hover { opacity: 0.9; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 700; }
.btn-full { width: 100%; }

.input-field { width: 100%; padding: 0.625rem 1rem; border-radius: 0.75rem; background: #f8fafc; border: 1px solid var(--border-light); color: var(--text-light); font-size: 0.875rem; outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.dark .input-field { background: #111827; border-color: var(--border-dark); color: var(--text-dark); }
.input-field:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.input-readonly { background: #f1f5f9; font-weight: 700; }
.dark .input-readonly { background: #1f2937; }
.select-field { width: 100%; padding: 0.625rem 1rem; border-radius: 0.75rem; background: #f8fafc; border: 1px solid var(--border-light); color: var(--text-light); font-size: 0.875rem; outline: none; }
.dark .select-field { background: #111827; border-color: var(--border-dark); color: var(--text-dark); }

.stat-box { padding: 0.75rem; border-radius: 0.75rem; background: #f8fafc; border: 1px solid #f1f5f9; }
.dark .stat-box { background: #111827; border-color: var(--border-dark); }
.stat-label { font-size: 0.7rem; color: var(--text-muted-light); margin-bottom: 0.25rem; display: block; }
.dark .stat-label { color: var(--text-muted-dark); }
.stat-value { font-size: 1.125rem; font-weight: 700; color: var(--text-light); font-family: 'Vazirmatn', monospace; display: block; }
.dark .stat-value { color: #ffffff; }

.table-base { width: 100%; font-size: 0.875rem; }
.table-base thead tr { color: var(--text-muted-light); border-bottom: 1px solid var(--border-light); }
.dark .table-base thead tr { color: var(--text-muted-dark); border-color: var(--border-dark); }
.table-base th { padding: 0.75rem 0.5rem; text-align: right; font-weight: 500; }
.table-base tbody tr { border-bottom: 1px solid #f1f5f9; }
.dark .table-base tbody tr { border-color: var(--border-dark); }
.table-base td { padding: 0.75rem 0.5rem; }
.table-wrap { overflow-x: auto; margin-bottom: 1rem; }

.tabBtn { position: relative; padding: 0.5rem 0.85rem; transition: all 0.2s ease; white-space: nowrap; border-radius: 0.5rem; font-size: 0.9rem; color: #64748b; background: transparent; border: none; cursor: pointer; }
.dark .tabBtn { color: #9ca3af; }
.tabBtn:hover { background: #f1f5f9; }
.dark .tabBtn:hover { background: #374151; }
.tabBtn.active-tab { background: var(--brand-50); color: var(--brand-600); font-weight: 600; }
.dark .tabBtn.active-tab { background: rgba(59,130,246,0.15); color: #60a5fa; }

.accordion-header { cursor: pointer; transition: background 0.2s; user-select: none; }
.accordion-header:hover { background: rgba(0,0,0,0.03); }
.dark .accordion-header:hover { background: rgba(255,255,255,0.05); }
.accordion-content { max-height: 0; overflow: hidden; transition: max-height 0.4s cubic-bezier(0.4,0,0.2,1); }
.accordion-content.open { max-height: 4000px; transition: max-height 0.6s ease-in; }

input, select { outline: none; transition: all 0.2s ease; font-family: 'Vazirmatn', sans-serif; }
input:focus, select:focus { border-color: var(--brand-500) !important; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

/* Mobile Menu */
#mobileMenu { transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); transform: translateX(100%); }
#mobileMenu.open { transform: translateX(0); }
#mobileMenuOverlay { transition: opacity 0.3s ease-in-out; }

/* Alerts Drawer */
#alertsDrawer { transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); transform: translateX(-100%); }
#alertsDrawer.open { transform: translateX(0); }
#alertsDrawerOverlay { transition: opacity 0.3s ease-in-out; }
.alerts-badge { position: absolute; top: -0.25rem; right: -0.25rem; min-width: 18px; height: 18px; padding: 0 0.25rem; display: flex; align-items: center; justify-content: center; background: #dc2626; color: #fff; font-size: 0.625rem; font-weight: 700; border-radius: 9999px; border: 2px solid #fff; }
.dark .alerts-badge { border-color: #1f2937; }
.alert-item { padding: 0.75rem; border-radius: 0.75rem; border: 1px solid var(--border-light); margin-bottom: 0.5rem; cursor: pointer; transition: opacity 0.2s; }
.dark .alert-item { border-color: var(--border-dark); }
.alert-item.read { opacity: 0.6; }
.alert-info { border-color: #93c5fd; background: #eff6ff; }
.dark .alert-info { border-color: #1e40af; background: rgba(37,99,235,0.2); }
.alert-warning { border-color: #fde68a; background: #fffbeb; }
.dark .alert-warning { border-color: #92400e; background: rgba(217,119,6,0.2); }
.alert-critical { border-color: #fecaca; background: #fef2f2; }
.dark .alert-critical { border-color: #991b1b; background: rgba(220,38,38,0.2); }
.alert-success { border-color: #a7f3d0; background: #ecfdf5; }
.dark .alert-success { border-color: #065f46; background: rgba(5,150,105,0.2); }

.scenarioBtn { padding: 0.5rem 1rem; border-radius: 0.75rem; font-size: 0.875rem; font-weight: 500; color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.05); border: none; cursor: pointer; }
.scenario-shock { background: #dc2626; }
.scenario-crash { background: #b91c1c; }
.scenario-rally { background: #059669; }
.scenario-inflation { background: #d97706; }
.scenario-deflation { background: #2563eb; }
.scenario-custom { background: #9333ea; }

.link-source { font-size: 0.75rem; color: #2563eb; text-decoration: none; }
.dark .link-source { color: #60a5fa; }
.link-source:hover { text-decoration: underline; }

/* Grid Helpers (Fallback if Tailwind not loaded) */
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 768px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
@media (min-width: 768px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.dark ::-webkit-scrollbar-thumb { background: #4b5563; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.dark ::-webkit-scrollbar-thumb:hover { background: #6b7280; }