/* ============================================================
   Safa Othman — ADMIN DASHBOARD
   Reuses the site's tokens (styles.css) + dashboard chrome.
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--ink-900);
  color: var(--fg-1);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }

/* ============================================================
   LOGIN GATE
   ============================================================ */
.admin { display: none; }
body:not(.authed) .admin { display: none !important; }
.authed .admin { display: grid; }
body.authed .login-gate { display: none; }

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(198,242,78,0.06), transparent 55%),
    var(--ink-900);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 40px 34px;
  box-shadow: 0 40px 100px -30px rgba(0,0,0,0.9);
}
.login-mark {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink, #0b0d08);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800; font-size: 24px;
  margin-bottom: 22px;
}
.login-title {
  font-family: var(--font-display);
  font-weight: 700; font-size: 27px;
  letter-spacing: -0.02em;
}
.login-sub { color: var(--fg-3); font-size: 14.5px; margin-top: 8px; margin-bottom: 26px; }
.login-field { margin-bottom: 16px; }
.login-field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.login-field input {
  width: 100%;
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 13px 15px;
  color: var(--fg-1);
  font-family: var(--font-body);
  font-size: 15px;
  transition: border-color 0.25s;
}
.login-field input:focus { outline: none; border-color: var(--accent); }
.login-err {
  display: none;
  color: #ff6f6f;
  font-size: 13px;
  margin: 4px 0 14px;
}
.login-err.show { display: block; }
.login-submit { width: 100%; justify-content: center; margin-top: 8px; }
.login-preview-note {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--fg-3);
  line-height: 1.55;
}
.login-preview-note b { color: var(--fg-1); }
.login-preview-note > i { color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.login-preview-note svg { width: 18px; height: 18px; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }

.admin {
  display: grid;
  grid-template-columns: 244px 1fr 1fr;
  height: 100vh;
}

/* ---------- SIDEBAR ---------- */
.side {
  background: var(--ink-850);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  overflow-y: auto;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 22px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
}
.side-brand .mk {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: 16px;
}
.side-brand small { display: block; font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-3); font-weight: 400; letter-spacing: 0.04em; margin-top: 1px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: 10px;
  color: var(--fg-2); font-size: 14.5px;
  transition: background 0.2s, color 0.2s;
  text-align: start;
}
.side-link svg { width: 18px; height: 18px; opacity: 0.85; }
.side-link:hover { background: var(--ink-700); color: var(--fg-1); }
.side-link.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.side-link.active svg { opacity: 1; }
.side-foot { margin-top: auto; padding-top: 18px; display: flex; flex-direction: column; gap: 8px; }

.abtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--font-mono); font-size: 13px; font-weight: 500;
  padding: 11px 14px; border-radius: 10px;
  transition: transform 0.2s, background 0.2s, border-color 0.2s, color 0.2s;
}
.abtn svg { width: 16px; height: 16px; }
.abtn-primary { background: var(--accent); color: var(--accent-ink); }
.abtn-primary:hover { background: var(--accent-press); }
.abtn-ghost { border: 1px solid var(--line); color: var(--fg-1); }
.abtn-ghost:hover { border-color: var(--fg-3); }
.abtn-danger { border: 1px solid var(--line); color: #ff8a8a; }
.abtn-danger:hover { border-color: #ff8a8a; background: rgba(255,80,80,0.08); }

/* ---------- MAIN ---------- */
.main { display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--line-soft); }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--line-soft);
  background: var(--ink-850);
  gap: 18px;
}
.topbar h1 { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; }
.topbar .sub { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-3); margin-top: 3px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.save-status { font-family: var(--font-mono); font-size: 12px; color: var(--fg-3); transition: color 0.3s, opacity 0.3s; }
.save-status.ok { color: var(--accent); }

/* language tabs */
.lang-tabs { display: flex; gap: 3px; background: var(--ink-900); border: 1px solid var(--line-soft); border-radius: 100px; padding: 4px; }
.lang-tab {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-2);
  padding: 7px 14px; border-radius: 100px; transition: background 0.2s, color 0.2s;
}
.lang-tab.active { background: var(--accent); color: var(--accent-ink); }

