/* ==========================================================================
   MebuTV — Black & Gold design system
   ========================================================================== */

:root {
  --bg: #050505;
  --bg-secondary: #0d0d0d;
  --card: #141414;
  --card-border: rgba(212, 175, 55, 0.12);
  --gold: #d4af37;
  --gold-bright: #f4d06f;
  --white: #ffffff;
  --text-primary: #ffffff;
  --text-secondary: #a6a6a6;
  --border: #232323;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* Back-compat alias: earlier pages use var(--accent) inline. */
  --accent: var(--gold);

  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;

  --shadow-card: 0 1px 0 rgba(255,255,255,0.03) inset, 0 12px 32px rgba(0,0,0,0.35);
  --shadow-gold: 0 0 0 1px rgba(212,175,55,0.25), 0 8px 28px rgba(212,175,55,0.15);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(212,175,55,0.06), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(212,175,55,0.04), transparent 55%),
    var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
::selection { background: rgba(212,175,55,0.3); color: #fff; }

.container { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 480px) { .container { padding: 0 18px; } }

/* ---------- Brand & gradient text ---------- */
.brand { font-family: var(--font-display); font-size: 2rem; letter-spacing: 0.01em; font-weight: 600; }
.app-sidebar .brand { font-size: 1.6rem; }
.brand img { max-height: 52px; }
.app-sidebar .brand img { max-height: 40px; }
.brand .gold,
.text-gold {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold) 60%, #a9812c);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--gold-bright); font-weight: 600; margin-bottom: 14px;
}
.eyebrow::before { content: ''; width: 18px; height: 1px; background: var(--gold); display: inline-block; }

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  background: rgba(5,5,5,0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 40;
}
.site-header .row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.site-header nav { display: flex; align-items: center; }
.site-header nav a { margin: 0 16px; color: var(--text-secondary); font-size: 0.92rem; transition: color 0.15s ease; }
.site-header nav a:hover { color: var(--white); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions a { margin-left: 6px; font-size: 0.9rem; }
.site-nav-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; width: 38px; height: 38px; align-items: center; justify-content: center; color: var(--text-primary); cursor: pointer; flex-shrink: 0; }
@media (max-width: 760px) {
  .site-header nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: flex-start; gap: 2px;
    background: var(--bg-secondary); border-bottom: 1px solid var(--border);
    padding: 10px 20px 16px; z-index: 60;
  }
  .site-header nav.is-open { display: flex; }
  .site-header nav a { margin: 0; padding: 10px 4px; width: 100%; }
  .site-header .row { position: relative; flex-wrap: wrap; }
  .site-nav-toggle { display: flex; order: 3; }
  .header-actions { order: 2; flex-wrap: wrap; justify-content: flex-end; }
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 56px 0 32px; margin-top: 72px; color: var(--text-secondary); font-size: 0.85rem; background: var(--bg-secondary); }
.site-footer .cols { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 36px; }
.site-footer h4 { color: var(--white); font-weight: 600; font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 14px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 10px; }
.site-footer li a:hover { color: var(--gold-bright); }
.site-footer .bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); font-size: 0.78rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 26px; border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  border: none; cursor: pointer; text-align: center; transition: all 0.18s ease;
  font-family: var(--font-body);
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #1a1404;
}
.btn-primary:hover { box-shadow: var(--shadow-gold); transform: translateY(-1px); }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--white); }
.btn-secondary:hover { border-color: var(--gold); color: var(--gold-bright); }
.btn-danger { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-sm { padding: 7px 16px; font-size: 0.8rem; }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 8px 4px; }
.btn-ghost:hover { color: var(--white); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 108px 0 80px;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: -20% -10% auto -10%; height: 480px;
  background: radial-gradient(ellipse at center, rgba(212,175,55,0.14), transparent 65%);
  pointer-events: none;
  animation: hero-glow 9s ease-in-out infinite alternate;
}
@keyframes hero-glow { from { opacity: 0.6; transform: scale(1); } to { opacity: 1; transform: scale(1.05); } }
.hero-content { position: relative; z-index: 1; max-width: 680px; }
.hero h1 { font-family: var(--font-display); font-weight: 600; font-size: 3.4rem; line-height: 1.08; margin: 0 0 22px; }
.hero p.lede { color: var(--text-secondary); font-size: 1.15rem; max-width: 520px; margin-bottom: 36px; }
.hero .actions { display: flex; gap: 14px; flex-wrap: wrap; }
@media (max-width: 640px) { .hero h1 { font-size: 2.3rem; } .hero { padding: 72px 0 56px; } }

