/* ============================================================
   GitCMS — Stylesheet
   Aesthetic: editorial dashboard, warm paper + ink, emerald accent
   ============================================================ */

:root {
  /* Palette */
  --paper: #f7f5f0;
  --surface: #ffffff;
  --ink: #1a1a18;
  --ink-soft: #4a4843;
  --ink-mute: #8a877e;
  --line: #e5e1d8;
  --line-soft: #efece4;
  --accent: #1f7a4d;
  --accent-dark: #155c39;
  --accent-soft: #e8f3ed;
  --danger: #c0392b;
  --danger-soft: #fbeae8;
  --amber: #b8801f;

  /* Type */
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* Misc */
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(26, 26, 24, 0.06);
  --shadow-md: 0 4px 16px rgba(26, 26, 24, 0.08);
  --shadow-lg: 0 12px 40px rgba(26, 26, 24, 0.14);
  --sidebar-w: 248px;
}

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

html, body {
  height: 100%;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.55;
}

.hidden { display: none !important; }

/* Input file tetap ada di DOM agar tombol upload bekerja konsisten di browser
   desktop/mobile, tetapi tidak mengganggu layout admin. */
.visually-hidden-file {
  position: fixed;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.16s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface); border-color: var(--ink-mute); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a02e22; }
.btn-block { width: 100%; }
.btn-icon { padding: 10px 12px; font-size: 16px; }

