/* ============================================================
   theme.css — ثيم فاتح وغامق موحّد
   ============================================================ */

/* ── Dark Mode (default) ── */
:root {
  --gold: #C9A84C;
  --gold-light: #E8C97A;
  --gold-dim: #7A5F28;
  --gold-subtle: rgba(201,168,76,0.08);

  --bg:       #0A0A0A;
  --bg2:      #111111;
  --bg3:      #191919;
  --bg4:      #222222;

  --border:   rgba(201,168,76,0.15);
  --border2:  rgba(201,168,76,0.30);
  --border3:  rgba(201,168,76,0.50);

  --text:     #F0EAD6;
  --text2:    #8A7D5E;
  --text3:    #4A4235;

  --up:       #2ECC71;
  --up-bg:    rgba(46,204,113,0.08);
  --up-text:  #6EDAA0;
  --dn:       #E24B4A;
  --dn-bg:    rgba(226,75,74,0.08);
  --dn-text:  #E07070;

  --nav-bg:   rgba(10,10,10,0.94);
  --grid-color: rgba(201,168,76,0.03);

  --shadow:   0 4px 24px rgba(0,0,0,0.4);
  --radius:   10px;
  --radius-lg:14px;

  --mono: 'JetBrains Mono', monospace;
  --sans: 'IBM Plex Sans Arabic', sans-serif;
}

/* ── Light Mode ── */
[data-theme="light"] {
  --gold: #A0762A;
  --gold-light: #7A5520;
  --gold-dim: #C9A84C;
  --gold-subtle: rgba(160,118,42,0.08);

  --bg:       #F5F0E8;
  --bg2:      #FFFFFF;
  --bg3:      #F0EBE0;
  --bg4:      #E8E0D0;

  --border:   rgba(160,118,42,0.18);
  --border2:  rgba(160,118,42,0.35);
  --border3:  rgba(160,118,42,0.55);

  --text:     #1A1208;
  --text2:    #6B5A3E;
  --text3:    #A08060;

  --up:       #1A7A45;
  --up-bg:    rgba(26,122,69,0.08);
  --up-text:  #1A7A45;
  --dn:       #C02020;
  --dn-bg:    rgba(192,32,32,0.08);
  --dn-text:  #C02020;

  --nav-bg:   rgba(245,240,232,0.96);
  --grid-color: rgba(160,118,42,0.04);

  --shadow:   0 4px 24px rgba(0,0,0,0.08);
}

/* ── Base Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
  transition: background 0.25s, color 0.25s;
}

body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none; z-index: 0;
}

/* ── Nav ── */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  z-index: 100; gap: 12px; flex-wrap: wrap;
}
.nav-brand { display: flex; align-items: center; gap: 8px; }
.nav-brand .mark {
  width: 26px; height: 26px; background: var(--gold);
  clip-path: polygon(50% 0%,100% 25%,100% 75%,50% 100%,0% 75%,0% 25%);
  flex-shrink: 0;
}
.nav-brand span { font-size: 13px; font-weight: 600; color: var(--gold); }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  padding: 5px 12px; border-radius: 6px; font-size: 12px;
  color: var(--text2); text-decoration: none;
  transition: all .15s; border: 1px solid transparent;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--gold); border-color: var(--border); background: var(--gold-subtle); }
.nav-right { display: flex; align-items: center; gap: 8px; }

/* ── Theme Toggle Button ── */
.theme-btn {
  width: 34px; height: 34px;
  border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text2);
  cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.theme-btn:hover { border-color: var(--border2); color: var(--text); background: var(--gold-subtle); }

/* ── Buttons ── */
.btn {
  padding: 8px 18px; border-radius: 8px; font-size: 13px; font-weight: 500;
  font-family: var(--sans); cursor: pointer; border: 1px solid;
  transition: all .15s; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; font-weight: 600; }
