@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap");

/* ─── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-base:      #0f172a;
    --bg-surface:   #1e293b;
    --bg-elevated:  #273548;
    --border:       #334155;
    --text-primary: #e2e8f0;
    --text-muted:   #94a3b8;
    --text-dim:     #64748b;
    --accent:       #6366f1;
    --accent-hover: #818cf8;
    --success:      #22c55e;
    --warning:      #f59e0b;
    --danger:       #f87171;
    --radius-sm:    4px;
    --radius:       8px;
    --radius-lg:    12px;
    --radius-pill:  999px;
    --shadow:       0 4px 24px rgba(0,0,0,0.4);
    --font:         'JetBrains Mono', ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
    --font-mono:    'JetBrains Mono', 'Fira Code', monospace;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Typography ────────────────────────────────────────────────────────────── */
h1,h2,h3,h4 { line-height: 1.3; font-weight: 600; }

/* ─── Layout ────────────────────────────────────────────────────────────────── */
.container { max-width: 860px; margin: 0 auto; padding: 0 1.5rem; }
.container-wide { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }

/* ─── Site Header ───────────────────────────────────────────────────────────── */
.site-header {
    border-bottom: 1px solid var(--border);
    background: rgba(15,23,42,0.95);
    backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 100;
}
.site-header .inner {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.5rem; max-width: 860px; margin: 0 auto;
}
.site-title {
    font-size: 1.1rem; font-weight: 700; color: var(--text-primary);
    letter-spacing: -0.02em;
}
.site-title span { color: var(--accent); }

/* ─── Toolbar ───────────────────────────────────────────────────────────────── */
.toolbar {
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
    padding: 1.25rem 0;
}
.toolbar select, .toolbar input[type=text] {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}
.toolbar select:focus, .toolbar input:focus { border-color: var(--accent); }

/* ─── Month Header ──────────────────────────────────────────────────────────── */
.month-header {
    display: flex; align-items: center; gap: 1rem;
    margin: 2rem 0 1.5rem;
}
.month-header h2 {
    font-size: 1.5rem; font-weight: 700; color: var(--text-primary);
}
.month-header .month-line {
    flex: 1; height: 1px; background: var(--border);
}

/* ─── Post Entry ────────────────────────────────────────────────────────────── */
.post-entry {
    margin-bottom: 2.5rem;
    border-left: 2px solid var(--border);
    padding-left: 1.5rem;
    position: relative;
}
.post-entry::before {
    content: '';
    position: absolute; left: -5px; top: 8px;
    width: 8px; height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

.post-date {
    font-size: 1rem; font-weight: 600;
    color: var(--text-primary); margin-bottom: 0.75rem;
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}
.post-date time { color: var(--text-muted); font-size: 0.85rem; font-weight: 400; }

/* ─── Pills ─────────────────────────────────────────────────────────────────── */
.pill-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }

.pill {
    display: inline-flex; align-items: center;
    padding: 0.2rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem; font-weight: 600;
    letter-spacing: 0.02em; text-transform: uppercase;
    border: 1px solid;
    cursor: default;
    transition: opacity 0.15s;
}

/* ─── Post Content (section-based) ─────────────────────────────────────────── */
.post-content { margin-top: 0.5rem; }

.post-section { margin-bottom: 1.25rem; }

.section-heading {
    display: inline-flex; align-items: center;
    padding: 0.25rem 0.85rem;
    border-radius: var(--radius-pill);
    font-size: 0.8rem; font-weight: 700;
    letter-spacing: 0.03em;
    margin-bottom: 0.6rem;
    border: 1px solid currentColor;
}

.section-items {
    list-style: none;
    padding-left: 0.5rem;
}
.section-items li {
    position: relative; padding-left: 1.25rem;
    color: var(--text-primary); font-size: 0.78rem;
    margin-bottom: 0.25rem; line-height: 1.6;
}
.section-items li::before {
    content: '–';
    position: absolute; left: 0;
    color: var(--text-dim);
}