.btn-small {
  padding: 8px 11px;
  font-size: 12px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------- Form fields ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.field-hint { display: block; margin-top: 6px; font-size: 12px; color: var(--ink-mute); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

input[type="text"], input[type="password"], input[type="date"],
select, textarea {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 14.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; line-height: 1.5; }
::placeholder { color: var(--ink-mute); }

/* ============================================================
   AUTH SCREENS (login + setup)
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(31, 122, 77, 0.05), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(184, 128, 31, 0.04), transparent 45%),
    var(--paper);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--ink);
  color: var(--paper);
  border-radius: 9px;
  font-size: 22px;
  font-weight: 600;
}
.brand-name {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.auth-tagline { color: var(--ink-soft); font-size: 14.5px; margin: 12px 0 28px; line-height: 1.55; }
.auth-footer { margin-top: 24px; font-size: 12.5px; color: var(--ink-mute); text-align: center; }

.auth-help { margin-top: 20px; font-size: 13px; }
.auth-help summary { cursor: pointer; color: var(--accent); font-weight: 600; user-select: none; }
.auth-help summary:hover { color: var(--accent-dark); }
.auth-help ol { margin: 14px 0 0 4px; padding-left: 20px; color: var(--ink-soft); line-height: 1.7; }
.auth-help li { margin-bottom: 4px; }

.user-pill {
  display: flex; align-items: center; gap: 10px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 22px;
  font-size: 13.5px;
  color: var(--accent-dark);
  font-weight: 500;
}
.user-pill img { width: 28px; height: 28px; border-radius: 50%; }

/* ============================================================
   APP SHELL (sidebar + main)
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 0 8px 24px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(247, 245, 240, 0.1);
}
.sidebar-brand .brand-mark { width: 34px; height: 34px; font-size: 18px; background: var(--accent); }
.sidebar-brand .brand-name { color: var(--paper); font-size: 21px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 14px; flex: 1; }
.sidebar-footer { display: flex; flex-direction: column; gap: 3px; border-top: 1px solid rgba(247,245,240,0.1); padding-top: 14px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  background: transparent;
  border: none;
  color: rgba(247, 245, 240, 0.66);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.14s ease;
  text-align: left;
}
.nav-item:hover { background: rgba(247, 245, 240, 0.07); color: var(--paper); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 16px; width: 18px; text-align: center; display: inline-block; }

.repo-badge {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: rgba(247, 245, 240, 0.5);
  padding: 8px 12px;
  word-break: break-all;
  line-height: 1.4;
}

.main-area { flex: 1; padding: 32px 40px; max-width: 1400px; overflow-x: hidden; }

/* ---------- Panel header ---------- */
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.panel-title { font-family: var(--font-display); font-size: 30px; font-weight: 500; letter-spacing: -0.01em; }
.panel-sub { color: var(--ink-mute); font-size: 14px; margin-top: 3px; }
.panel-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ---------- Search ---------- */
.search-bar { margin-bottom: 22px; }
.search-bar input { max-width: 480px; }

/* ============================================================
   ARTICLE LIST
   ============================================================ */
.article-list { display: flex; flex-direction: column; gap: 10px; }
.article-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all 0.16s ease;
  box-shadow: var(--shadow-sm);
}
.article-card:hover { border-color: var(--ink-mute); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.article-info { flex: 1; min-width: 0; cursor: pointer; }
.article-info h3 {
  font-size: 16.5px;
  font-weight: 600;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.article-meta { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--ink-mute); flex-wrap: wrap; }
.article-meta .mono { font-family: var(--font-mono); font-size: 12px; }
.status-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-published { background: var(--accent-soft); color: var(--accent-dark); }
.status-draft { background: #f3efe2; color: var(--amber); }
.article-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------- Empty / loading states ---------- */
.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--ink-mute);
}
.empty-state .empty-icon { font-size: 44px; opacity: 0.4; margin-bottom: 14px; }
.empty-state h3 { font-family: var(--font-display); font-size: 21px; font-weight: 500; color: var(--ink-soft); margin-bottom: 6px; }
.empty-state p { font-size: 14px; max-width: 360px; margin: 0 auto 18px; }

.skeleton-card {
  height: 78px;
  background: linear-gradient(90deg, var(--line-soft) 25%, #f3f0e8 50%, var(--line-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ============================================================
   EDITOR
   ============================================================ */
.editor-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.editor-main { min-width: 0; }
.title-input {
  font-family: var(--font-display) !important;
  font-size: 26px !important;
  font-weight: 500 !important;
  border: none !important;
  border-bottom: 2px solid var(--line) !important;
  border-radius: 0 !important;
  padding: 8px 2px 14px !important;
  margin-bottom: 18px;
  background: transparent !important;
}
.title-input:focus { box-shadow: none !important; border-bottom-color: var(--accent) !important; }

.editor-meta { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 24px; }
.meta-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.meta-card-muted { background: var(--line-soft); border-style: dashed; }
.meta-card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  margin-bottom: 16px;
}
.meta-card .field:last-child { margin-bottom: 0; }
.meta-filename { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-soft); word-break: break-all; }


/* ---------- Featured image uploader ---------- */
.field-featured-image { margin-top: 4px; }
.featured-preview {
  width: 100%;
  min-height: 142px;
  margin-bottom: 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--line-soft);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.featured-preview img {
  width: 100%;
  height: 168px;
  object-fit: cover;
  display: block;
}
.featured-preview-empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--ink-mute);
  font-size: 13px;
}
.featured-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.featured-actions .btn { flex: 1 1 auto; }

/* EasyMDE overrides */
.EasyMDEContainer .CodeMirror {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
  min-height: 420px;
}
.EasyMDEContainer .editor-toolbar {
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
}
.EasyMDEContainer .CodeMirror { border-radius: 0 0 var(--radius) var(--radius); }
.editor-toolbar button:hover { background: var(--line-soft); border-color: var(--line); }
.editor-toolbar button.active { background: var(--accent-soft); }
.editor-preview { background: var(--paper) !important; font-family: var(--font-ui); }

/* ============================================================
   MEDIA GRID
   ============================================================ */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}