.btn-gold:hover { opacity: .88; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text2); }
.btn-ghost:hover { border-color: var(--border2); color: var(--text); }
.btn-danger { background: transparent; border-color: var(--dn-bg); color: var(--dn-text); }
.btn-danger:hover { background: var(--dn-bg); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Cards ── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: background .25s, border-color .25s;
}

/* ── Form Elements ── */
input, select, textarea {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-family: var(--sans); font-size: 14px;
  padding: 9px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.1);
}
[data-theme="light"] input:focus,
[data-theme="light"] select:focus {
  box-shadow: 0 0 0 3px rgba(160,118,42,0.12);
}

/* ── Toggle Switch ── */
.toggle {
  position: relative; width: 44px; height: 24px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; transition: all .2s; flex-shrink: 0;
}
.toggle.on { background: var(--gold-dim); border-color: var(--gold); }
.toggle::after {
  content: ''; position: absolute;
  width: 18px; height: 18px; background: var(--text2);
  border-radius: 50%; top: 2px; right: 2px; transition: all .2s;
}
.toggle.on::after { background: var(--gold-light); right: auto; left: 2px; }

/* ── Live Badge ── */
.live-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text3);
  padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 20px; white-space: nowrap;
}
.live-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text3); flex-shrink: 0; }
.live-badge.live .dot { background: var(--up); animation: pulse 1.5s infinite; }
.live-badge.live { color: var(--up); border-color: var(--up-bg); }
.live-badge.err  { color: var(--dn); border-color: var(--dn-bg); }

/* ── Spinner ── */
.spinner {
  width: 15px; height: 15px;
  border: 2px solid var(--border); border-top-color: var(--gold);
  border-radius: 50%; animation: spin .7s linear infinite;
  display: inline-block; vertical-align: middle;
}

/* ── Toast ── */
.toast {
  position: fixed; top: 76px; left: 50%;
  transform: translateX(-50%) translateY(-14px);
  background: var(--bg2); border: 1px solid var(--border2);
  color: var(--text); padding: 9px 20px; border-radius: 8px;
  font-size: 12px; opacity: 0; pointer-events: none;
  transition: all .25s; z-index: 500; white-space: nowrap;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--up-bg); color: var(--up-text); }
.toast.error   { border-color: var(--dn-bg); color: var(--dn-text); }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 10px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text3); padding: 9px 1.25rem;
  border-bottom: 1px solid var(--border); text-align: right; font-weight: 400;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gold-subtle); }
tbody td { padding: 11px 1.25rem; vertical-align: middle; }

/* ── Section Title ── */
.section-title {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text3); margin-bottom: 1rem;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Page Header ── */
.page { position: relative; z-index: 1; max-width: 920px; margin: 0 auto; padding: 2rem 1.5rem 5rem; }
.page-header {
  padding: 1.75rem 0 1.25rem; border-bottom: 1px solid var(--border);
  margin-bottom: 1.75rem; display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 12px;
}
.eyebrow { font-size: 10px; letter-spacing: .15em; color: var(--gold); text-transform: uppercase; margin-bottom: 5px; }
.page-header h1 { font-size: 22px; font-weight: 300; color: var(--text); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem;
}
[data-theme="light"] .modal-overlay { background: rgba(0,0,0,0.35); }
.modal {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); width: 100%; max-width: 520px;
  max-height: 92vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-header {
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-header h2 { font-size: 15px; font-weight: 500; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 20px; cursor: pointer; border-radius: 4px; padding: 2px 6px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

/* ── Field ── */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 5px; font-weight: 500; }
.hint { font-size: 11px; color: var(--text3); margin-bottom: 6px; line-height: 1.5; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-wrap { position: relative; }
.input-wrap input { padding-left: 44px; }
.input-suffix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--text2); pointer-events: none; }

