/* ============================================================
   MAGEITECH ADMIN — dark sharp utilitarian
   ============================================================ */

:root, :root[data-theme="dark"] {
  --bg: #0A0A0A;
  --bg-2: #0F0F10;
  --surface: #141414;
  --surface-2: #1A1A1B;
  --border: #1F1F1F;
  --border-2: #2A2A2A;
  --text: #FAFAFA;
  --text-dim: #A0A0A0;
  --text-dim2: #6B6B6B;
  --brand: #F26B1F;
  --brand-2: #FF8A3D;
  --ok: #27AE60;
  --err: #E74C3C;
  --ease: cubic-bezier(.22,.61,.36,1);
}

:root[data-theme="light"] {
  --bg: #F5F5F7;
  --bg-2: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F0F0F2;
  --border: #E2E2E5;
  --border-2: #CECED4;
  --text: #111111;
  --text-dim: #555560;
  --text-dim2: #9999A8;
  --brand: #E55A0A;
  --brand-2: #F26B1F;
  --ok: #16A34A;
  --err: #DC2626;
  --ease: cubic-bezier(.22,.61,.36,1);
}

/* Theme toggle button */
.theme-toggle {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--border-2);
  border-radius: 8px; cursor: pointer; color: var(--text-dim);
  flex-shrink: 0;
  transition: border-color .25s var(--ease), color .25s var(--ease);
}
.theme-toggle:hover { border-color: var(--brand); color: var(--brand); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-icon { display: none; }
[data-theme="dark"]  .theme-icon--sun  { display: block; }
[data-theme="light"] .theme-icon--moon { display: block; }

* { box-sizing: border-box; margin: 0; padding: 0; }
*, *::before, *::after { transition: background-color .3s ease, border-color .3s ease, color .15s ease; }
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
.muted { color: var(--text-dim); }
.small { font-size: .82rem; }

/* ============ LOGIN ============ */
.login-body {
  display: grid; place-items: center; min-height: 100vh;
  background: #080808;
  overflow: hidden;
  position: relative;
}

/* Layered gradient blobs */
.login-body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%,  rgba(242,107,31,.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 85%,  rgba(242,107,31,.12) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 60% 40%,  rgba(255,80,0,.06)   0%, transparent 50%),
    radial-gradient(ellipse 100% 80% at 50% 50%, rgba(10,5,0,.9)      0%, transparent 100%);
  animation: blobDrift 14s ease-in-out infinite alternate;
}
.login-body::after {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(242,107,31,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(242,107,31,.04) 1px, transparent 1px);
  background-size: 48px 48px;
  /* prefixed first for Safari, then standard */
  -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 100%);
  mask-image:         radial-gradient(ellipse 80% 80% at 50% 50%, black 30%, transparent 100%);
}

/* blobDrift removed — background-position is paint-triggering and non-GPU.
   Static layered gradients look equally rich without the cost. */

/* Floating orbs — animated via Web Animations API in JS (no @keyframes = no linter hints) */
.login-orb {
  position: fixed; z-index: 0; pointer-events: none;
  will-change: transform;
}
.login-orb__inner {
  width: 100%; height: 100%;
  border-radius: 50%;
  filter: blur(80px);
}
.login-orb--1 { width: 500px; height: 500px; top: -120px; left: -100px; }
.login-orb--1 .login-orb__inner { background: radial-gradient(circle, rgba(242,107,31,.22), transparent 70%); }

.login-orb--2 { width: 400px; height: 400px; bottom: -80px; right: -80px; }
.login-orb--2 .login-orb__inner { background: radial-gradient(circle, rgba(255,100,20,.16), transparent 70%); }

.login-orb--3 { width: 280px; height: 280px; top: 50%; right: 15%; }
.login-orb--3 .login-orb__inner { background: radial-gradient(circle, rgba(242,107,31,.1), transparent 70%); }

/* Noise texture overlay */
.login-noise {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* Card */
.login {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px;
  padding: 44px 38px;
  background: rgba(18,18,18,.82);
  border: 1px solid rgba(242,107,31,.18);
  border-radius: 24px;
  /* prefixed first for Safari */
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  backdrop-filter:         blur(24px) saturate(1.4);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.04) inset,
    0 32px 80px rgba(0,0,0,.6),
    0 0 60px rgba(242,107,31,.08);
  will-change: opacity, transform; /* own layer for cardIn animation */
  animation: cardIn .6s var(--ease) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Top accent bar */
.login::before {
  content: '';
  position: absolute; top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(242,107,31,.7), transparent);
  border-radius: 1px;
}