/* ─── Embedded images in content ────────────────────────────────────────────── */
.post-content img {
    max-width: 100%; border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: zoom-in; transition: opacity 0.2s;
    margin: 0.5rem 0;
}
.post-content img:hover { opacity: 0.85; }

/* ─── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center; padding: 4rem 1rem;
    color: var(--text-dim);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { font-size: 1rem; }

/* ─── Lightbox ──────────────────────────────────────────────────────────────── */
.lightbox-overlay {
    display: none; position: fixed; inset: 0; z-index: 999;
    background: rgba(0,0,0,0.85);
    align-items: center; justify-content: center;
}
.lightbox-overlay.active { display: flex; }
.lightbox-overlay img {
    max-width: 90vw; max-height: 90vh;
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.lightbox-close {
    position: absolute; top: 1.5rem; right: 1.5rem;
    background: none; border: none; color: #fff;
    font-size: 2rem; cursor: pointer; line-height: 1;
}

/* ─── Login Page ────────────────────────────────────────────────────────────── */
.auth-wrap {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    padding: 2rem;
}
.auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    width: 100%; max-width: 400px;
    box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.auth-card .subtitle { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 2rem; }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block; font-size: 0.8rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 0.4rem;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.form-control {
    width: 100%; background: var(--bg-elevated);
    border: 1px solid var(--border); color: var(--text-primary);
    padding: 0.6rem 0.9rem; border-radius: var(--radius);
    font-size: 0.925rem; outline: none;
    transition: border-color 0.2s;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-dim); }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 1.25rem; border-radius: var(--radius);
    font-size: 0.875rem; font-weight: 600;
    cursor: pointer; border: 1px solid transparent;
    transition: all 0.15s; text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); text-decoration: none; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: rgba(248,113,113,0.1); text-decoration: none; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* ─── Flash Message ─────────────────────────────────────────────────────────── */
.flash-msg {
    padding: 0.8rem 1rem; border-radius: var(--radius);
    background: var(--bg-elevated); margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

/* ─── Admin Layout ──────────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px; flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 0 1.25rem 1.5rem;
    font-weight: 700; font-size: 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    color: var(--text-primary);
}
.sidebar-brand span { color: var(--accent); }

.nav-item {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.55rem 1.25rem; color: var(--text-muted);
    font-size: 0.875rem; font-weight: 500;
    transition: all 0.15s; border-left: 2px solid transparent;
    text-decoration: none;
}
.nav-item:hover { color: var(--text-primary); background: var(--bg-elevated); text-decoration: none; }
.nav-item.active { color: var(--accent-hover); border-left-color: var(--accent); background: rgba(99,102,241,0.08); }
.nav-icon { width: 18px; text-align: center; }

.admin-main { flex: 1; padding: 2rem; overflow-x: hidden; }
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p { color: var(--text-muted); font-size: 0.875rem; margin-top: 0.25rem; }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}
.card-sm { padding: 1rem 1.25rem; }

/* ─── Stats Grid ────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1.25rem;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.35rem; }

/* ─── Calendar ──────────────────────────────────────────────────────────────── */
.cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.cal-day-name {
    text-align: center; font-size: 0.7rem; color: var(--text-dim);
    padding: 0.3rem 0; font-weight: 600; text-transform: uppercase;
}
.cal-day {
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); font-size: 0.8rem;
    color: var(--text-muted); position: relative;
}
.cal-day.has-post {
    background: rgba(99,102,241,0.15);
    color: var(--accent-hover); font-weight: 600; cursor: pointer;
}
.cal-day.has-post:hover { background: rgba(99,102,241,0.3); }
.cal-day.today { outline: 1px solid var(--accent); }
.cal-day.empty { opacity: 0; pointer-events: none; }

/* ─── Post List Table ───────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
    text-align: left; padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-dim); font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid rgba(51,65,85,0.5); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-elevated); }
.data-table .actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ─── Section Builder (Editor) ──────────────────────────────────────────────── */
.editor-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 900px) { .editor-layout { grid-template-columns: 1fr; } }