/* ---------- Sections ---------- */
.section { padding: 72px 0; position: relative; }
.section.alt { background: var(--bg-secondary); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { max-width: 620px; margin: 0 auto 48px; text-align: center; }
.section-head.left { margin: 0 0 44px; text-align: left; }
.section h2 { font-family: var(--font-display); font-weight: 600; font-size: 2.1rem; margin: 0 0 12px; }
.section .subhead { color: var(--text-secondary); font-size: 1rem; }

/* ---------- Grid ---------- */
.grid { display: grid; gap: 28px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4, .grid-2, .grid-5 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-3, .grid-4, .grid-2, .grid-5 { grid-template-columns: 1fr; } }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card-hover:hover { border-color: rgba(212,175,55,0.35); transform: translateY(-2px); }

.feature-card { padding: 30px 26px; }
.feature-card .icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(212,175,55,0.18), rgba(212,175,55,0.04));
  color: var(--gold-bright); margin-bottom: 18px; font-size: 1.2rem;
}
.feature-card h3 { margin: 0 0 8px; font-size: 1.02rem; font-weight: 600; }
.feature-card p { margin: 0; color: var(--text-secondary); font-size: 0.9rem; line-height: 1.6; }

.category-card {
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  background: linear-gradient(160deg, #171717, #0c0c0c);
  border: 1px solid var(--border);
  text-align: left;
  position: relative;
  overflow: hidden;
}
.category-card::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(212,175,55,0.09), transparent 60%);
  opacity: 0; transition: opacity 0.25s ease;
}
.category-card:hover::after { opacity: 1; }
.category-card .cat-icon { font-size: 1.6rem; margin-bottom: 14px; display: block; }
.category-card .cat-name { font-weight: 600; font-size: 0.95rem; }

/* ---------- Plan cards ---------- */
.plan-card { display: flex; flex-direction: column; position: relative; }
.plan-card.popular { border-color: rgba(212,175,55,0.5); box-shadow: var(--shadow-gold); }
.plan-card .popular-badge {
  position: absolute; top: -13px; left: 24px;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #1a1404; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 5px 12px; border-radius: 999px; text-transform: uppercase;
}
.plan-card .plan-name { font-size: 1.05rem; font-weight: 600; }
.plan-card .price { font-family: var(--font-display); font-size: 2rem; margin: 18px 0 2px; font-weight: 600; }
.plan-card .price .unit { font-family: var(--font-body); font-size: 0.8rem; color: var(--text-secondary); font-weight: 400; }
.plan-card ul { list-style: none; padding: 0; margin: 22px 0; flex: 1; }
.plan-card li { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 10px; padding-left: 24px; position: relative; }
.plan-card li:before { content: '✓'; position: absolute; left: 0; color: var(--gold-bright); font-weight: 700; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-active, .badge-successful, .badge-paid { background: rgba(34,197,94,0.12); color: var(--success); }
.badge-expired, .badge-failed { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-pending { background: rgba(245,158,11,0.12); color: var(--warning); }
.badge-suspended, .badge-cancelled, .badge-refunded { background: rgba(166,166,166,0.15); color: var(--text-secondary); }
.badge-new { background: rgba(212,175,55,0.15); color: var(--gold-bright); }
.badge-read { background: rgba(166,166,166,0.15); color: var(--text-secondary); }
.badge-replied { background: rgba(34,197,94,0.12); color: var(--success); }
.badge-closed { background: rgba(166,166,166,0.15); color: var(--text-secondary); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.84rem; color: var(--text-secondary); margin-bottom: 7px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], textarea, select {
  width: 100%; padding: 12px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-secondary); color: var(--text-primary); font-size: 0.9rem; font-family: var(--font-body);
  transition: border-color 0.15s ease;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 64px 24px; }
.auth-card { width: 100%; max-width: 420px; }

.alert { padding: 13px 16px; border-radius: var(--radius-sm); font-size: 0.88rem; margin-bottom: 18px; }
.alert-error { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.25); }
.alert-success { background: rgba(34,197,94,0.1); color: var(--success); border: 1px solid rgba(34,197,94,0.25); }

/* ---------- App shell (dashboard/admin) ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar { width: 244px; border-right: 1px solid var(--border); padding: 26px 20px; flex-shrink: 0; background: var(--bg-secondary); }
.app-sidebar nav a {
  display: flex; align-items: center; padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 3px; transition: all 0.15s ease;
}
.app-sidebar nav a:hover { background: rgba(212,175,55,0.08); color: var(--gold-bright); }
.admin-nav-categories details { margin-bottom: 2px; }
.admin-nav-categories summary {
  cursor: pointer; list-style: none; padding: 9px 12px; border-radius: 8px;
  font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.admin-nav-categories summary::-webkit-details-marker { display: none; }
.admin-nav-categories summary::before { content: '▸'; display: inline-block; margin-right: 6px; transition: transform 0.15s ease; }
.admin-nav-categories details[open] summary::before { transform: rotate(90deg); }
.admin-nav-categories summary:hover { color: var(--gold-bright); background: rgba(212,175,55,0.06); }
.admin-nav-links { padding-left: 10px; }
.admin-nav-direct {
  display: block; cursor: pointer; padding: 9px 12px; margin-bottom: 2px; border-radius: 8px;
  font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em; text-decoration: none;
}
.admin-nav-direct:hover, .admin-nav-direct.is-active { color: var(--gold-bright); background: rgba(212,175,55,0.06); }
.admin-nav-links a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--text-secondary); font-size: 0.88rem; margin-bottom: 1px; }
.admin-nav-links a:hover { background: rgba(212,175,55,0.08); color: var(--gold-bright); }
.app-main { flex: 1; padding: 42px; max-width: 1000px; }

/* Mobile admin: a compact top bar (logo + toggle) replaces the full
   sidebar by default; the sidebar becomes an off-canvas panel that
   slides in only when opened, instead of always rendering above the
   content (which forced scrolling past the entire nav on every page). */