.login__brand { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 600; margin-bottom: 32px; }
.login h1 { font-size: 1.6rem; margin-bottom: 4px; letter-spacing: -.02em; }
.login p { margin-bottom: 24px; font-size: .92rem; }
.login__form { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.login__form label { display: flex; flex-direction: column; gap: 6px; }
.login__form label span { font-size: .8rem; color: var(--text-dim); font-weight: 500; }
.login code { background: rgba(0,0,0,.4); padding: 2px 6px; border-radius: 4px; color: var(--brand); font-size: .8rem; }

input, select, textarea {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 11px 14px;
  font-family: inherit;
  font-size: .95rem;
  width: 100%;
  transition: border-color .3s var(--ease);
}
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 500;
  font-size: .92rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .3s var(--ease);
  white-space: nowrap;
}
.btn--sm    { padding: 7px 14px; font-size: .85rem; }
.btn--lg    { padding: 12px 22px; font-size: .98rem; }
.btn--block { width: 100%; }
.btn--primary { background: var(--brand); color: #0A0A0A; font-weight: 600; }
.btn--primary:hover { background: var(--brand-2); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border-2); }
.btn--ghost:hover { border-color: var(--text); }

/* ============ LAYOUT ============ */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.side {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 24px 18px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side__brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 1rem;
  padding: 0 10px 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.side__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side__nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: .92rem;
  transition: all .25s var(--ease);
}
.side__nav a:hover { background: var(--surface); color: var(--text); }
.side__nav a.is-active { background: var(--surface); color: var(--text); box-shadow: inset 3px 0 0 var(--brand); }
.side__nav a.is-active svg { color: var(--brand); }

.side__foot { padding-top: 20px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.side__user { display: flex; align-items: center; gap: 10px; font-size: .82rem; }
.side__user .theme-toggle { margin-left: auto; }
.side__user strong { font-size: .9rem; }
.side__user a { color: var(--text-dim); }
.side__user a:hover { color: var(--brand); }
.side__avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #000; display: grid; place-items: center; font-weight: 700; }
.side__link { font-size: .82rem; color: var(--text-dim); }
.side__link:hover { color: var(--brand); }

.main { padding: 32px 36px 80px; max-width: 1200px; width: 100%; }

/* ============ TOPBAR ============ */
.topbar {
  display: flex; justify-content: space-between; align-items: flex-end;
  padding-bottom: 22px; margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.5rem; letter-spacing: -.02em; font-weight: 600; margin-bottom: 4px; }

/* ============ ALERTS ============ */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-size: .92rem; }
.alert--ok  { background: rgba(39,174,96,.1); color: var(--ok); border: 1px solid rgba(39,174,96,.3); }
.alert--err { background: rgba(231,76,60,.1); color: var(--err); border: 1px solid rgba(231,76,60,.3); }

/* ============ KPIs ============ */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 32px; }
.kpi {
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .3s var(--ease);
}
.kpi:hover { border-color: var(--border-2); }
.kpi--accent { background: linear-gradient(135deg, var(--surface), rgba(242,107,31,.08)); border-color: rgba(242,107,31,.3); }
.kpi__lbl { font-size: .78rem; color: var(--text-dim); letter-spacing: .04em; text-transform: uppercase; }
.kpi__num { font-size: 2rem; font-weight: 600; letter-spacing: -.02em; }
.kpi--accent .kpi__num { color: var(--brand); }

/* ============ CARD ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; margin-bottom: 20px; }
.card__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 16px; }
.card__head h2 { font-size: 1.1rem; font-weight: 600; letter-spacing: -.01em; }
.empty { padding: 30px; text-align: center; }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 12px 14px;
  font-size: .78rem; font-weight: 500;
  color: var(--text-dim); letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 1px solid var(--border-2);
}
.table td { padding: 14px 14px; font-size: .9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table a:hover { color: var(--brand); }
.msg-cell { max-width: 300px; color: var(--text-dim); font-size: .85rem; }

/* Status pills */
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 500; letter-spacing: .02em; }
.pill--new        { background: rgba(242,107,31,.14); color: var(--brand); }
.pill--contacted  { background: rgba(255,255,255,.08); color: var(--text); }
.pill--converted  { background: rgba(39,174,96,.15); color: var(--ok); }
.pill--lost       { background: rgba(231,76,60,.12); color: var(--err); }