.section-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    overflow: hidden;
}
.section-card-header {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    background: rgba(0,0,0,0.15);
    cursor: grab;
}
.section-card-header:active { cursor: grabbing; }
.section-drag-handle { color: var(--text-dim); font-size: 1rem; }
.section-cat-select {
    flex: 1; background: transparent; border: none;
    color: var(--text-primary); font-size: 0.875rem; font-weight: 600;
    outline: none; cursor: pointer;
}
.section-cat-select option { background: var(--bg-surface); }
.section-remove-btn {
    background: none; border: none; color: var(--text-dim);
    cursor: pointer; font-size: 1.1rem; padding: 0 0.25rem;
    transition: color 0.15s;
}
.section-remove-btn:hover { color: var(--danger); }

.section-items-editor { padding: 0.5rem 0.85rem 0.75rem; }
.item-row { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.35rem; }
.item-bullet { color: var(--text-dim); padding-top: 0.5rem; font-size: 0.85rem; }
.item-input {
    flex: 1; background: transparent; border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary); font-size: 0.875rem;
    padding: 0.35rem 0.25rem; outline: none;
    transition: border-color 0.15s; resize: none;
    min-height: 32px; line-height: 1.4;
    font-family: var(--font);
}
.item-input:focus { border-bottom-color: var(--accent); }
.item-remove-btn {
    background: none; border: none; color: var(--text-dim);
    cursor: pointer; padding: 0.35rem 0.25rem; font-size: 0.9rem;
    transition: color 0.15s;
}
.item-remove-btn:hover { color: var(--danger); }
.add-item-btn {
    background: none; border: none; color: var(--text-dim);
    cursor: pointer; font-size: 0.8rem; padding: 0.25rem 0;
    transition: color 0.15s;
}
.add-item-btn:hover { color: var(--accent-hover); }

/* ─── Preview ───────────────────────────────────────────────────────────────── */
.preview-pane {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    min-height: 300px;
    overflow-y: auto;
}
.preview-pane .post-section { margin-bottom: 1rem; }