.media-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.16s ease;
}
.media-item:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.media-thumb { width: 100%; height: 130px; object-fit: cover; display: block; background: var(--line-soft); }
.media-body { padding: 11px 13px; }
.media-name {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}
.media-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.media-actions button {
  flex: 1;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.14s;
}
.media-actions button:hover { background: var(--line-soft); border-color: var(--ink-mute); color: var(--ink); }

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  animation: toast-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.toast-out { animation: toast-out 0.24s forwards; }
.toast-success { border-left: 3px solid #3ecf7e; }
.toast-error { border-left: 3px solid #ff6b5e; }
.toast-info { border-left: 3px solid #5eb3ff; }
.toast-icon { font-size: 15px; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px); } }

/* ============================================================
   LOADER
   ============================================================ */
.loader {
  position: fixed;
  inset: 0;
  background: rgba(247, 245, 240, 0.78);
  backdrop-filter: blur(3px);
  z-index: 8000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
}
.loader-spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 24, 0.45);
  z-index: 7000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade-in 0.18s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal h3 { font-family: var(--font-display); font-size: 22px; font-weight: 500; margin-bottom: 10px; }
.modal p { color: var(--ink-soft); font-size: 14.5px; margin-bottom: 24px; line-height: 1.55; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   SITE SETTINGS PANEL
   ============================================================ */
.settings-wrap {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 640px;
}
.settings-note { font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; margin: 0; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-meta { position: static; }
  .main-area { padding: 24px 20px; }
}
@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 12px 16px; gap: 6px;
  }
  .sidebar-brand { border: none; padding: 0; margin: 0 auto 0 0; }
  .sidebar-nav { flex-direction: row; margin: 0; flex: 0; }
  .sidebar-footer { flex-direction: row; border: none; padding: 0; }
  .repo-badge { display: none; }
  .nav-item span:not(.nav-icon) { display: none; }
  .panel-header { flex-direction: column; }
  .field-row { grid-template-columns: 1fr; }
}

/* ============================================================
   CATEGORY MANAGER
   ============================================================ */
.category-manager-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.category-form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.category-note { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.category-list-admin { display: grid; gap: 10px; }
.category-admin-item {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.category-admin-title { font-weight: 700; color: var(--ink); }
.category-admin-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; color: var(--ink-mute); font-size: 12.5px; }
.category-admin-desc { color: var(--ink-soft); font-size: 13.5px; margin-top: 7px; line-height: 1.45; }
.category-admin-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.category-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
}

@media (max-width: 900px) {
  .category-manager-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .category-admin-item { grid-template-columns: 1fr; }
  .category-admin-actions { justify-content: flex-start; }
}

/* ============================================================
   MENU & ADS SETTINGS
   ============================================================ */
.checkbox-field {
  display: flex;
  align-items: end;
}
.check-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.check-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.menu-list-admin .mono {
  overflow-wrap: anywhere;
}
.ads-settings-wrap {
  max-width: 1120px;
}
.ads-master-toggle {
  margin-bottom: 8px;
}
.ad-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.ad-setting-card {
  min-width: 0;
}
.ad-setting-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.ad-setting-head .meta-card-title {
  margin-bottom: 0;
}
.html-textarea {
  width: 100%;
  min-height: 142px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
  white-space: pre;
  overflow: auto;
}

@media (max-width: 1000px) {
  .ad-settings-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   LOGO & FAVICON SETTINGS
   ============================================================ */
.brand-asset-field {
  gap: 10px;
}
.brand-preview,
.favicon-preview {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  min-height: 96px;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: hidden;
}
.brand-preview img {
  max-width: 260px;
  max-height: 82px;
  object-fit: contain;
}
.favicon-preview {
  width: 104px;
  height: 104px;
  min-height: 104px;
}
.favicon-preview img {
  max-width: 64px;
  max-height: 64px;
  object-fit: contain;
}
.brand-preview-empty {
  color: var(--ink-mute);
  font-size: 13px;
  font-weight: 700;
}

/* ---------- V7: Highlight & homepage category block controls ---------- */
.status-highlight {
  background: #fff1c2;
  color: #8a5a00;
}
.highlight-checkbox-field {
  display: block;
  padding: 12px 13px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: #fffaf0;
}
.category-count-pill.is-on {
  background: #dff6ec;
  color: #0f6a43;
}
.category-count-pill.is-off {
  background: #f2e8e8;
  color: #a33a3a;
}
