/* =========================================================
   KRETIVZ — Admin Portal Styles
   WordPress-inspired admin UI
   ========================================================= */
:root {
  --a-primary: #07311a;
  --a-primary-2: #0a4527;
  --a-primary-3: #1d6840;
  --a-accent: #dc2740;
  --a-lime: #c5ec6c;
  --a-sidebar: #061a10;
  --a-sidebar-2: #0a2719;
  --a-bg: #f3f1ec;
  --a-surface: #fff;
  --a-border: #e3e0d8;
  --a-ink: #0b1212;
  --a-ink-soft: #3a4441;
  --a-ink-mute: #7d847f;
  --a-success: #1d8a4d;
  --a-warn: #d08a26;
  --a-danger: #c63a3a;
  --a-shadow: 0 2px 8px rgba(7, 49, 26, 0.06);
  --a-shadow-lg: 0 20px 50px rgba(7, 49, 26, 0.12);
  --a-radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", -apple-system, system-ui, sans-serif;
  background: var(--a-bg);
  color: var(--a-ink);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--a-primary); text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---------- LOGIN ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(60% 50% at 50% 30%, #0a4527, #07311a 70%, #061a10);
  padding: 2rem;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 2.5rem;
  width: min(420px, 100%);
  box-shadow: 0 40px 80px rgba(0,0,0,.3);
}
.login-card .brand-block {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-card .brand-logo .wordmark {
  display: inline-flex;
  font-family: Inter, sans-serif;
  font-weight: 900;
  font-size: 2rem;
  letter-spacing: -.04em;
  border-radius: 6px;
  overflow: hidden;
}
.login-card .brand-logo .kre { background: var(--a-accent); color: #fff; padding: 8px 8px 8px 10px; }
.login-card .brand-logo .tivz { background: #fff; color: #0b1212; padding: 8px 12px 8px 6px; border: 1px solid #e7e4dc; border-left: none; }
.login-card .tag {
  color: var(--a-accent);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  margin-top: 6px;
}
.login-card h1 {
  font-family: "Fraunces", serif;
  font-size: 1.7rem;
  margin: 0 0 .25rem;
  letter-spacing: -.02em;
}
.login-card p.sub { color: var(--a-ink-mute); margin: 0 0 1.5rem; }
.login-card .hint {
  background: #f5f3ed;
  border: 1px dashed var(--a-border);
  border-radius: 10px;
  padding: .75rem 1rem;
  font-size: .82rem;
  color: var(--a-ink-soft);
  margin-bottom: 1.5rem;
}
.login-card .hint strong { color: var(--a-primary); }

.field-group { margin-bottom: 1rem; }
.field-group label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--a-ink-soft);
  margin-bottom: .35rem;
}
.field-group input {
  width: 100%;
  padding: .75rem 1rem;
  border: 1px solid var(--a-border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.field-group input:focus {
  outline: none;
  border-color: var(--a-primary);
  box-shadow: 0 0 0 3px rgba(7,49,26,.12);
}

.a-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--a-primary);
  color: #fff;
  font-weight: 600;
  font-size: .92rem;
  transition: transform .2s, box-shadow .2s, background .2s;
  white-space: nowrap;
}
.a-btn:hover { transform: translateY(-1px); box-shadow: var(--a-shadow); }
.a-btn.full { width: 100%; justify-content: center; }
.a-btn.ghost { background: transparent; color: var(--a-ink); border-color: var(--a-border); }
.a-btn.ghost:hover { background: #fff; }
.a-btn.danger { background: var(--a-danger); }
.a-btn.accent { background: var(--a-accent); }
.a-btn.lime   { background: var(--a-lime); color: var(--a-primary); }
.a-btn.sm     { padding: .45rem .8rem; font-size: .82rem; }

.login-error {
  margin-top: 1rem;
  padding: .65rem .85rem;
  background: #fde7e7;
  color: #94302f;
  border-radius: 8px;
  font-size: .85rem;
  display: none;
}
.login-error.is-on { display: block; }

/* ---------- APP SHELL ---------- */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
}

.sidebar {
  background: var(--a-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
@media (max-width: 880px) {
  .sidebar { position: relative; height: auto; }
}
.sidebar .brand {
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  margin-bottom: .75rem;
}
.sidebar .brand .wordmark {
  display: inline-flex;
  font-family: Inter, sans-serif;
  font-weight: 900;
  font-size: 1.35rem;
  letter-spacing: -.04em;
  border-radius: 4px;
  overflow: hidden;
}
.sidebar .brand .kre { background: var(--a-accent); color: #fff; padding: 5px 6px 5px 7px; }
.sidebar .brand .tivz { background: #fff; color: #0b1212; padding: 5px 8px 5px 5px; }
.sidebar .brand .tag {
  display: block;
  margin-top: .35rem;
  font-size: .58rem;
  letter-spacing: .18em;
  color: rgba(255,255,255,.55);
  text-transform: uppercase;
  font-weight: 700;
}
.sidebar nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 .75rem;
}
.sidebar nav .group-label {
  text-transform: uppercase;
  font-size: .65rem;
  letter-spacing: .14em;
  color: rgba(255,255,255,.4);
  padding: 1rem .5rem .35rem;
  font-weight: 700;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .65rem;
  border-radius: 8px;
  color: rgba(255,255,255,.78);
  font-size: .9rem;
  transition: background .2s, color .2s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar nav a.active {
  background: var(--a-primary-3);
  color: #fff;
}
.sidebar nav a svg { width: 16px; height: 16px; opacity: .85; }
.sidebar .foot {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: .8rem;
  color: rgba(255,255,255,.55);
}
.sidebar .foot a { color: var(--a-lime); }

/* ---------- MAIN ---------- */
.main { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--a-border);
  padding: .85rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.topbar .crumbs {
  font-size: .85rem;
  color: var(--a-ink-mute);
  display: flex;
  gap: .35rem;
  align-items: center;
}
.topbar .crumbs strong { color: var(--a-ink); font-weight: 600; }
.topbar .actions { display: flex; gap: .5rem; align-items: center; }
.topbar .pill {
  padding: .3rem .65rem;
  background: var(--a-bg);
  border: 1px solid var(--a-border);
  border-radius: 999px;
  font-size: .78rem;
  color: var(--a-ink-soft);
  font-weight: 600;
}
.topbar .pill.live { color: var(--a-success); }
.topbar .pill.live::before { content: "●"; margin-right: 4px; }

.content {
  padding: 1.75rem;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
@media (max-width: 660px) { .content { padding: 1.25rem; } }

.view { display: none; }
.view.is-on { display: block; }

.page-head { margin-bottom: 1.5rem; }
.page-head h1 {
  font-family: "Fraunces", serif;
  font-size: 1.7rem;
  margin: 0 0 .25rem;
  letter-spacing: -.02em;
}
.page-head p { margin: 0; color: var(--a-ink-mute); }

/* ---------- KPIS ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 980px) { .kpi-grid { grid-template-columns: repeat(2,1fr); } }
.kpi {
  background: #fff;
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  padding: 1.1rem;
}
.kpi .label { color: var(--a-ink-mute); font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.kpi .value {
  font-family: "Fraunces", serif;
  font-size: 2rem;
  letter-spacing: -.02em;
  margin: .4rem 0 .2rem;
}
.kpi .delta { font-size: .78rem; color: var(--a-success); }
.kpi .delta.warn { color: var(--a-warn); }
.kpi .icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(7,49,26,.08);
  color: var(--a-primary);
  display: inline-flex; align-items: center; justify-content: center;
  float: right;
}

/* ---------- CARDS ---------- */
.card {
  background: #fff;
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.card h2 {
  font-family: "Fraunces", serif;
  font-size: 1.2rem;
  margin: 0 0 .25rem;
  letter-spacing: -.01em;
}
.card .desc { color: var(--a-ink-mute); margin: 0 0 1rem; font-size: .9rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
@media (max-width: 720px) { .card-grid { grid-template-columns: 1fr; } }

/* ---------- TABLES ---------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--a-radius);
  overflow: hidden;
  border: 1px solid var(--a-border);
}
.tbl th, .tbl td {
  text-align: left;
  padding: .85rem 1rem;
  font-size: .9rem;
  border-bottom: 1px solid var(--a-border);
}
.tbl th {
  background: #faf8f3;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--a-ink-mute);
  font-weight: 700;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fbfaf6; }
.tbl .row-actions {
  display: flex;
  gap: .4rem;
}
.tbl .status {
  display: inline-flex;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.tbl .status.published { background: rgba(29,138,77,.12); color: var(--a-success); }
.tbl .status.draft { background: rgba(208,138,38,.14); color: var(--a-warn); }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .75rem;
}
.search {
  position: relative;
}
.search input {
  padding: .55rem .85rem .55rem 2.2rem;
  border: 1px solid var(--a-border);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  min-width: 240px;
}
.search svg {
  position: absolute;
  left: .65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--a-ink-mute);
}

/* ---------- EDITOR PANE ---------- */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 980px) { .editor-grid { grid-template-columns: 1fr; } }

.editor-fields .field {
  margin-bottom: 1rem;
}
.editor-fields label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  color: var(--a-ink-soft);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .4rem;
}
.editor-fields input,
.editor-fields textarea,
.editor-fields select {
  width: 100%;
  padding: .65rem .85rem;
  border: 1px solid var(--a-border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  font-size: .95rem;
  transition: border-color .2s, box-shadow .2s;
}
.editor-fields textarea { min-height: 110px; resize: vertical; font-family: inherit; }
.editor-fields input:focus,
.editor-fields textarea:focus,
.editor-fields select:focus {
  outline: none;
  border-color: var(--a-primary);
  box-shadow: 0 0 0 3px rgba(7,49,26,.1);
}
.editor-fields .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .editor-fields .row-2 { grid-template-columns: 1fr; } }

.sticky-side {
  position: sticky;
  top: 88px;
}
.publish-box, .meta-box {
  background: #fff;
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.publish-box h3, .meta-box h3 {
  margin: 0 0 .75rem;
  font-family: "Fraunces", serif;
  font-size: 1rem;
}
.publish-box .row {
  display: flex;
  justify-content: space-between;
  padding: .35rem 0;
  font-size: .85rem;
  color: var(--a-ink-soft);
  border-bottom: 1px solid var(--a-border);
}
.publish-box .row:last-child { border-bottom: none; }
.publish-box .actions {
  display: flex;
  gap: .5rem;
  margin-top: .75rem;
}

/* ---------- THEME COLOR PICKER ---------- */
.color-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--a-border);
}
.color-row:last-child { border-bottom: none; }
.color-row .sw {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--a-border);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.color-row .sw input {
  position: absolute; inset: 0;
  opacity: 0;
  cursor: pointer;
}
.color-row .meta {
  flex: 1;
}
.color-row .meta strong { display: block; font-size: .92rem; }
.color-row .meta code {
  font-family: "JetBrains Mono", monospace;
  font-size: .78rem;
  color: var(--a-ink-mute);
}

/* ---------- MEDIA LIBRARY ---------- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.media-card {
  background: #fff;
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius);
  overflow: hidden;
}
.media-card .thumb {
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
  background-color: #faf8f3;
}
.media-card .meta { padding: .65rem; font-size: .8rem; }
.media-card strong { display: block; font-size: .85rem; }
.media-card small { color: var(--a-ink-mute); }
.media-add {
  background: rgba(7,49,26,.04);
  border: 2px dashed var(--a-border);
  border-radius: var(--a-radius);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: .35rem;
  color: var(--a-primary);
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.media-add:hover { background: rgba(7,49,26,.08); border-color: var(--a-primary); }

/* ---------- MENU MANAGER ---------- */
.menu-list { list-style: none; padding: 0; margin: 0; }
.menu-item {
  background: #fff;
  border: 1px solid var(--a-border);
  border-radius: 8px;
  padding: .75rem 1rem;
  margin-bottom: .5rem;
  display: grid;
  grid-template-columns: 24px 1fr 1fr auto;
  gap: .75rem;
  align-items: center;
}
.menu-item .handle {
  color: var(--a-ink-mute);
  cursor: grab;
  user-select: none;
  font-size: 1rem;
}
.menu-item input {
  padding: .4rem .65rem;
  border: 1px solid var(--a-border);
  border-radius: 6px;
  font: inherit;
  font-size: .85rem;
}
.menu-item .rm {
  background: transparent;
  border: none;
  color: var(--a-danger);
  font-weight: 600;
  font-size: .8rem;
}

/* ---------- TABS ---------- */
.tabs {
  display: flex;
  gap: .25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--a-border);
  flex-wrap: wrap;
}
.tabs button {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: .65rem 1rem;
  color: var(--a-ink-mute);
  font-weight: 600;
  font-size: .9rem;
  transition: color .2s, border-color .2s;
}
.tabs button.active {
  color: var(--a-primary);
  border-bottom-color: var(--a-primary);
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--a-primary);
  color: #fff;
  padding: .85rem 1.25rem;
  border-radius: 10px;
  box-shadow: var(--a-shadow-lg);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: .55rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translateY(0); }
.toast.danger { background: var(--a-danger); }
.toast.success { background: var(--a-success); }

/* ---------- MODAL ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7,49,26,.5);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-backdrop.is-on { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px;
  max-width: 540px;
  width: 100%;
  padding: 1.5rem;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 {
  font-family: "Fraunces", serif;
  font-size: 1.4rem;
  margin: 0 0 .5rem;
  letter-spacing: -.02em;
}
.modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: 1.25rem;
}

/* Mobile menu toggle */
.mobile-menu-toggle {
  display: none;
  border: 1px solid var(--a-border);
  background: #fff;
  border-radius: 8px;
  padding: .35rem .65rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--a-ink);
}
@media (max-width: 880px) {
  .mobile-menu-toggle { display: inline-flex; align-items: center; gap: .35rem; }
  .sidebar { display: none; }
  .sidebar.is-open { display: flex; }
}
