/* Teroka Portfolio CMS — admin */
:root {
  --red: #ED1C24;
  --red-dark: #C5141B;
  --ink: #111111;
  --ink-2: #3d3d3d;
  --muted: #6f6f6f;
  --line: #e7e7e7;
  --bg: #f6f6f5;
  --card: #ffffff;
  --ok-bg: #edf8f0; --ok-ink: #17602f;
  --err-bg: #fdeeee; --err-ink: #9b1219;
  --warn-bg: #fff6e5; --warn-ink: #7a4b00;
  --radius: 12px;
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 500;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.55; }
a { color: var(--ink); }
h1, h2 { font-weight: 700; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 16px; margin-bottom: 14px; }
code { background: #f0f0f0; padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.req { color: var(--red); }
.warn-text { color: var(--red-dark); }
.sr-default { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Bolt mark */
.bolt { display: inline-block; width: 14px; height: 22px; background: var(--red);
  clip-path: polygon(60% 0, 0 58%, 42% 58%, 30% 100%, 100% 40%, 58% 40%, 80% 0); margin-right: 8px; vertical-align: -4px; }

/* Topbar */
.topbar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 24px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand small { font-weight: 500; opacity: .55; margin-left: 4px; }
.nav { display: flex; gap: 4px; }
.nav a { color: #bbb; text-decoration: none; padding: 7px 12px; border-radius: 8px; }
.nav a:hover { color: #fff; background: #222; }
.nav a.on { color: #fff; background: #262626; box-shadow: inset 0 -2px 0 var(--red); }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.topbar-right form { margin: 0; }
.topbar .btn.ghost { color: #ddd; border-color: #333; background: transparent; }
.topbar .btn.ghost:hover { border-color: #666; color: #fff; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 500;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: #bdbdbd; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.btn.primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red-dark); border-color: #f3c4c6; background: #fff; }
.btn.danger:hover { background: var(--err-bg); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn.block { width: 100%; }
.icon-btn { font: inherit; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.icon-btn:hover:not(:disabled) { border-color: #bdbdbd; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--red); outline-offset: 2px; }

/* Alerts */
.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; }
.alert.ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert.err { background: var(--err-bg); color: var(--err-ink); }
.alert.warn { background: var(--warn-bg); color: var(--warn-ink); }

/* Forms */
.form fieldset { border: 0; padding: 0; margin: 0 0 18px; }
.form legend { font-weight: 700; margin-bottom: 10px; }
.field { display: block; margin-bottom: 14px; font-size: 13px; color: var(--ink-2); }
.field input:not([type=checkbox]), .field select, .field textarea, .toolbar input, .toolbar select, .inline-add input, .cat-row input {
  display: block; width: 100%; margin-top: 5px; font: inherit; font-size: 14px; color: var(--ink);
  padding: 10px 12px; border: 1px solid #dcdcdc; border-radius: 9px; background: #fff; }
.field textarea { resize: vertical; }
.field input[type=file] { padding: 8px; }
.counter { display: block; text-align: right; margin-top: 3px; }
.check { display: flex; gap: 10px; align-items: center; margin: 10px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--red); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.card.narrow { max-width: 720px; }

/* Toolbar */
.toolbar { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar input { flex: 1 1 240px; margin: 0; }
.toolbar select { width: auto; margin: 0; }

/* Project list */
.plist { display: grid; gap: 10px; }
.prow { display: grid; grid-template-columns: 136px 1fr auto; gap: 18px; align-items: center; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.prow.is-draft { background: #fbfbfb; }
.prow.is-draft .pthumb img { opacity: .5; filter: grayscale(.6); }
.pthumb { display: block; aspect-ratio: 16/10; border-radius: 8px; overflow: hidden; background: #efefef;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-decoration: none; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.ptitle { font-weight: 700; font-size: 15px; text-decoration: none; display: block; margin: 3px 0 2px; }
.ptitle:hover { color: var(--red); }
.pmeta { font-size: 13px; }
.pmeta a { color: var(--muted); }
.ptags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #f1f1f1; color: var(--ink-2); }
.tag.draft { background: var(--ink); color: #fff; }
.tag.feat { background: #fff0f0; color: var(--red-dark); }
.pactions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; padding-right: 6px; }
.pactions form { display: flex; gap: 6px; margin: 0; }

.empty { text-align: center; padding: 60px 20px; background: #fff; border: 1px dashed #d6d6d6; border-radius: var(--radius); }
.empty h2 { font-size: 20px; margin-bottom: 6px; }
.empty p { margin: 0 0 18px; }

/* Edit */
.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.col-side { position: sticky; top: 76px; }
.sticky-save { position: sticky; bottom: 16px; }
.sticky-save.wide { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.img-item { margin: 0; position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fafafa; }
.img-item.is-cover { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.img-item img { width: 100%; aspect-ratio: 16/10; object-fit: cover; object-position: top; display: block; }
.img-item figcaption { display: flex; gap: 4px; padding: 7px; flex-wrap: wrap; align-items: center; }
.img-item .icon-btn { width: 26px; height: 26px; font-size: 12px; }
.cover-badge { position: absolute; top: 8px; left: 8px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 26px; border: 2px dashed #d3d3d3;
  border-radius: 12px; text-align: center; cursor: pointer; background: #fcfcfc; position: relative; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--red); background: #fff7f7; }
.dropzone.has-files { border-style: solid; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.preview figure { margin: 0; font-size: 11px; color: var(--muted); }
.preview img { width: 100%; aspect-ratio: 16/10; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--line); }
.preview figcaption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview .too-big { color: var(--red-dark); }
.preview p { grid-column: 1 / -1; margin: 0; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 30px;
  padding: 18px 22px; border: 1px solid #f3c4c6; border-radius: var(--radius); background: #fff; }
.danger-zone p { margin: 2px 0 0; }

/* Kategori */
.inline-add { display: flex; gap: 8px; margin-bottom: 16px; }
.inline-add input { margin: 0; }
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { border-top: 1px solid var(--line); }
.cat-row { display: flex; gap: 8px; align-items: center; padding: 10px 0; margin: 0; }
.cat-row input { margin: 0; flex: 1; }
.cat-row .order { display: flex; gap: 4px; }
.cat-row .count { width: 70px; text-align: right; white-space: nowrap; }

/* Tetapan */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; align-items: start; }
.logo-preview { background: repeating-conic-gradient(#f2f2f2 0 25%, #fff 0 50%) 0 0/16px 16px; border: 1px solid var(--line);
  border-radius: 10px; padding: 16px; margin-bottom: 12px; text-align: center; }
.logo-preview img { max-height: 70px; max-width: 100%; }

/* Auth */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px; }
.auth-card.wide { max-width: 520px; }
.auth-card h1 { font-size: 22px; margin: 18px 0 8px; }
.auth-brand { font-weight: 700; }
.auth-card .back { display: block; text-align: center; margin-top: 16px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .edit-grid, .settings-grid { grid-template-columns: 1fr; }
  .col-side { position: static; }
  .prow { grid-template-columns: 100px 1fr; }
  .pactions { grid-column: 1 / -1; justify-content: flex-start; padding: 0; }
}
@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .topbar-right .btn.ghost:first-child { display: none; }
  .wrap { padding: 20px 16px 60px; }
  .two { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .cat-row { flex-wrap: wrap; }
  .cat-row input { flex-basis: 100%; order: -1; }
  .danger-zone { flex-direction: column; align-items: flex-start; }
}
