@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ============================================
   YAFNAH BLOG ADMIN — Shared Stylesheet

   Palette is the locked brand kit, dark build:
   Bakhoor ground, Rimal type, Ghaf as the emphasis
   PLANE (never coloured text on brown — Ghaf reads
   1.85 against Bakhoor and disappears). Dhahab is
   hairline/large-label only, 3.88 against Bakhoor.
   Status colours are conventional and functional
   ONLY — never decorative, so brand stays brand.
   ============================================ */

:root {
  /* Surfaces — Bakhoor stepped down for a dark build */
  --ground:        #241806;
  --surface:       #38250E;
  --raised:        #47301A;
  --sunken:        #1B1104;

  /* Type — brand neutral scale, which runs toward white */
  --text:          #FFE4C4;  /* Rimal        11.93 on surface */
  --text-2:        #CDC8C3;  /* kit 25%                       */
  --muted:         #AFA89F;  /* kit 40%                       */
  --line:          #60513E;  /* kit 80%                       */
  --line-soft:     rgba(96, 81, 62, 0.45);

  /* Brand */
  --plane:         #006039;  /* Ghaf   — Rimal on Ghaf 6.28   */
  --plane-deep:    #00502F;
  --fill:          #7A8971;  /* Sidr   — fill only, never text */
  --dhahab:        #A37E2C;  /* Dhahab — hairline / large only */
  --dhahab-glow:   rgba(163, 126, 44, 0.14);

  /* Status — conventional, functional only */
  --ok:            #4ADE80;
  --warn:          #FBBF24;
  --bad:           #F87171;
  --bad-fill:      #DC2626;

  --radius:        4px;
  --radius-card:   6px;
  --sans: 'IBM Plex Sans Arabic', 'IBM Plex Sans',
          'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body.admin-body {
  font-family: var(--sans);
  background: var(--ground);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Arabic needs its own leading — brand rule, never shares Latin's */
[lang="ar"], [dir="rtl"] { line-height: 1.9; }

/* Western numerals in both scripts — brand rule */
.stat-value, .char-count, td, input, textarea { font-variant-numeric: lining-nums tabular-nums; }

/* ── SHELL ── */
.admin-sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
  padding: 24px 16px;
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 8px 8px;
}
.sidebar-brand span { font-weight: 600; font-size: 15px; letter-spacing: 0.2px; }
.sidebar-logout {
  display: block; padding: 0 8px 24px 50px;
  font-weight: 600; font-size: 11px; color: var(--muted); text-decoration: none;
  text-transform: uppercase; letter-spacing: 0.12em;
  transition: color 0.15s ease;
}
.sidebar-logout:hover { color: var(--text); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav a:hover { background: var(--raised); color: var(--text); }

/* The signature: Ghaf plane carries the active state, Dhahab hairline marks it */
.sidebar-nav a.active { background: var(--plane); color: var(--text); font-weight: 600; }
.sidebar-nav a.active::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 2px; background: var(--dhahab);
}

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 32px;
  border-bottom: 1px solid var(--dhahab);
}
.admin-header h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.2px; }
.admin-content { padding: 32px; overflow-y: auto; }

/* ── BUTTONS ──
   Class name is historical: the plane is Ghaf now, with a
   Dhahab hairline. Renamed styling, not renamed markup. */
.btn-gold, .btn-gold-sm {
  display: inline-block;
  background: var(--plane); color: var(--text);
  border: 1px solid var(--dhahab);
  border-radius: var(--radius); font-weight: 600; text-decoration: none;
  cursor: pointer; transition: background 0.15s ease; text-align: center;
  font-family: inherit;
}
.btn-gold { padding: 13px; width: 100%; font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; }
.btn-gold-sm { padding: 9px 18px; font-size: 13px; }
.btn-gold:hover, .btn-gold-sm:hover { background: var(--plane-deep); }