.panel-scroll { overflow-y: auto; padding: 28px; flex: 1; }
.panel { display: none; max-width: 720px; }
.panel.active { display: block; animation: fade 0.4s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.group { margin-bottom: 30px; }
.group-title {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--fg-3);
  padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--line-soft);
}
.field { margin-bottom: 16px; }
.field > label {
  display: block; font-size: 13px; color: var(--fg-2); margin-bottom: 7px; font-weight: 500;
}
.field .hint { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-4); margin-inline-start: 6px; }
.inp, .ta {
  width: 100%; background: var(--ink-850); border: 1px solid var(--line);
  border-radius: 9px; padding: 11px 13px; color: var(--fg-1); font-size: 14px;
  transition: border-color 0.2s, background 0.2s;
}
.inp:focus, .ta:focus { outline: none; border-color: var(--accent); background: var(--ink-800); }
.inp::placeholder, .ta::placeholder { color: var(--fg-4); }
.ta { resize: vertical; min-height: 80px; line-height: 1.5; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1.4fr 0.7fr; gap: 12px; align-items: end; }

/* color swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch {
  width: 38px; height: 38px; border-radius: 10px; border: 2px solid transparent;
  position: relative; transition: transform 0.2s;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: var(--fg-1); }
.swatch.active::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: #000; font-size: 15px; font-weight: 800; }
.swatch-custom { display: inline-flex; align-items: center; gap: 8px; }
.swatch-custom input[type="color"] { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: none; cursor: pointer; padding: 2px; }

/* logo preview */
.logo-row { display: flex; align-items: center; gap: 16px; }
.logo-prev {
  width: 52px; height: 52px; border-radius: 13px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 24px;
}
.logo-row .inp { width: 90px; text-align: center; font-size: 20px; font-family: var(--font-display); font-weight: 700; }

/* toggle */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 15px; background: var(--ink-850); border: 1px solid var(--line-soft);
  border-radius: 10px; margin-bottom: 10px;
}
.toggle-row .t-label { font-size: 14px; }
.toggle-row .t-label small { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); margin-top: 2px; }
.switch { width: 44px; height: 26px; border-radius: 100px; background: var(--ink-600); position: relative; transition: background 0.25s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--fg-1); transition: transform 0.25s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); background: var(--accent-ink); }

/* project card editor */
.proj-edit { background: var(--ink-850); border: 1px solid var(--line-soft); border-radius: 13px; padding: 16px; margin-bottom: 14px; }
.proj-edit-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.proj-edit-head h4 { font-family: var(--font-display); font-size: 15px; font-weight: 600; }
.proj-ctrls { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
  color: var(--fg-2); display: grid; place-items: center; transition: all 0.2s;
}
.icon-btn:hover { border-color: var(--fg-3); color: var(--fg-1); }
.icon-btn.del:hover { border-color: #ff6f6f; color: #ff6f6f; }
.icon-btn svg { width: 15px; height: 15px; }
.proj-edit.off { opacity: 0.5; }

/* ---------- PREVIEW ---------- */
.preview { display: flex; flex-direction: column; background: var(--ink-900); overflow: hidden; }
.preview-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-bottom: 1px solid var(--line-soft); background: var(--ink-850);
}
.preview-bar .pt { font-family: var(--font-mono); font-size: 12px; color: var(--fg-3); display: flex; align-items: center; gap: 8px; }
.preview-bar .pt .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.preview-wrap { flex: 1; overflow: hidden; position: relative; background: var(--ink-900); }
.preview-frame { width: 100%; height: 100%; border: 0; display: block; }

/* toast */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  padding: 13px 22px; border-radius: 100px; opacity: 0; pointer-events: none;
  transition: opacity 0.3s, transform 0.3s; z-index: 50;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,0.6);
  display: flex; align-items: center; gap: 9px;
}
.toast svg { width: 16px; height: 16px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1180px) {
  .admin { grid-template-columns: 230px 1fr; }
  .preview { display: none; }
}
@media (max-width: 760px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; width: 244px; height: 100%; transform: translateX(-100%); transition: transform 0.3s; }
  .side.open { transform: none; }
}
