/* =============================================================
   Catatan Pribadi — Stylesheet
   Palet warna dipakai lewat CSS variable supaya konsisten &
   mudah diubah dari satu tempat kalau perlu.
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Inter:wght@400;500;600&display=swap');

:root {
    --bg: #F7F7F5;
    --surface: #FFFFFF;
    --text-primary: #1F2421;
    --text-secondary: #6B7280;
    --accent: #0F766E;
    --accent-hover: #0B5C56;
    --accent-soft: #E6F2F1;
    --border: #E5E7EB;
    --danger: #B91C1C;
    --danger-soft: #FDECEC;
    --success: #15803D;
    --success-soft: #EAF7EE;
    --info: #1D4ED8;
    --info-soft: #EAF0FD;

    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(31, 36, 33, 0.06);
    --shadow-md: 0 4px 16px rgba(31, 36, 33, 0.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px 80px;
}

.hint-text {
    color: var(--text-secondary);
    font-size: 13.5px;
    margin: 4px 0 20px;
}

/* ---------------- Top navigation ---------------- */
.topnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topnav-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.brand {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 600;
    color: var(--text-primary);
}
.brand:hover { text-decoration: none; color: var(--accent); }
.topnav-links {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 14px;
}
.topnav-links a { color: var(--text-secondary); }
.topnav-links a:hover { color: var(--accent); text-decoration: none; }
.topnav-user {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 4px 10px;
    background: var(--bg);
    border-radius: 20px;
}

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 16px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, opacity 150ms ease;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text-primary); }

.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------------- Alerts ---------------- */
.alert {
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 20px;
}
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }

.draft-banner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* ---------------- Forms ---------------- */
label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 14px 0 6px;
}
input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--surface);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------------- Auth pages (login / create_admin) ---------------- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.auth-wrap { width: 100%; max-width: 380px; }
.auth-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 36px 32px;
}
.auth-title {
    font-size: 24px;
    text-align: center;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}
.auth-form label:first-of-type { margin-top: 0; }
.auth-form .btn { margin-top: 22px; }

/* ---------------- Dashboard ---------------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 28px;
}
.search-bar input { flex: 1; }

.note-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}
.note-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    color: var(--text-primary);
    transition: box-shadow 150ms ease, transform 150ms ease;
}
.note-card:hover {
    text-decoration: none;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.note-thumb { width: 100%; height: 130px; background: var(--bg); overflow: hidden; }
.note-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.note-card-body { padding: 14px 16px; }
.note-card-body h3 {
    font-size: 16px;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.note-snippet {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 34px;
}
.note-meta { font-size: 12px; color: var(--text-secondary); margin: 0; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state .btn { margin-top: 14px; }

.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 28px;
}
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}
.page-link:hover { background: var(--bg); text-decoration: none; }
.page-link.active { background: var(--accent); color: #fff; }

/* ---------------- Note detail (view) ---------------- */
.view-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}
.view-toolbar-actions { display: flex; gap: 8px; }

.note-detail {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 36px;
}
.note-detail h1 { font-size: 28px; }
.note-detail .note-meta { margin-bottom: 24px; font-size: 13px; }
.note-content { padding: 0; font-size: 15.5px; }
.note-content img, .note-content video { max-width: 100%; border-radius: 6px; }

/* ---------------- Editor pages ---------------- */
.editor-page { max-width: 900px; }
.editor-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
}
.autosave-status {
    font-size: 12.5px;
    color: var(--text-secondary);
}
.title-input {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 600;
    border: none;
    border-bottom: 2px solid var(--border);
    border-radius: 0;
    padding: 8px 2px 14px;
    margin-bottom: 16px;
    background: transparent;
}
.title-input:focus {
    box-shadow: none;
    border-bottom-color: var(--accent);
}

#editor-toolbar {
    border: 1px solid var(--border) !important;
    border-bottom: none !important;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--surface);
}
#editor {
    background: var(--surface);
    border: 1px solid var(--border) !important;
    border-radius: 0 0 var(--radius) var(--radius);
    min-height: 380px;
    font-size: 15px;
    font-family: var(--font-body);
}
.ql-editor { min-height: 380px; }