.btn-secondary-sm {
  display: inline-block; padding: 9px 18px; border-radius: var(--radius);
  background: transparent; color: var(--text-2); text-decoration: none;
  font-size: 13px; border: 1px solid var(--line); cursor: pointer;
  font-family: inherit; transition: border-color 0.15s ease, color 0.15s ease;
}
.btn-secondary-sm:hover { border-color: var(--dhahab); color: var(--text); }

/* ── STATS ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius-card); padding: 20px;
  border-top: 2px solid var(--dhahab);
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 8px; }
/* Metrics stay in the text face — IBM Plex Mono's slashed zero is a default
   glyph, and across a figure like 1,500 the slashes read as a strikethrough.
   Tabular figures above still keep the columns aligned. */
.stat-value { font-size: 30px; font-weight: 600; color: var(--text); letter-spacing: -0.5px; }
.stat-change { font-size: 12px; color: var(--ok); margin-top: 4px; }

.analytics-section {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius-card); padding: 24px; margin-bottom: 20px;
}
.analytics-section h2 { font-size: 15px; margin-bottom: 16px; font-weight: 600; }
.section-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

/* ── FILTERS ── */
.filter-tabs { display: flex; gap: 6px; }
.filter-tab {
  background: transparent; border: 1px solid var(--line); color: var(--text-2);
  padding: 6px 14px; border-radius: var(--radius); font-size: 12px; cursor: pointer;
  font-family: inherit; transition: all 0.15s ease;
}
.filter-tab:hover { border-color: var(--dhahab); }
.filter-tab.active { background: var(--plane); color: var(--text); border-color: var(--dhahab); font-weight: 600; }

