/* ==========================================================================
   PORTFOLIO DASHBOARD — "Obsidian & Gold" admin theme
   ========================================================================== */
:root {
  --bg: #0b0a08;
  --bg-alt: #100e0a;
  --surface: #14110b;
  --bg-glass: rgba(244, 239, 228, 0.05);
  --text: #f4efe4;
  --text-soft: #b8afa0;
  --text-faint: #958c7c;
  --gold: #e3b566;
  --gold-deep: #c98a3d;
  --gold-ink: #1c1508;
  --gold-grad: linear-gradient(135deg, #ecc684, #c98a3d);
  --line: rgba(227, 181, 102, 0.14);
  --line-strong: rgba(227, 181, 102, 0.32);
  --success: #7fd99a;
  --error: #f0937c;
  --danger: #e06a52;
  --font-display: "Syne", "Avenir Next", sans-serif;
  --font-body: "Manrope", "Helvetica Neue", Arial, sans-serif;
  --radius: 16px;
  --radius-lg: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --speed: 0.25s;
}

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

html, body { max-width: 100%; overflow-x: hidden; }

body {
  min-height: 100vh;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}
.glow-a { width: 480px; height: 480px; top: -160px; left: -120px; background: radial-gradient(circle, rgba(227,181,102,0.5), transparent 70%); }
.glow-b { width: 520px; height: 520px; bottom: -200px; right: -140px; background: radial-gradient(circle, rgba(201,138,61,0.4), transparent 70%); }

.glass {
  background: linear-gradient(160deg, rgba(244,239,228,0.05), rgba(244,239,228,0.02));
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

i { font-style: normal; color: var(--gold); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.7rem 1.15rem;
  border: 1px solid transparent; border-radius: 999px;
  font-family: var(--font-body); font-weight: 700; font-size: 0.9rem;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) ease, background var(--speed) ease, border-color var(--speed) ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 0.5rem 0.9rem; font-size: 0.82rem; }
.btn-gold { background: var(--gold-grad); color: var(--gold-ink); }
.btn-gold:hover { box-shadow: 0 12px 28px rgba(227,181,102,0.3); transform: translateY(-2px); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-danger { background: rgba(224,106,82,0.14); color: var(--danger); border-color: rgba(224,106,82,0.4); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 50%; background: rgba(11,10,8,0.6); border: 1px solid var(--line-strong);
  color: var(--text); cursor: pointer; transition: background var(--speed) ease, transform var(--speed) ease;
}
.icon-btn:hover { background: var(--gold); color: var(--gold-ink); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.link-btn {
  background: none; border: none; color: var(--text-faint); cursor: pointer;
  font: inherit; font-size: 0.8rem; text-decoration: underline; padding: 0.25rem 0; align-self: flex-start;
}
.link-btn:hover { color: var(--error); }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field > span { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; color: var(--text-soft); text-transform: uppercase; }
.field input, .field textarea, .url-input {
  width: 100%; padding: 0.75rem 0.9rem;
  background: rgba(11,10,8,0.5); border: 1px solid var(--line-strong); border-radius: 12px;
  color: var(--text); font: inherit; font-size: 0.92rem;
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus, .url-input:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(227,181,102,0.18);
}
.url-input { margin-top: 0.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.field-wide { grid-column: 1 / -1; }
.field-inline { flex-direction: row; align-items: center; gap: 0.6rem; }
.field-inline span { text-transform: none; }
.field-inline input { width: 90px; }

/* ============================ AUTH SCREEN ============================ */
.auth-screen {
  position: relative; z-index: 1;
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
}
.auth-card {
  width: min(420px, 100%); border-radius: var(--radius-lg);
  padding: clamp(1.75rem, 5vw, 2.5rem); display: flex; flex-direction: column; gap: 1rem;
}
.auth-brand { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; }
.auth-brand span { color: var(--text-faint); font-weight: 600; font-size: 0.9rem; }
.auth-card h1 { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.15; }
.auth-sub { color: var(--text-soft); font-size: 0.92rem; margin-top: -0.4rem; }
.auth-card .btn-gold { margin-top: 0.5rem; }
.auth-error { color: var(--error); font-size: 0.85rem; min-height: 1em; }
.auth-toggle { font-size: 0.85rem; color: var(--text-soft); }
.auth-toggle .link-btn { color: var(--gold); text-decoration: none; font-weight: 700; }
.auth-toggle .link-btn:hover { color: var(--gold-deep); text-decoration: underline; }
.auth-hint { color: var(--text-faint); font-size: 0.78rem; line-height: 1.5; }
.auth-hint code { color: var(--gold); background: rgba(227,181,102,0.1); padding: 0.1em 0.4em; border-radius: 6px; }

/* ============================== APP LAYOUT ============================== */
.app { position: relative; z-index: 1; min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 1.5rem; padding: 1.75rem 1.25rem;
  border-right: 1px solid var(--line); background: rgba(16,14,10,0.6); backdrop-filter: blur(14px);
}
.side-brand { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; }
.side-nav { display: flex; flex-direction: column; gap: 0.4rem; }
.side-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.9rem; border-radius: 12px; border: 1px solid transparent;
  background: none; color: var(--text-soft); font: inherit; font-weight: 600; font-size: 0.95rem;
  cursor: pointer; text-align: left; transition: all var(--speed) ease;
}
.side-link svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.side-link:hover { color: var(--text); background: var(--bg-glass); }
.side-link.is-active { color: var(--gold); background: rgba(227,181,102,0.1); border-color: var(--line-strong); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.75rem; }
.side-view { color: var(--text-soft); text-decoration: none; font-size: 0.88rem; font-weight: 600; }
.side-view:hover { color: var(--gold); }
.side-logout { background: none; border: 1px solid var(--line-strong); color: var(--text); padding: 0.6rem; border-radius: 10px; cursor: pointer; font: inherit; font-size: 0.85rem; transition: all var(--speed) ease; }
.side-logout:hover { border-color: var(--danger); color: var(--danger); }

/* Mobile bars (hidden on desktop) */
.topbar, .tabbar { display: none; }

.content { padding: clamp(1.25rem, 3.5vw, 2.5rem); }

.panel { display: none; animation: fade 0.35s var(--ease); }
.panel.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.panel-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1.75rem;
}
.panel-head h2 { font-family: var(--font-display); font-size: clamp(1.5rem, 4vw, 2rem); }
.panel-sub { color: var(--text-faint); font-size: 0.9rem; margin-top: 0.25rem; }
.panel-head-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---------- Analytics stats row ---------- */
.stats-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.9rem; margin-bottom: 1.75rem; }
@media (min-width: 720px) { .stats-row { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
  padding: 1.1rem 1.25rem; border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(227,181,102,0.08), rgba(244,239,228,0.02));
  display: flex; flex-direction: column; gap: 0.3rem;
}
.stat-card-num { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.5rem, 4vw, 2rem); color: var(--gold); line-height: 1; }
.stat-card-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }

/* ---------- Projects grid (admin cards) ---------- */
.cards-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.admin-card {
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
  cursor: pointer; transition: transform var(--speed) var(--ease), border-color var(--speed) ease, box-shadow var(--speed) ease;
}
.admin-card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: 0 20px 44px rgba(0,0,0,0.4); }
.admin-card-media { position: relative; aspect-ratio: 16/10; background: var(--bg-alt); }
.admin-card-media img { width: 100%; height: 100%; object-fit: cover; }
.admin-badges { position: absolute; top: 0.6rem; left: 0.6rem; display: flex; gap: 0.35rem; }
.badge { padding: 0.2rem 0.55rem; border-radius: 999px; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.badge-feature { background: var(--gold-grad); color: var(--gold-ink); }
.badge-order { background: rgba(11,10,8,0.75); color: var(--text-soft); border: 1px solid var(--line-strong); }
.admin-card-body { padding: 0.9rem 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.35rem; }
.admin-card-body h3 { font-family: var(--font-display); font-size: 1.1rem; }
.admin-card-cat { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.admin-card-desc { font-size: 0.85rem; color: var(--text-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.admin-card-foot { margin-top: 0.5rem; display: flex; gap: 0.5rem; }
.card-mini {
  flex: 1; padding: 0.45rem; border-radius: 9px; border: 1px solid var(--line-strong);
  background: rgba(11,10,8,0.4); color: var(--text-soft); font: inherit; font-size: 0.78rem; font-weight: 600; cursor: pointer;
  transition: all var(--speed) ease;
}
.card-mini:hover { color: var(--gold); border-color: var(--gold); }
.card-mini.danger:hover { color: var(--danger); border-color: var(--danger); }

.empty-state {
  grid-column: 1/-1; text-align: center; padding: 3.5rem 1rem; color: var(--text-faint);
  border: 1px dashed var(--line-strong); border-radius: var(--radius-lg);
}

/* ---------- Settings form ---------- */
.settings-form { border-radius: var(--radius-lg); padding: clamp(1.25rem, 3vw, 2rem); display: flex; flex-direction: column; gap: 1.75rem; }
.settings-form fieldset { border: none; display: flex; flex-direction: column; gap: 1rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.settings-form fieldset:last-child { border-bottom: none; padding-bottom: 0; }
.settings-form legend { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--gold); margin-bottom: 0.25rem; }
.stats-editor { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 640px) { .stats-editor { grid-template-columns: 1fr 1fr; } }
.stat-edit { display: grid; grid-template-columns: 90px 1fr; gap: 0.6rem; align-items: end; }

/* ============================== DRAWER (editor) ============================== */
.drawer { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: flex-end; }
.drawer[hidden] { display: none; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(6,5,3,0.7); backdrop-filter: blur(6px); animation: fade 0.3s ease; }
.drawer-panel {
  position: relative; z-index: 1; width: min(560px, 100%); height: 100%;
  display: flex; flex-direction: column; border-left: 1px solid var(--line-strong);
  background: linear-gradient(160deg, rgba(20,17,11,0.98), rgba(16,14,10,0.98));
  animation: slideIn 0.35s var(--ease);
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--line); }
.drawer-head h3 { font-family: var(--font-display); font-size: 1.3rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }
.drawer-foot { display: flex; align-items: center; gap: 0.6rem; padding: 1rem 1.5rem; border-top: 1px solid var(--line); }
.drawer-foot .spacer { flex: 1; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; font-size: 0.9rem; font-weight: 600; color: var(--text-soft); }
.switch input { display: none; }
.switch span { width: 42px; height: 24px; border-radius: 999px; background: rgba(11,10,8,0.6); border: 1px solid var(--line-strong); position: relative; transition: background var(--speed) ease; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-soft); transition: transform var(--speed) var(--ease), background var(--speed) ease; }
.switch input:checked + span { background: rgba(227,181,102,0.25); border-color: var(--gold); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--gold); }

/* Uploader */
.uploader {
  position: relative; border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  min-height: 150px; display: grid; place-items: center; overflow: hidden; cursor: pointer;
  background: rgba(11,10,8,0.4); transition: border-color var(--speed) ease, background var(--speed) ease;
}
.uploader:hover, .uploader.is-drag { border-color: var(--gold); background: rgba(227,181,102,0.06); }
.uploader-preview { width: 100%; height: 100%; max-height: 220px; object-fit: cover; }
.uploader-cta { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; padding: 1.5rem; text-align: center; color: var(--text-faint); font-size: 0.82rem; }
.uploader-cta svg { width: 30px; height: 30px; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Gallery */
.gallery-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; margin-top: 0.75rem; }
.gallery-item { display: flex; flex-direction: column; gap: 0.4rem; }
.gallery-thumb { position: relative; aspect-ratio: 16/11; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-strong); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb button {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(6,5,3,0.85); border: none; color: #fff; cursor: pointer; display: grid; place-items: center; font-size: 0.85rem; line-height: 1;
}
.gallery-thumb button:hover { background: var(--danger); }
.gallery-caption {
  width: 100%; padding: 0.5rem 0.65rem; font: inherit; font-size: 0.8rem;
  background: rgba(11,10,8,0.5); border: 1px solid var(--line-strong); border-radius: 9px; color: var(--text);
}
.gallery-caption:focus { outline: none; border-color: var(--gold); }

/* Links editor */
.links-editor { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.75rem; }
.link-row { display: grid; grid-template-columns: 1fr 1.5fr auto; gap: 0.5rem; align-items: center; }
.link-row input { padding: 0.6rem 0.75rem; background: rgba(11,10,8,0.5); border: 1px solid var(--line-strong); border-radius: 10px; color: var(--text); font: inherit; font-size: 0.85rem; }
.link-row input:focus { outline: none; border-color: var(--gold); }
.link-row button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line-strong); background: none; color: var(--text-faint); cursor: pointer; }
.link-row button:hover { color: var(--danger); border-color: var(--danger); }