.editor-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

/* Font kustom di dropdown & konten editor */
.ql-font-serif { font-family: Georgia, 'Times New Roman', serif; }
.ql-font-monospace { font-family: 'Courier New', monospace; }
.ql-font-georgia { font-family: Georgia, serif; }
.ql-font-times-new-roman { font-family: 'Times New Roman', serif; }
.ql-font-courier-new { font-family: 'Courier New', monospace; }
.ql-picker.ql-font .ql-picker-label[data-value="georgia"]::before,
.ql-picker.ql-font .ql-picker-item[data-value="georgia"]::before { content: 'Georgia'; font-family: Georgia, serif; }
.ql-picker.ql-font .ql-picker-label[data-value="times-new-roman"]::before,
.ql-picker.ql-font .ql-picker-item[data-value="times-new-roman"]::before { content: 'Times New Roman'; font-family: 'Times New Roman', serif; }
.ql-picker.ql-font .ql-picker-label[data-value="courier-new"]::before,
.ql-picker.ql-font .ql-picker-item[data-value="courier-new"]::before { content: 'Courier New'; font-family: 'Courier New', monospace; }
.ql-picker.ql-font .ql-picker-label[data-value="serif"]::before,
.ql-picker.ql-font .ql-picker-item[data-value="serif"]::before { content: 'Serif'; }
.ql-picker.ql-font .ql-picker-label[data-value="monospace"]::before,
.ql-picker.ql-font .ql-picker-item[data-value="monospace"]::before { content: 'Monospace'; }

/* Custom video toolbar button pakai ikon SVG sendiri, samakan style-nya
   dengan tombol bawaan Quill lain (ql-image dsb) */
#editor-toolbar button.ql-customVideo svg { width: 18px; height: 18px; }
#editor-toolbar button.ql-customVideo .ql-stroke {
    fill: none; stroke: #444; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2;
}
#editor-toolbar button.ql-customVideo .ql-fill { fill: #444; }
#editor-toolbar button.ql-customVideo:hover .ql-stroke { stroke: var(--accent); }
#editor-toolbar button.ql-customVideo:hover .ql-fill { fill: var(--accent); }
#editor-toolbar button.ql-undo svg, #editor-toolbar button.ql-redo svg { width: 18px; height: 18px; }
#editor-toolbar button.ql-undo .ql-stroke, #editor-toolbar button.ql-redo .ql-stroke {
    fill: none; stroke: #444; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2;
}
#editor-toolbar button.ql-undo:hover .ql-stroke, #editor-toolbar button.ql-redo:hover .ql-stroke { stroke: var(--accent); }

/* ---------------- Popup konfirmasi 2 tahap (unsaved-guard.js) ---------------- */
.guard-overlay {
    position: fixed;
    inset: 0;
    background: rgba(31, 36, 33, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}
.guard-modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 28px;
    max-width: 380px;
    width: 100%;
    text-align: center;
}
.guard-message {
    font-size: 15.5px;
    margin: 0 0 22px;
    line-height: 1.6;
}
.guard-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* ---------------- Share page ---------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
}
.inline-form { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.inline-form select { width: auto; }

.simple-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.simple-table th, .simple-table td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    vertical-align: middle;
}
.simple-table th { color: var(--text-secondary); font-weight: 500; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.02em; }
.table-actions { display: flex; gap: 8px; }

.link-input {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 6px 10px;
    min-width: 220px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-inactive { background: var(--bg); color: var(--text-secondary); }

/* ---------------- Responsive ---------------- */
@media (max-width: 640px) {
    .container { padding: 20px 14px 60px; }
    .note-detail { padding: 22px 18px; }
    .title-input { font-size: 21px; }
    .topnav-links { gap: 12px; font-size: 13px; }
    .table-actions { flex-direction: column; }
    .link-input { min-width: 140px; }
}
