/* Admin panel — clean, dense, dark sidebar */

* { box-sizing: border-box; }
body {
    margin: 0;
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f4f5f7;
    color: #1f2937;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.admin {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: #1f2937;
    color: #cbd5e1;
    padding: 22px 0 0 0;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-bottom: 12px;
}

/* User/Logout block — pinned to bottom of the sidebar */
.sidebar-user {
    flex-shrink: 0;
    padding: 16px 22px 18px;
    border-top: 1px solid #374151;
    font-size: 12px;
    color: #9ca3af;
    background: #1f2937;
}
.sidebar-user .lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #6b7280; margin-bottom: 4px; }
.sidebar-user strong { display: block; color: #f9fafb; font-size: 14px; margin-bottom: 8px; word-break: break-word; }
.sidebar-user .logout-link { color: #f59e0b; font-weight: 500; }
.sidebar-user .logout-link:hover { color: #fbbf24; }
.sidebar .brand {
    padding: 0 22px 18px;
    border-bottom: 1px solid #374151;
    margin-bottom: 14px;
    font-family: 'Caveat', cursive;
    font-size: 24px;
    color: #f9fafb;
}
.sidebar .brand small { display: block; font-family: inherit; font-size: 11px; color: #9ca3af; letter-spacing: 1.5px; text-transform: uppercase; margin-top: 2px; }
.sidebar nav a {
    display: flex; gap: 10px; align-items: center;
    padding: 10px 22px;
    color: #cbd5e1;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #111827; color: #fff; text-decoration: none; }
.sidebar nav a.is-active { background: #111827; color: #fff; border-left-color: #f59e0b; }
.sidebar nav a .ico { width: 18px; text-align: center; }

.main {
    padding: 28px 36px;
    overflow-x: auto;
}
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 22px;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
}

.toolbar {
    display: flex; gap: 10px; align-items: center;
    margin-bottom: 14px;
}
.toolbar input[type="search"], .toolbar select {
    padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px;
    background: #fff;
}

.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
    border: 1px solid #e5e7eb;
    padding: 22px;
    margin-bottom: 22px;
}
.card h2 { margin-top: 0; font-size: 16px; font-weight: 600; }
.card .hint { color: #6b7280; font-size: 13px; margin: -4px 0 14px; }

table.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
}
.table th {
    background: #f9fafb;
    font-weight: 600;
    color: #4b5563;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .5px;
}
.table tbody tr:hover { background: #fafafa; }
.table .row-actions { display: flex; gap: 6px; }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    background: #2563eb; color: #fff;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}
.btn:hover { background: #1d4ed8; text-decoration: none; color: #fff; }
.btn--ghost { background: transparent; color: #1f2937; border: 1px solid #d1d5db; }
.btn--ghost:hover { background: #f3f4f6; }
.btn--danger { background: #dc2626; }
.btn--danger:hover { background: #b91c1c; }
.btn--accent { background: #f59e0b; color: #1f2937; font-weight: 600; }
.btn--accent:hover { background: #d97706; color: #1f2937; }
.btn--sm { padding: 5px 10px; font-size: 12px; }

.badge {
    display: inline-block; padding: 3px 8px; font-size: 11px; font-weight: 600;
    border-radius: 999px; text-transform: uppercase; letter-spacing: .5px;
}
.badge-ok    { background: #dcfce7; color: #166534; }
.badge-draft { background: #f3f4f6; color: #374151; }
.badge-sched { background: #fef3c7; color: #92400e; }

form .field { margin-bottom: 16px; }
form .field label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
form .field .desc { color: #6b7280; font-size: 12px; margin-top: 4px; }
form input[type=text], form input[type=email], form input[type=password],
form input[type=number], form input[type=url], form input[type=datetime-local],
form select, form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    font-family: inherit;
}
form textarea { min-height: 140px; resize: vertical; }
form input:focus, form select:focus, form textarea:focus {
    border-color: #2563eb;
    outline: 2px solid rgba(37,99,235,.15);
    outline-offset: -1px;
}
form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
form .row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
form .checkbox { display: flex; gap: 8px; align-items: center; }

.flash {
    padding: 12px 16px; border-radius: 6px; margin-bottom: 16px;
    font-size: 14px;
}
.flash--ok { background: #dcfce7; color: #166534; }
.flash--err { background: #fee2e2; color: #991b1b; }
.flash--info { background: #dbeafe; color: #1e40af; }

/* Theme customizer */
.customizer-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 22px;
}
@media (max-width: 1000px) { .customizer-grid { grid-template-columns: 1fr; } }

.color-input {
    display: flex; gap: 8px; align-items: center;
}
.color-input input[type=color] {
    width: 44px; height: 38px; padding: 2px;
    border: 1px solid #d1d5db; border-radius: 6px; background: #fff;
    cursor: pointer;
}
.color-input input[type=text] {
    flex: 1;
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
}

.preview-frame {
    background: #fff; border-radius: 8px; overflow: hidden;
    border: 1px solid #e5e7eb;
}
.preview-frame iframe {
    width: 100%; min-height: 80vh; border: 0; display: block;
}

.editor-shell { background: #fff; border-radius: 6px; border: 1px solid #e5e7eb; }
.editor-toolbar {
    background: #f3f4f6; padding: 8px;
    border-bottom: 1px solid #e5e7eb;
    display: flex; flex-wrap: wrap; gap: 4px;
}
.editor-toolbar button {
    background: transparent; border: 1px solid transparent; border-radius: 4px;
    padding: 6px 10px; cursor: pointer; font-size: 13px; min-width: 32px;
}
.editor-toolbar button:hover { background: #e5e7eb; border-color: #d1d5db; }
.editor-toolbar select { padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 12px; }
.editor-toolbar .sep { width: 1px; background: #d1d5db; margin: 4px 6px; }

.tox-tinymce { border-radius: 6px !important; border-color: #e5e7eb !important; }

.section-cards {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
@media (max-width: 900px) { .section-cards { grid-template-columns: 1fr; } }
.metric { background: #fff; border-radius: 10px; padding: 18px; border: 1px solid #e5e7eb; }
.metric .num { font-size: 32px; font-weight: 700; }
.metric .lbl { color: #6b7280; font-size: 13px; }

.kbd {
    background: #1f2937; color: #f9fafb;
    padding: 2px 6px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 12px;
}

.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #2a2622, #3f5a3a);
    padding: 24px;
}
.login-card {
    background: #fff;
    padding: 36px 32px;
    border-radius: 14px;
    width: min(420px, 100%);
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-card h1 {
    font-family: 'Caveat', cursive;
    font-size: 32px;
    margin: 0 0 4px;
    color: #3f5a3a;
}
.login-card .lead { color: #6b7280; font-size: 13px; margin: 0 0 22px; }

/* -------------------------------------------------------------------------
   Theme customizer — stacked sections, upload widgets, font previews
   ------------------------------------------------------------------------- */
form .stacked { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
form .stacked .field { margin: 0; }

/* Upload widget (logo / favicon / hero image) */
.upload-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px;
    border: 1px dashed rgba(120, 90, 50, .25);
    border-radius: 8px;
    background: rgba(120, 90, 50, .04);
    margin-bottom: 8px;
}
.upload-preview {
    width: 96px; height: 64px;
    flex: 0 0 96px;
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.upload-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.upload-empty { color: #9ca3af; font-size: 13px; }
.upload-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.upload-controls input[type="file"] { display: none; }
.upload-msg { font-size: 12px; color: #6b7280; }
.upload-msg--ok  { color: #166534; }
.upload-msg--err { color: #991b1b; }
.btn--danger { color: #991b1b; }
.btn--danger:hover { background: #fee2e2; }

/* Font preview block under the typography <select>s */
.font-preview {
    margin-top: 10px;
    padding: 14px 16px;
    background: #f6efe1;
    border: 1px solid rgba(120, 90, 50, .18);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
body.is-dark .font-preview { background: #2a2622; border-color: rgba(255,255,255,.08); }
.font-preview-sample { display: block; line-height: 1.3; color: #2a2622; }
body.is-dark .font-preview-sample { color: #ede2c8; }
.font-preview-sample.heading-sample { font-size: 30px; font-weight: 700; }
.font-preview-sample.body-sample    { font-size: 14px; }
.font-preview-name { font-size: 11px; color: #7a6f5f; font-family: 'IBM Plex Mono', monospace; text-transform: uppercase; letter-spacing: .04em; }
body.is-dark .font-preview-name { color: #978a73; }

/* -------------------------------------------------------------------------
   Cover image uploader (post editor sidebar)
   ------------------------------------------------------------------------- */
.cover-uploader { display: block; }

/* Compact thumbnail in the sidebar — not a wide preview, so it doesn't
   push all the other publish settings off-screen. ~120×80 with a click
   affordance to inspect it in a larger modal. */
.cover-preview {
    position: relative;
    width: 120px;
    height: 80px;
    border: 2px dashed rgba(120, 90, 50, .25);
    border-radius: 6px;
    background: #f6efe1;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.cover-preview:hover { border-color: #c66b3d; }
body.is-dark .cover-preview { background: #2a2622; border-color: rgba(255,255,255,.12); }

.cover-preview img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
}

.cover-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    color: #7a6f5f;
    font-size: 10px;
    text-align: center;
    padding: 4px;
    line-height: 1.2;
}
.cover-empty span:first-child { font-size: 18px; }

.cover-remove {
    position: absolute; top: 3px; right: 3px;
    width: 22px; height: 22px;
    background: rgba(20, 18, 16, .8);
    color: #fff;
    border: none; border-radius: 999px;
    font-size: 14px; line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity .12s ease;
}
.cover-preview:hover .cover-remove,
.cover-remove:focus { opacity: 1; }
.cover-remove:hover { background: #b03a3a; }

.cover-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.cover-actions .btn--sm { font-size: 11px; padding: 4px 8px; }

[data-cover-url] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid rgba(120, 90, 50, .25);
    border-radius: 6px;
    background: #fff;
    font: 13px 'IBM Plex Mono', monospace;
}
body.is-dark [data-cover-url] { background: #1a1411; color: #ede2c8; border-color: rgba(255,255,255,.12); }

/* -------------------------------------------------------------------------
   Modal (gallery picker)
   ------------------------------------------------------------------------- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(20, 18, 16, .55);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: fade-in .15s ease;
}
.modal {
    background: #f6efe1;
    color: #2a2622;
    border-radius: 12px;
    width: min(720px, 100%);
    max-height: 80vh;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
body.is-dark .modal { background: #2a2622; color: #ede2c8; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(120, 90, 50, .18);
}
body.is-dark .modal-header { border-bottom-color: rgba(255,255,255,.08); }
.modal-close {
    background: none; border: none;
    font-size: 24px; line-height: 1;
    color: inherit; cursor: pointer;
    padding: 0 6px;
}
.modal-close:hover { color: #b03a3a; }
.modal-body {
    padding: 16px 18px;
    overflow-y: auto;
    max-height: 60vh;
}
.gallery-tile:hover { border-color: #c66b3d !important; transform: translateY(-1px); }
.gallery-tile { transition: all .12s ease; }

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}