.pill-select {
  padding: 5px 26px 5px 10px !important;
  border-radius: 999px !important;
  border: 1px solid transparent !important;
  font-size: .75rem !important;
  font-weight: 500 !important;
  width: auto !important;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23a0a0a0' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.pill-select--new        { background-color: rgba(242,107,31,.14); color: var(--brand); }
.pill-select--contacted  { background-color: rgba(255,255,255,.08); color: var(--text); }
.pill-select--converted  { background-color: rgba(39,174,96,.15); color: var(--ok); }
.pill-select--lost       { background-color: rgba(231,76,60,.12); color: var(--err); }
.pill-select option      { background: var(--surface); color: var(--text); }

.icon-btn {
  width: 30px; height: 30px; border-radius: 8px;
  background: transparent; border: 1px solid var(--border-2);
  color: var(--text-dim); cursor: pointer;
  display: inline-grid; place-items: center;
  transition: all .25s var(--ease);
}
.icon-btn:hover { border-color: var(--err); color: var(--err); background: rgba(231,76,60,.08); }
.icon-btn--wa:hover   { border-color: #25D366; color: #25D366; background: rgba(37,211,102,.1); }
.icon-btn--call:hover { border-color: #3B82F6; color: #3B82F6; background: rgba(59,130,246,.1); }
.icon-btn--mail:hover { border-color: var(--brand); color: var(--brand); background: rgba(242,107,31,.1); }
.contact-actions { display: flex; gap: 6px; margin-top: 6px; }
.inline-form { display: inline-block; margin: 0; }

/* ============ FILTERS ============ */
.filters { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 180px; }

/* ============ CONTENT FORM ============ */
.content-form, .seo-form { padding-bottom: 90px; }
.fields { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__lbl { font-size: .78rem; color: var(--text-dim); letter-spacing: .04em; text-transform: uppercase; font-weight: 500; }
.field__preview { max-height: 100px; width: auto; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 6px; }
textarea { font-family: inherit; resize: vertical; min-height: 70px; }

.sticky-save {
  position: fixed; bottom: 0; left: 240px; right: 0;
  padding: 16px 36px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  backdrop-filter: blur(10px);
  display: flex; justify-content: flex-end;
  z-index: 20;
}

/* ============ MOBILE TOPBAR (hidden on desktop) ============ */
.mob-topbar {
  display: none; /* shown only in mobile media query */
}

/* ============ HAMBURGER ============ */
.hamburger {
  width: 38px; height: 38px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  background: transparent; border: 1px solid var(--border-2); border-radius: 8px; cursor: pointer;
  padding: 0; flex-shrink: 0;
  transition: border-color .25s var(--ease);
}
.hamburger:hover { border-color: var(--brand); }
.hamburger span {
  display: block; width: 18px; height: 2px;
  background: var(--text); border-radius: 2px;
  transition: transform .3s var(--ease), opacity .3s var(--ease), width .3s var(--ease);
  transform-origin: center;
}
/* Animated X when sidebar open */
.hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.is-open span:nth-child(2) { opacity: 0; width: 0; }
.hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============ OVERLAY ============ */
/* Always in the DOM, invisible + non-interactive by default.
   Using opacity+pointer-events (not display:none) so CSS transitions work. */
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 148;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease);
}
.sidebar-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* ============ CLOSE BUTTON (mobile only) ============ */
.side__close {
  display: none; /* shown in mobile media query */
  margin-left: auto;
  background: transparent; border: 1px solid var(--border-2); border-radius: 8px;
  color: var(--text-dim); cursor: pointer;
  width: 30px; height: 30px; font-size: .85rem;
  transition: all .25s var(--ease);
  align-items: center; justify-content: center;
}
.side__close:hover { border-color: var(--err); color: var(--err); }

/* ============ RESPONSIVE — tablet & mobile ============ */
@media (max-width: 960px) {

  /* ── Mobile topbar ── */
  .mob-topbar {
    display: flex;
    position: fixed; top: 0; left: 0; right: 0; z-index: 200;
    height: 56px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    align-items: center;
    gap: 12px;
    padding: 0 16px;
  }
  .mob-topbar__brand {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: .95rem;
  }
  .mob-topbar__page {
    margin-left: auto;
    font-size: .82rem; color: var(--text-dim);
  }

  /* ── Layout ── */
  .layout {
    display: block;
    padding-top: 56px; /* height of mob-topbar */
    min-height: calc(100vh - 56px);
  }

  /* ── Sidebar drawer ── */
  .side {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 199; /* below mob-topbar (200) so topbar always on top */
    width: 272px;
    transform: translateX(-100%);
    transition: transform .32s var(--ease);
    overflow-y: auto;
  }
  .side.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,.5);
  }

  /* ── Close button visible on mobile ── */
  .side__close { display: flex; }

  /* ── Main content ── */
  .main { padding: 24px 16px 80px; max-width: 100%; }

  /* ── KPIs ── */
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* ── Sticky save bar ── */
  .sticky-save { left: 0; padding: 14px 16px; }

  /* ── Topbar row ── */
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .topbar__actions { align-self: stretch; display: flex; justify-content: flex-end; }

  /* ── Filters ── */
  .filters { flex-direction: column; }
  .filters input, .filters select { width: 100%; min-width: 0; }
}

@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .mob-topbar__page { display: none; }
  .main { padding: 16px 12px 80px; }
  .kpi { padding: 18px 14px; }
  .kpi__num { font-size: 1.6rem; }
}