/* Toast */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 300; padding: 0.85rem 1.4rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--text);
  font-weight: 600; font-size: 0.9rem; box-shadow: 0 18px 40px rgba(0,0,0,0.5);
  opacity: 0; transition: opacity var(--speed) ease, transform var(--speed) var(--ease);
}
.toast[hidden] { display: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(127,217,154,0.5); }
.toast.err { border-color: rgba(240,147,124,0.6); color: var(--error); }

/* Confirm */
.confirm { position: fixed; inset: 0; z-index: 250; display: grid; place-items: center; padding: 1.5rem; }
.confirm[hidden] { display: none; }
.confirm-box { position: relative; z-index: 1; width: min(400px, 100%); padding: 1.75rem; border-radius: var(--radius-lg); text-align: center; }
.confirm-box p { margin-bottom: 1.25rem; color: var(--text-soft); }
.confirm-actions { display: flex; gap: 0.6rem; justify-content: center; }

/* ============================== RESPONSIVE ============================== */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20; padding: 0.9rem 1.1rem;
    background: rgba(16,14,10,0.9); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
  }
  .topbar-actions { display: flex; gap: 0.5rem; }
  .tabbar {
    display: flex; position: sticky; top: 57px; z-index: 19; gap: 0.4rem; padding: 0.6rem 1.1rem;
    background: rgba(11,10,8,0.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  }
  .tab-link {
    flex: 1; padding: 0.6rem; border-radius: 10px; border: 1px solid transparent;
    background: none; color: var(--text-soft); font: inherit; font-weight: 700; font-size: 0.88rem; cursor: pointer;
  }
  .tab-link.is-active { color: var(--gold); background: rgba(227,181,102,0.1); border-color: var(--line-strong); }
  .drawer-panel { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
