/* ============================================================
   admin.css — admin panel UI (matches the site's dark/glass aesthetic)
   ============================================================ */

:root {
  --bg-0:#05060d; --bg-1:#08091a; --bg-2:#0c0e22;
  --panel: rgba(15, 18, 40, 0.55);
  --panel-2: rgba(15, 18, 40, 0.85);
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.16);
  --text:#e9ecff; --text-dim:#a8b0d6; --text-mute:#6b7299;
  --blue:#4d8dff; --blue-bright:#6aa1ff; --purple:#a855f7; --cyan:#22d3ee; --cyan-soft:#67e8f9;
  --good:#22c55e; --warn:#f59e0b; --bad:#ef4444;
  --f-display:"Space Grotesk", system-ui, sans-serif;
  --f-body:"Space Grotesk", system-ui, sans-serif;
  --f-mono:"JetBrains Mono", ui-monospace, monospace;
  --sidebar-w: 240px;
  --header-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--f-body);
  background: var(--bg-1);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
::selection { background: rgba(77,141,255,0.4); color: #fff; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: rgba(5,6,13,0.5);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  width: 100%;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(106,161,255,0.55);
  background: rgba(5,6,13,0.8);
  box-shadow: 0 0 0 3px rgba(77,141,255,0.10);
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-mute); }

/* Decor */
.bg-mesh {
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(60% 50% at 80% 0%,   rgba(124,58,237,0.18), transparent 70%),
    radial-gradient(50% 50% at 0% 30%,   rgba(34,211,238,0.10), transparent 70%),
    radial-gradient(60% 60% at 50% 100%, rgba(77,141,255,0.12), transparent 70%),
    var(--bg-1);
}
.bg-grid {
  position: fixed; inset: 0; z-index: -1;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 30%, #000 30%, transparent 90%);
}

/* ============================================================
   LAYOUT
   ============================================================ */

.app {
  display: grid;
  grid-template-rows: var(--header-h) 1fr;
  height: 100vh;
}
.app-header {
  display: flex; align-items: center; gap: 16px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 6, 13, 0.6);
  backdrop-filter: blur(14px);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}
.brand .sub {
  font-family: var(--f-mono); font-size: 11px;
  color: var(--text-mute);
  margin-left: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.save-status {
  margin-left: 20px;
  font-family: var(--f-mono); font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
  transition: color .2s;
}
.save-status .pip {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-mute);
  transition: background .2s, box-shadow .2s;
}
.save-status.saving { color: var(--warn); }
.save-status.saving .pip { background: var(--warn); box-shadow: 0 0 8px var(--warn); animation: blink 1s infinite; }
.save-status.saved  { color: var(--good); }
.save-status.saved  .pip { background: var(--good); box-shadow: 0 0 8px var(--good); }
@keyframes blink { 50% { opacity: 0.4; } }