/* ── TABLES ── */
.posts-table { width: 100%; border-collapse: collapse; }
.posts-table th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.posts-table td { padding: 11px 8px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.posts-table tbody tr { transition: background 0.12s ease; }
.posts-table tbody tr:hover { background: var(--raised); }
.loading-cell { text-align: center; padding: 40px; color: var(--muted); }

/* ── BADGES ── */
.cat-badge { padding: 3px 10px; border-radius: 9999px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.cat-badge.cat-areas { background: rgba(122, 137, 113, 0.22); color: #C7D0BF; }
.cat-badge.cat-faq { background: var(--dhahab-glow); color: #D9B871; }
.cat-badge.cat-guides { background: rgba(0, 96, 57, 0.35); color: var(--ok); }

/* ── ACTIONS ── */
.action-link {
  color: var(--text-2); text-decoration: none; font-size: 13px; font-weight: 500;
  margin-right: 12px; background: none; border: none; cursor: pointer; font-family: inherit;
  border-bottom: 1px solid transparent; transition: color 0.15s ease, border-color 0.15s ease;
}
.action-link:hover { color: var(--text); border-bottom-color: var(--dhahab); }
.action-danger { color: var(--bad); }
.action-danger:hover { color: var(--bad); border-bottom-color: var(--bad); }

.spinner {
  width: 24px; height: 24px; border: 2px solid var(--line);
  border-top-color: var(--dhahab);
  border-radius: 50%; margin: 0 auto; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  * { transition-duration: 0.01ms !important; }
}

/* ── EDITOR FORM ── */
.editor-form { max-width: 720px; }
.form-section { margin-bottom: 20px; }
.form-section label {
  display: block; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 8px;
}
.field-hint { text-transform: none; font-weight: 400; color: var(--muted); opacity: 0.75; letter-spacing: 0; margin-left: 6px; font-size: 12px; }
.form-section input, .form-section textarea, .form-section select {
  width: 100%; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 11px 14px; color: var(--text); font-size: 14px; font-family: var(--sans);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-section input::placeholder, .form-section textarea::placeholder { color: var(--muted); opacity: 0.6; }
.form-section input:focus, .form-section textarea:focus, .form-section select:focus {
  outline: none; border-color: var(--dhahab); box-shadow: 0 0 0 3px var(--dhahab-glow);
}
.char-count { display: block; text-align: right; font-size: 11px; color: var(--muted); margin-top: 4px; font-family: var(--mono); }
.geo-row { display: flex; gap: 12px; }
/* Top rule, not a left bar — matches .stat-card so callouts and cards share
   one language, and a side accent tab is the tell of a templated UI. */
.seo-section {
  background: var(--sunken); border: 1px solid var(--line-soft);
  border-top: 2px solid var(--dhahab);
  border-radius: var(--radius); padding: 16px;
}

.faq-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.faq-row input, .faq-row textarea { flex: 1; }
.btn-remove { background: none; border: none; color: var(--bad); cursor: pointer; font-size: 16px; padding: 8px; }

.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 24px; }
.form-actions .btn-gold { width: auto; padding: 13px 32px; }

/* ── MEDIA ── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.media-card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius-card); overflow: hidden;
  transition: border-color 0.15s ease;
}
.media-card:hover { border-color: var(--dhahab); }
.media-card img { width: 100%; height: 120px; object-fit: cover; display: block; }
.copy-url-btn {
  width: 100%; padding: 8px; background: transparent; border: none; color: var(--text-2);
  font-size: 12px; cursor: pointer; border-top: 1px solid var(--line-soft);
  font-family: inherit; transition: background 0.15s ease, color 0.15s ease;
}
.copy-url-btn:hover { background: var(--plane); color: var(--text); }

/* ── SETUP ── */
.setup-steps { padding-left: 20px; line-height: 1.8; margin-bottom: 16px; }
.setup-steps li { margin-bottom: 8px; }
.setup-steps code {
  background: var(--sunken); padding: 2px 6px; border-radius: var(--radius);
  font-size: 13px; font-family: var(--mono); color: var(--text-2);
}

/* ── COMING SOON ── */
.coming-soon {
  border: 1px solid var(--line-soft); border-top: 2px solid var(--dhahab);
  border-radius: var(--radius-card); background: var(--surface);
  padding: 48px 24px; text-align: center; color: var(--muted);
}
.coming-soon-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-2); margin-bottom: 8px;
}

/* Header matches the control board: brand left, actions right, Dhahab hairline. */
.admin-header::before {
  content: "Yafnah & Co";
  position: absolute; left: 32px; top: 50%; transform: translateY(-50%);
  font-size: 13px; font-weight: 600; color: var(--muted);
  letter-spacing: 0.06em; pointer-events: none;
}
.admin-header { position: relative; padding-left: 32px; }
.admin-header h1 { margin-left: 132px; }
.header-actions { display: flex; align-items: center; gap: 10px; }

.nav-toggle { display: none; background: none; border: 1px solid var(--line);
  color: var(--text); font-size: 18px; line-height: 1; padding: 6px 11px;
  border-radius: var(--radius); cursor: pointer; margin-right: 12px; }
@media (max-width: 768px) {
  .nav-toggle { display: inline-block; }
  .admin-sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 1500;
    transform: translateX(-100%); transition: transform 0.2s ease;
    border-right: 1px solid var(--dhahab); }
  body.nav-open .admin-sidebar { transform: translateX(0); }
  body.nav-open::after { content: ""; position: fixed; inset: 0;
    background: rgba(11,7,2,0.6); z-index: 1400; }
  .admin-header::before { display: none; }
  .admin-header h1 { margin-left: 0; font-size: 18px; }
  .admin-content { padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .posts-table thead { display: none; }
  .posts-table tr { display: block; border-bottom: 1px solid var(--line-soft); padding: 10px 0; }
  .posts-table td { display: block; border: none; padding: 3px 8px; }
  .section-header-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .filter-tabs { flex-wrap: wrap; }
  .editor-form { max-width: 100%; }
  .geo-row { flex-direction: column; }
  .media-grid { grid-template-columns: 1fr 1fr; }
}