.admin-mobile-bar { display: none; }
@media (max-width: 860px) {
  .app-shell { position: relative; }
  .admin-mobile-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--bg-secondary);
    position: sticky; top: 0; z-index: 40;
  }
  .admin-mobile-bar .brand { font-size: 1.2rem; }
  .admin-mobile-toggle {
    background: transparent; border: 1px solid var(--border); border-radius: 8px;
    color: var(--text-primary); width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer;
  }
  .app-sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
    width: 82%; max-width: 320px; overflow-y: auto;
    transform: translateX(-105%); transition: transform 0.2s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,0.4);
  }
  .app-sidebar.is-open { transform: translateX(0); }
  [dir="rtl"] .app-sidebar { left: auto; right: 0; transform: translateX(105%); }
  [dir="rtl"] .app-sidebar.is-open { transform: translateX(0); }
  .admin-sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 45;
  }
  .admin-sidebar-backdrop.is-open { display: block; }
  .app-main { padding: 24px 18px; }
}

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead { background: var(--bg-secondary); color: var(--text-secondary); text-align: left; }
th, td { padding: 13px 16px; }
tbody tr { border-top: 1px solid rgba(35,35,35,0.8); }
tbody tr:hover { background: rgba(212,175,55,0.03); }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; overflow-x: auto; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: 1fr 1fr; } }
.stat-card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-card); }
.stat-card .label { color: var(--text-secondary); font-size: 0.85rem; }
.stat-card .value { font-family: var(--font-display); font-size: 1.7rem; margin-top: 8px; font-weight: 600; }

/* ---------- Steps ---------- */
.step-num { font-family: var(--font-display); font-size: 2.2rem; font-weight: 600; color: var(--gold-bright); opacity: 0.85; line-height: 1; margin-bottom: 10px; }

/* ---------- CTA band ---------- */
.cta-band {
  border-radius: 28px;
  padding: 64px 48px;
  text-align: center;
  background: linear-gradient(150deg, #171310, #0c0c0c 60%);
  border: 1px solid rgba(212,175,55,0.18);
  box-shadow: var(--shadow-gold);
}
.cta-band h2 { margin-bottom: 10px; }
@media (max-width: 600px) { .cta-band { padding: 44px 24px; } }

/* ---------- Utilities ---------- */
.text-muted { color: var(--text-secondary); }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; } .mt-5 { margin-top: 48px; }
.mb-0 { margin-bottom: 0; }

/* ---------- RTL (Arabic) ----------
   Targeted overrides rather than a full mirror: flip text alignment,
   nav/sidebar direction, list markers, and directional arrows. Verified
   on header/footer/homepage/auth — other pages inherit these rules but
   have not each been individually checked; treat as a starting point,
   not a guarantee, for anything outside that set. */
[dir="rtl"] { text-align: right; }
[dir="rtl"] .site-header .row,
[dir="rtl"] .header-actions,
[dir="rtl"] .footer-actions { flex-direction: row-reverse; }
[dir="rtl"] .site-header nav a { margin: 0 0 0 16px; }
[dir="rtl"] .eyebrow::before { margin-left: 8px; margin-right: 0; }
[dir="rtl"] .plan-card li,
[dir="rtl"] .feature-card { text-align: right; }
[dir="rtl"] .plan-card li { padding-left: 0; padding-right: 24px; }
[dir="rtl"] .plan-card li:before { left: auto; right: 0; }
[dir="rtl"] .plan-card .popular-badge { left: auto; right: 24px; }
[dir="rtl"] .app-sidebar { border-right: none; border-left: 1px solid var(--border); }
[dir="rtl"] .app-shell { direction: rtl; }
[dir="rtl"] .btn-ghost svg,
[dir="rtl"] .arrow { transform: scaleX(-1); display: inline-block; }
[dir="rtl"] .form-row,
[dir="rtl"] .hero-content { text-align: right; }