.app-header-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  transition: border-color .2s, background .2s, transform .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--line-strong); background: rgba(255,255,255,0.07); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 18px rgba(77,141,255,0.3);
}
.btn.primary:hover { box-shadow: 0 6px 22px rgba(77,141,255,0.5); }
.btn.danger { color: var(--bad); border-color: rgba(239,68,68,0.3); }
.btn.danger:hover { background: rgba(239,68,68,0.08); border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.icon { padding: 7px; }
.btn svg { width: 14px; height: 14px; }

.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  overflow-y: auto;
  background: rgba(5, 6, 13, 0.3);
}
.sidebar h4 {
  font-family: var(--f-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-mute);
  padding: 14px 10px 8px;
  font-weight: 500;
}
.sidebar h4:first-child { padding-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  border: 1px solid transparent;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active {
  background: rgba(77,141,255,0.10);
  color: var(--text);
  border-color: rgba(77,141,255,0.3);
}
.nav-item .ic { width: 14px; height: 14px; display: grid; place-items: center; color: var(--text-mute); }
.nav-item.active .ic { color: var(--cyan-soft); }
.nav-item svg { width: 14px; height: 14px; }

/* Main editor */
.editor {
  overflow-y: auto;
  padding: 32px clamp(20px, 4vw, 56px) 80px;
}
.editor-wrap { max-width: 880px; margin: 0 auto; }
.editor-header {
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.editor-header h1 {
  font-family: var(--f-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.editor-header p {
  color: var(--text-dim);
  font-size: 14px;
  max-width: 560px;
}

/* Fields & cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 18px;
  backdrop-filter: blur(10px);
}
.card-title {
  font-family: var(--f-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 10px;
}
.card-title .num {
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--text-mute);
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid var(--line);
  letter-spacing: 0.1em;
}
.card-sub {
  color: var(--text-mute);
  font-size: 12.5px;
  margin-bottom: 18px;
}
.card-actions {
  display: flex; gap: 8px; align-items: center;
  margin-left: auto;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 7px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.field-row.thirds { grid-template-columns: 1fr 1fr 1fr; }

/* Repeater */
.repeater-item {
  background: rgba(5,6,13,0.4);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
}
.repeater-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.repeater-head .label {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.repeater-actions { display: flex; gap: 4px; }
.repeater-add {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  width: 100%;
  justify-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--text-dim);
  background: transparent;
  transition: border-color .2s, color .2s, background .2s;
}
.repeater-add:hover {
  border-color: rgba(106,161,255,0.6);
  color: var(--text);
  background: rgba(77,141,255,0.06);
}

/* Tag input (skills.badges, post.tags, services.stack) */
.tag-input {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px;
  background: rgba(5,6,13,0.5);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  align-items: center;
}
.tag-input:focus-within { border-color: rgba(106,161,255,0.55); }
.tag-input .tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: rgba(77,141,255,0.12);
  border: 1px solid rgba(77,141,255,0.3);
  color: var(--blue-bright);
  border-radius: 100px;
  font-family: var(--f-mono);
  font-size: 11.5px;
}
.tag-input .tag button {
  color: inherit;
  opacity: 0.6;
  font-size: 13px;
  line-height: 1;
}
.tag-input .tag button:hover { opacity: 1; }
.tag-input input {
  flex: 1;
  min-width: 100px;
  border: 0;
  padding: 4px;
  background: transparent;
}
.tag-input input:focus { box-shadow: none; }

/* Icon picker (services) */
.icon-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.icon-picker button {
  aspect-ratio: 1;
  border-radius: 8px;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  transition: border-color .15s, background .15s;
}
.icon-picker button:hover { border-color: var(--line-strong); background: rgba(255,255,255,0.07); }
.icon-picker button.sel {
  border-color: rgba(106,161,255,0.6);
  background: rgba(77,141,255,0.1);
  color: var(--cyan-soft);
}
.icon-picker button svg { width: 18px; height: 18px; stroke: currentColor; color: var(--text-dim); }
.icon-picker button.sel svg { color: var(--cyan-soft); }

/* Cover color picker (blog) */
.cover-picker { display: flex; gap: 8px; }
.cover-picker button {
  flex: 1;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  transition: transform .15s, border-color .15s;
}
.cover-picker button.sel {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(106,161,255,0.5);
}
.cover-picker button.cv-blue   { background: linear-gradient(135deg, #4d8dff, #1e3a8a); }
.cover-picker button.cv-purple { background: linear-gradient(135deg, #a855f7, #4c1d95); }
.cover-picker button.cv-cyan   { background: linear-gradient(135deg, #22d3ee, #0e7490); }
.cover-picker button.cv-pink   { background: linear-gradient(135deg, #f472b6, #831843); }
.cover-picker button.cv-mix    { background: linear-gradient(135deg, #4d8dff, #a855f7, #22d3ee); }

/* ============================================================
   BLOG section (post list + editor)
   ============================================================ */

.blog-toolbar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 18px;
}
.blog-toolbar .search {
  flex: 1;
  position: relative;
}
.blog-toolbar .search input { padding-left: 36px; }
.blog-toolbar .search svg {
  position: absolute; top: 50%; left: 12px;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  stroke: var(--text-mute);
}

.post-list { display: flex; flex-direction: column; gap: 8px; }
.post-row {
  display: grid;
  grid-template-columns: 56px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.post-row:hover { border-color: var(--line-strong); background: rgba(15, 18, 40, 0.75); }
.post-row .thumb {
  width: 56px; height: 40px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 22px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.post-row .info .ttl {
  font-family: var(--f-display);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  line-height: 1.3;
}
.post-row .info .meta {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.05em;
}
.post-row .info .meta .dot { opacity: 0.4; margin: 0 6px; }
.post-row .tags { display: flex; gap: 4px; flex-wrap: wrap; max-width: 200px; justify-content: flex-end; }
.post-row .tags span {
  font-family: var(--f-mono);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 100px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: var(--text-mute);
}

/* Editor (split markdown) */
.post-editor {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.post-editor .field { margin: 0; }
.editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-height: 480px;
}
.editor-split textarea {
  font-family: var(--f-mono);
  font-size: 13px;
  line-height: 1.7;
  min-height: 480px;
  background: rgba(5,6,13,0.7);
}
.preview-pane {
  padding: 22px 24px;
  background: rgba(5,6,13,0.4);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-y: auto;
  max-height: 580px;
  color: var(--text-dim);
  line-height: 1.65;
}
.preview-pane h1 { font-family: var(--f-display); font-size: 24px; color: var(--text); margin: 18px 0 10px; letter-spacing: -0.02em; }
.preview-pane h2 { font-family: var(--f-display); font-size: 19px; color: var(--text); margin: 22px 0 8px; letter-spacing: -0.015em; }
.preview-pane h3 { font-family: var(--f-display); font-size: 16px; color: var(--text); margin: 18px 0 6px; }
.preview-pane h1:first-child, .preview-pane h2:first-child { margin-top: 0; }
.preview-pane p { margin-bottom: 12px; font-size: 14px; }
.preview-pane ul, .preview-pane ol { margin: 0 0 14px 22px; }
.preview-pane li { margin-bottom: 4px; font-size: 14px; }
.preview-pane strong { color: var(--text); }
.preview-pane em { color: var(--cyan-soft); font-style: normal; }
.preview-pane code {
  font-family: var(--f-mono); font-size: 12px;
  background: rgba(255,255,255,0.06);
  padding: 1px 5px; border-radius: 4px;
  color: var(--cyan-soft);
  border: 1px solid var(--line);
}
.preview-pane blockquote {
  border-left: 2px solid var(--blue);
  background: rgba(77,141,255,0.06);
  padding: 10px 14px;
  margin: 14px 0;
  font-style: italic;
  color: var(--text);
}
.preview-pane blockquote p { margin: 0; }
.preview-pane a { color: var(--cyan-soft); border-bottom: 1px solid rgba(34,211,238,0.3); }

.md-toolbar {
  display: flex; gap: 4px;
  margin-bottom: 6px;
  padding: 6px;
  background: rgba(5,6,13,0.5);
  border: 1px solid var(--line);
  border-radius: 8px;
  flex-wrap: wrap;
}
.md-toolbar button {
  font-family: var(--f-mono);
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 5px;
  color: var(--text-dim);
  transition: background .15s, color .15s;
}
.md-toolbar button:hover { background: rgba(255,255,255,0.06); color: var(--text); }

.empty {
  text-align: center;
  padding: 60px 30px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--text-mute);
}
.empty .em-title {
  font-family: var(--f-display);
  font-size: 16px;
  color: var(--text);
  margin-bottom: 6px;
  font-weight: 500;
}

/* Backup tab */
.backup-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.json-pre {
  font-family: var(--f-mono);
  font-size: 11.5px;
  background: rgba(5,6,13,0.7);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--cyan-soft);
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: rgba(15,18,40,0.95);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  display: flex; align-items: center; gap: 10px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s, opacity .25s;
  z-index: 200;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.good { border-color: rgba(34,197,94,0.4); }
.toast.bad  { border-color: rgba(239,68,68,0.4); color: #fca5a5; }

/* Mobile */
@media (max-width: 800px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: var(--header-h) 0 auto 0;
    z-index: 50;
    background: rgba(5,6,13,0.95);
    border-bottom: 1px solid var(--line);
    display: none;
  }
  .sidebar.open { display: block; }
  .editor-split { grid-template-columns: 1fr; }
  .field-row, .field-row.thirds { grid-template-columns: 1fr; }
  .post-row { grid-template-columns: 48px 1fr auto; }
  .post-row .tags { display: none; }
}