/* ─── Upload Zone ───────────────────────────────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem; text-align: center;
    cursor: pointer; transition: all 0.2s;
    color: var(--text-muted); font-size: 0.875rem;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--accent);
    background: rgba(99,102,241,0.05);
    color: var(--text-primary);
}
.upload-zone .upload-icon { font-size: 2rem; margin-bottom: 0.5rem; }

/* ─── Media Grid ────────────────────────────────────────────────────────────── */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}
.media-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    transition: border-color 0.15s;
}
.media-item:hover { border-color: var(--accent); }
.media-thumb {
    width: 100%; aspect-ratio: 1;
    object-fit: cover; display: block;
}
.media-info {
    padding: 0.5rem 0.6rem;
    font-size: 0.75rem; color: var(--text-muted);
}
.media-info .filename {
    font-weight: 600; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-actions {
    display: flex; gap: 0.4rem; padding: 0 0.6rem 0.6rem;
}
.media-copy-btn, .media-del-btn {
    flex: 1; font-size: 0.7rem; padding: 0.3rem;
    border-radius: var(--radius-sm); cursor: pointer;
    border: 1px solid var(--border); font-weight: 600;
    transition: all 0.15s; background: transparent;
}
.media-copy-btn { color: var(--accent-hover); border-color: var(--accent); }
.media-copy-btn:hover { background: rgba(99,102,241,0.15); }
.media-del-btn { color: var(--danger); border-color: var(--danger); }
.media-del-btn:hover { background: rgba(248,113,113,0.1); }

/* ─── Misc ──────────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.text-right { text-align: right; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 0.75rem; }
.justify-between { justify-content: space-between; }
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }
.badge {
    display: inline-block; padding: 0.15rem 0.55rem;
    border-radius: var(--radius-pill); font-size: 0.7rem; font-weight: 700;
    background: rgba(99,102,241,0.2); color: var(--accent-hover);
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .admin-main { padding: 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ─── Lampiran ──────────────────────────────────────────────────────────────── */
.lampiran {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
}
.lampiran-label {
    font-size: 0.7rem; font-weight: 700; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}
.lampiran-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.lampiran-thumb {
    width: 80px; height: 80px; object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: zoom-in; transition: all 0.2s;
}
.lampiran-thumb:hover {
    border-color: var(--accent);
    transform: scale(1.06);
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}

/* ─── Lampiran editor (post editor panel) ────────────────────────────────────── */
.lampiran-edit-item {
    position: relative;
    display: flex; flex-direction: column; align-items: center;
    width: 90px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.35rem 0.4rem;
    gap: 0.2rem;
    overflow: hidden;
}
.lampiran-edit-thumb {
    width: 78px; height: 62px; object-fit: cover;
    border-radius: 2px;
    display: block;
}
.lampiran-edit-name {
    font-size: 0.65rem; color: var(--text-muted);
    width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    text-align: center;
}
.lampiran-edit-size {
    font-size: 0.6rem; color: var(--text-muted);
}
.lampiran-del-btn {
    position: absolute; top: 2px; right: 3px;
    background: rgba(239,68,68,0.85);
    color: #fff; border: none; border-radius: 50%;
    width: 17px; height: 17px; font-size: 0.6rem; line-height: 17px; text-align: center;
    cursor: pointer; padding: 0;
    transition: background 0.15s;
}
.lampiran-del-btn:hover { background: #ef4444; }

/* ─── Header Site Nav (pages) ────────────────────────────────────────────────── */
.site-nav { display: flex; align-items: center; gap: 0.15rem; flex-wrap: wrap; }
.site-nav-link {
    color: var(--text-muted); font-size: 0.85rem; font-weight: 500;
    padding: 0.3rem 0.65rem; border-radius: var(--radius);
    transition: all 0.15s;
}
.site-nav-link:hover {
    color: var(--text-primary); background: var(--bg-elevated); text-decoration: none;
}
.site-nav-link.active { color: var(--accent-hover); background: rgba(99,102,241,0.1); }

/* ─── Page Content Viewer ────────────────────────────────────────────────────── */
.page-content { line-height: 1.8; }
.page-content h1 { font-size: 1.5rem; margin: 1.5rem 0 0.75rem; }
.page-content h2 { font-size: 1.25rem; margin: 1.25rem 0 0.5rem; }
.page-content h3 { font-size: 1.05rem; margin: 1rem 0 0.4rem; }
.page-content p  { margin: 0.75rem 0; }
.page-content ul, .page-content ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.page-content li { margin: 0.3rem 0; }
.page-content a  { color: var(--accent-hover); }
.page-content code {
    background: var(--bg-elevated); padding: 0.15em 0.4em;
    border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 0.875em;
}
.page-content pre {
    background: var(--bg-elevated); padding: 1rem;
    border-radius: var(--radius); overflow-x: auto;
    border: 1px solid var(--border); margin: 1rem 0;
}
.page-content pre code { background: none; padding: 0; }
.page-content img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); margin: 0.5rem 0; }
.page-content blockquote {
    border-left: 3px solid var(--accent); padding-left: 1rem;
    margin: 1rem 0; color: var(--text-muted); font-style: italic;
}
.page-content table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.page-content th, .page-content td { padding: 0.5rem 0.75rem; border: 1px solid var(--border); text-align: left; }
.page-content th { background: var(--bg-elevated); font-weight: 600; }

/* ─── Page editor textarea ───────────────────────────────────────────────────── */
.page-editor-textarea {
    width: 100%; min-height: 380px; resize: vertical;
    background: var(--bg-elevated); border: 1px solid var(--border);
    color: var(--text-primary); padding: 1rem; border-radius: var(--radius);
    font-family: var(--font-mono); font-size: 0.875rem; line-height: 1.6;
    outline: none; transition: border-color 0.2s;
}
.page-editor-textarea:focus { border-color: var(--accent); }