/* ── Status Badge ── */
.status-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 3px 10px; border-radius: 20px; }
.status-badge.ok  { background: var(--up-bg);  color: var(--up-text);  border: 1px solid var(--up-bg); }
.status-badge.err { background: var(--dn-bg);  color: var(--dn-text);  border: 1px solid var(--dn-bg); }
.status-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ── Save Bar ── */
.save-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--nav-bg); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: .875rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  z-index: 200; transform: translateY(100%);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.save-bar.visible { transform: translateY(0); }
.save-bar .unsaved { font-size: 13px; color: var(--text2); }
.save-bar .unsaved span { color: var(--gold); }

/* ── Ticker ── */
.ticker {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 0 1.5rem; height: 34px;
  display: flex; align-items: center; gap: 1.5rem;
  overflow-x: auto; scrollbar-width: none;
  position: relative; z-index: 1;
}
.ticker::-webkit-scrollbar { display: none; }
.tick-item { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tick-lbl { font-size: 10px; color: var(--text3); letter-spacing: .06em; text-transform: uppercase; }
.tick-val { font-size: 12px; font-family: var(--mono); font-weight: 500; color: var(--text); }
.tick-chg { font-size: 10px; font-family: var(--mono); }
.up { color: var(--up); } .dn { color: var(--dn); }

/* ── Countdown Bar ── */
.cd-bar { width: 100px; height: 2px; background: var(--border); border-radius: 1px; overflow: hidden; }
.cd-fill { height: 100%; background: var(--gold); transition: width 1s linear; }

/* ── Footer ── */
footer {
  position: relative; z-index: 1;
  padding: .75rem 1.5rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--text3); flex-wrap: wrap; gap: 6px;
}

/* ── Animations ── */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }
@keyframes spin   { to { transform: rotate(360deg); } }
@keyframes rowFlash { 0%{background:rgba(201,168,76,0.12)} 100%{background:transparent} }
[data-theme="light"] @keyframes rowFlash { 0%{background:rgba(160,118,42,0.10)} 100%{background:transparent} }
.flash { animation: rowFlash .6s ease forwards; }

/* ── User Chip ── */
.user-chip { font-size: 12px; color: var(--text2); padding: 4px 10px; border: 1px solid var(--border); border-radius: 20px; }
.btn-logout { font-size: 12px; color: var(--dn-text); background: none; border: 1px solid var(--dn-bg); border-radius: 6px; padding: 5px 12px; cursor: pointer; font-family: var(--sans); transition: background .15s; }
.btn-logout:hover { background: var(--dn-bg); }

/* ── Tabs ── */
.tabs-bar {
  position: relative; z-index: 1;
  padding: .75rem 1.5rem 0;
  display: flex; align-items: flex-end; gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
  background: var(--bg);
}
.tabs-bar::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 18px; border-radius: 10px 10px 0 0;
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; border-bottom: none;
  color: var(--text2); background: transparent;
  font-family: var(--sans); transition: all .15s;
  white-space: nowrap; position: relative; bottom: -1px;
}
.tab:hover { color: var(--text); background: var(--gold-subtle); }
.tab.active { color: var(--gold); background: var(--bg2); border-color: var(--border); border-bottom-color: var(--bg2); }
.tab .flag { font-size: 16px; line-height: 1; }

/* ── Metric Card ── */
.mc { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; position: relative; overflow: hidden; transition: background .25s, border-color .15s; }
.mc:hover { border-color: var(--border2); }
.mc::after { content: ''; position: absolute; top:0; right:0; width:50px; height:50px; background: radial-gradient(circle at top right, var(--gold-subtle), transparent 70%); pointer-events:none; }
.mc-lbl { font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--text3); margin-bottom: 6px; }
.mc-val { font-family: var(--mono); font-size: 22px; font-weight: 600; line-height: 1; color: var(--text); }
.mc-val.gold { color: var(--gold); }
.mc-sub { font-size: 11px; color: var(--text2); margin-top: 4px; font-family: var(--mono); }
.chg-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-family: var(--mono); padding: 2px 7px; border-radius: 4px; margin-top: 4px; font-weight: 500; }
.badge-up { background: var(--up-bg); color: var(--up); }
.badge-dn { background: var(--dn-bg); color: var(--dn); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
