/* ==========================================================================
   Aroostook Right to Read — Admin UI
   A small design system: tokens, layout shell, and components.
   ========================================================================== */

:root {
    /* Brand + accents */
    --accent:         #2f6f4e;
    --accent-strong:  #245a3f;
    --accent-soft:    #e6f2ec;
    --accent-ring:    rgba(47, 111, 78, 0.18);

    --blue:    #2563eb;
    --success: #12855c;
    --danger:  #dc2626;
    --warning: #b45309;
    --info:    #2563eb;

    /* Surfaces */
    --bg:            #f4f6f8;
    --surface:       #ffffff;
    --surface-2:     #f8fafc;
    --surface-3:     #f1f5f9;
    --sidebar:       #10231c;
    --sidebar-2:     #16332a;
    --sidebar-text:  rgba(255, 255, 255, 0.72);

    /* Ink */
    --text:      #0f172a;
    --text-2:    #475569;
    --text-3:    #94a3b8;
    --border:    #e2e8f0;
    --border-2:  #cbd5e1;

    /* Legacy aliases kept so older markup keeps rendering correctly */
    --primary-blue: var(--accent);
    --primary-dark: var(--accent-strong);
    --primary-light: var(--accent-soft);
    --primary-green: var(--accent);
    --error: var(--danger);
    --text-primary: var(--text);
    --text-secondary: var(--text-2);
    --bg-primary: var(--surface);
    --bg-secondary: var(--bg);
    --bg-tertiary: var(--surface-3);
    --border-color: var(--border);

    --radius:    10px;
    --radius-sm: 7px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.14);

    --sidebar-w: 256px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* The `hidden` attribute must win over component display rules. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.55;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

::selection { background: var(--accent-ring); }

/* ============================================================ LAYOUT SHELL */

.admin-wrapper { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: transform 0.28s var(--ease);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-mark {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #4aa878, #2f6f4e);
    display: grid; place-items: center;
    color: #fff; font-weight: 800; font-size: 14px;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.sidebar-header h2 {
    font-size: 14px; font-weight: 700; color: #fff; letter-spacing: -0.2px; line-height: 1.2;
}
.sidebar-header span { display: block; font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.45); }

.admin-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
}
.admin-nav::-webkit-scrollbar { width: 6px; }
.admin-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.admin-nav h3 {
    padding: 16px 10px 7px;
    font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.9px;
    color: rgba(255, 255, 255, 0.34);
}

.admin-nav a,
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px; font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s, color 0.15s;
    white-space: nowrap;
}
.admin-nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.8; }

.admin-nav a:hover { background-color: rgba(255, 255, 255, 0.07); color: #fff; }
.admin-nav a:hover svg { opacity: 1; }

.admin-nav a.is-active {
    background-color: rgba(74, 168, 120, 0.18);
    color: #fff;
    box-shadow: inset 2px 0 0 #4aa878;
}
.admin-nav a.is-active svg { opacity: 1; color: #7ed0a5; }

.admin-nav .nav-spacer { flex: 1; min-height: 12px; }

.admin-nav a.logout {
    color: #fca5a5;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    margin-top: 6px; padding-top: 14px;
}
.admin-nav a.logout:hover { background-color: rgba(220, 38, 38, 0.16); color: #fecaca; }

.admin-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.admin-header {
    position: sticky; top: 0; z-index: 40;
    background-color: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(10px);
    padding: 0 28px;
    min-height: 62px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}

.admin-header h1 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.admin-header .crumbs { font-size: 12px; color: var(--text-3); font-weight: 500; }

.header-actions { display: flex; align-items: center; gap: 8px; }

.user-info { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 9px; }
.user-info strong { color: var(--text); font-weight: 600; }

.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700; text-transform: uppercase;
}

.icon-btn {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
    box-shadow: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); transform: none; box-shadow: none; }
.icon-btn svg { width: 17px; height: 17px; }

#sidebar-toggle { display: none; }

.admin-content {
    flex: 1;
    padding: 26px 28px 60px;
    max-width: 1240px;
    width: 100%;
}

/* ============================================================== TYPOGRAPHY */

.admin-content h2 { font-size: 19px; font-weight: 700; margin-bottom: 18px; letter-spacing: -0.3px; }
.admin-content h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; letter-spacing: -0.2px; }

.page-intro { color: var(--text-2); font-size: 14px; margin: -6px 0 22px; max-width: 70ch; }

.muted { color: var(--text-2); }
.small { font-size: 13px; }
.req { color: var(--danger); font-weight: 600; }

/* =================================================================== CARDS */

.card,
.admin-section {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.card-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.card-head h3 { margin-bottom: 4px; }
.card-head p { color: var(--text-2); font-size: 13.5px; margin: 0; max-width: 68ch; }
.card-head .card-head-actions { display: flex; gap: 8px; flex-shrink: 0; }

.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 22px 24px 0; }

/* =================================================================== FORMS */

.form-group { margin-bottom: 20px; }
.form-group:last-child { margin-bottom: 0; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }

label {
    display: block; margin-bottom: 7px;
    font-weight: 600; font-size: 13px; color: var(--text);
}
label .hint-inline { font-weight: 400; color: var(--text-3); }

.field-hint { color: var(--text-2); font-size: 12.5px; margin-top: 6px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], input[type="search"],
input[type="date"], input[type="time"], textarea, select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background-color: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder, textarea::placeholder { color: var(--text-3); }

input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="number"]:focus, input[type="url"]:focus, input[type="search"]:focus,
input[type="date"]:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

textarea {
    resize: vertical;
    min-height: 110px;
    font-family: inherit;
    line-height: 1.6;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2394a3b8' stroke-width='1.6'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 34px;
}

.input-with-icon { position: relative; }
.input-with-icon svg {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-3); pointer-events: none;
}
.input-with-icon input { padding-left: 34px; }

.form-actions {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border);
}

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
    width: 40px; height: 23px; border-radius: 99px;
    background: var(--border-2);
    position: relative; flex-shrink: 0;
    transition: background-color 0.2s var(--ease);
}
.switch-track::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 17px; height: 17px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.2s var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-ring); }
.switch input:disabled + .switch-track { opacity: 0.5; cursor: not-allowed; }
.switch-label { font-size: 13.5px; font-weight: 500; }
.switch-label small { display: block; font-weight: 400; color: var(--text-2); font-size: 12.5px; }

/* Choice card — a switch presented as a highlighted panel */
.choice-card {
    display: flex; align-items: flex-start; gap: 13px;
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; background: var(--surface-2);
    transition: border-color 0.15s, background-color 0.15s;
}
.choice-card:hover { border-color: var(--border-2); }
.choice-card.is-on { border-color: var(--accent); background: var(--accent-soft); }
.choice-card .switch { align-items: flex-start; }

/* Segmented control */
.segmented {
    display: inline-flex; padding: 3px; gap: 3px;
    background: var(--surface-3); border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.segmented.wrap { flex-wrap: wrap; max-width: 100%; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; }
.segmented span {
    display: flex; align-items: center; gap: 7px;
    padding: 7px 14px; border-radius: 5px;
    font-size: 13px; font-weight: 600; color: var(--text-2);
    cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.segmented span svg { width: 15px; height: 15px; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-ring); }

/* ================================================================= BUTTONS */

button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 15px;
    background-color: var(--accent);
    color: #fff;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit; font-size: 13.5px; font-weight: 600;
    text-decoration: none;
    line-height: 1.3;
    transition: background-color 0.15s, box-shadow 0.15s, transform 0.08s;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}
button svg, .btn svg { width: 15px; height: 15px; }

button:hover, .btn:hover { background-color: var(--accent-strong); box-shadow: var(--shadow-md); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
button:disabled, .btn.is-disabled { opacity: 0.55; pointer-events: none; }

.btn.secondary, button.secondary {
    background-color: var(--surface); color: var(--text); border-color: var(--border-2);
}
.btn.secondary:hover, button.secondary:hover { background-color: var(--surface-3); }

.btn.ghost, button.ghost {
    background: transparent; color: var(--text-2); box-shadow: none; border-color: transparent;
}
.btn.ghost:hover, button.ghost:hover { background: var(--surface-3); color: var(--text); box-shadow: none; }

.btn.danger, button.danger { background-color: var(--danger); }
.btn.danger:hover, button.danger:hover { background-color: #b91c1c; }

.btn.danger-ghost {
    background: transparent; color: var(--danger); box-shadow: none; border-color: var(--border);
}
.btn.danger-ghost:hover { background: #fef2f2; border-color: #fecaca; box-shadow: none; }

.btn.small, button.small { padding: 6px 11px; font-size: 12.5px; border-radius: 6px; }
.btn.block { width: 100%; }

.btn-group { display: flex; gap: 7px; flex-wrap: wrap; }

/* ================================================================== TABLES */

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.card.flush .table-wrap { border: none; border-radius: 0; }

table { width: 100%; border-collapse: collapse; background-color: var(--surface); font-size: 14px; }

thead { background-color: var(--surface-2); }

th {
    padding: 11px 16px; text-align: left;
    font-weight: 600; color: var(--text-2);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }

tbody tr { transition: background-color 0.12s; }
tbody tr:hover { background-color: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

td .cell-title { font-weight: 600; color: var(--text); }
td .cell-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

.col-actions { text-align: right; white-space: nowrap; }
.col-actions .btn-group { justify-content: flex-end; }

/* Sortable rows */
.sortable tr.is-dragging { opacity: 0.4; }
.sortable tr.drop-target td { box-shadow: inset 0 2px 0 var(--accent); }
.drag-handle {
    cursor: grab; color: var(--text-3);
    display: inline-grid; place-items: center;
    width: 26px; height: 26px; border-radius: 6px;
    transition: background-color 0.15s, color 0.15s;
}
.drag-handle:hover { background: var(--surface-3); color: var(--text-2); }
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { width: 15px; height: 15px; pointer-events: none; }

/* ================================================================== BADGES */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 99px;
    font-size: 11.5px; font-weight: 600; letter-spacing: 0.2px;
    background: var(--surface-3); color: var(--text-2);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green  { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge.amber  { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.badge.blue   { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.badge.red    { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.badge.grey   { background: var(--surface-3); color: var(--text-2); }

/* File-type chip */
.filetype {
    width: 38px; height: 38px; border-radius: 8px; flex-shrink: 0;
    display: grid; place-items: center;
    font-size: 9.5px; font-weight: 800; color: #fff; letter-spacing: 0.3px;
    background: #64748b;
}
.filetype.pdf { background: #dc2626; }
.filetype.doc, .filetype.docx { background: #2563eb; }
.filetype.xls, .filetype.xlsx, .filetype.csv { background: #16a34a; }
.filetype.ppt, .filetype.pptx { background: #ea580c; }
.filetype.zip { background: #7c3aed; }
.filetype.jpg, .filetype.jpeg, .filetype.png, .filetype.gif, .filetype.webp { background: #0891b2; }
.filetype.url { background: var(--accent); }

/* ================================================================ MESSAGES */

.success, .error, .warning, .info, .alert {
    display: flex; gap: 11px; align-items: flex-start;
    padding: 13px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 13.5px; font-weight: 500;
    border: 1px solid;
}
.alert svg, .success svg, .error svg, .warning svg, .info svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }

.success { background-color: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.error   { background-color: #fef2f2; color: #991b1b; border-color: #fecaca; }
.warning { background-color: #fffbeb; color: #92400e; border-color: #fde68a; }
.info    { background-color: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* Empty state */
.empty-state {
    text-align: center; padding: 46px 24px;
    color: var(--text-2);
}
.empty-state svg { width: 40px; height: 40px; color: var(--text-3); margin-bottom: 12px; }
.empty-state h4 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.empty-state p { font-size: 13.5px; max-width: 46ch; margin: 0 auto 16px; }

/* ================================================================== TOASTS */

.toast-stack {
    position: fixed; right: 18px; bottom: 18px; z-index: 200;
    display: flex; flex-direction: column; gap: 9px;
    max-width: min(380px, calc(100vw - 36px));
}
.toast {
    display: flex; align-items: flex-start; gap: 10px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 14px; font-size: 13.5px; font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.25s var(--ease);
}
.toast.is-error   { border-left-color: var(--danger); }
.toast.is-warning { border-left-color: var(--warning); }
.toast.is-info    { border-left-color: var(--info); }
.toast.is-leaving { animation: toast-out 0.2s ease forwards; }
.toast button { margin-left: auto; background: none; border: none; box-shadow: none; color: var(--text-3); padding: 0 2px; font-size: 16px; line-height: 1; }
.toast button:hover { background: none; color: var(--text); box-shadow: none; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(16px); } }

/* =================================================================== MODAL */

.modal-backdrop {
    position: fixed; inset: 0; z-index: 150;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    display: grid; place-items: center;
    padding: 20px;
    animation: fade-in 0.15s ease;
}
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 440px;
    padding: 24px;
    animation: modal-in 0.22s var(--ease);
}
.modal h3 { margin-bottom: 8px; }
.modal p { color: var(--text-2); font-size: 14px; margin-bottom: 20px; }
.modal .form-actions { margin-top: 0; padding-top: 0; border-top: none; justify-content: flex-end; }

@keyframes fade-in  { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

/* Slide-over drawer */
.drawer-backdrop {
    position: fixed; inset: 0; z-index: 140;
    background: rgba(15, 23, 42, 0.4);
    animation: fade-in 0.15s ease;
}
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 145;
    width: min(560px, 100vw);
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    animation: drawer-in 0.26s var(--ease);
}
.drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px; }
.drawer-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; background: var(--surface-2); }

@keyframes drawer-in { from { transform: translateX(100%); } }

/* ================================================================ UPLOADER */

.uploader { position: relative; }
.uploader-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.uploader-drop {
    border: 1.5px dashed var(--border-2);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 26px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.18s, background-color 0.18s, transform 0.12s;
}
.uploader-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.uploader-drop:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.uploader.is-dragover .uploader-drop {
    border-color: var(--accent); background: var(--accent-soft);
    border-style: solid; transform: scale(1.005);
}

.uploader-icon { width: 26px; height: 26px; color: var(--accent); margin-bottom: 8px; }
.uploader-copy { font-size: 13.5px; color: var(--text); }
.uploader-browse { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.uploader-hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }

.uploader-progress { margin-top: 12px; }
.uploader-progress-bar {
    height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden;
}
.uploader-progress-bar span {
    display: block; height: 100%; width: 0;
    background: linear-gradient(90deg, #4aa878, var(--accent));
    border-radius: 99px; transition: width 0.18s linear;
}
.uploader-progress-text { font-size: 12px; color: var(--text-2); margin-top: 6px; }

.uploader-file {
    display: flex; align-items: center; gap: 13px;
    margin-top: 12px; padding: 11px 13px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface);
}
.uploader-thumb {
    width: 52px; height: 52px; border-radius: 8px; object-fit: cover;
    border: 1px solid var(--border); background: var(--surface-3); flex-shrink: 0;
}
.uploader-badge {
    width: 44px; height: 44px; border-radius: 8px; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent);
    font-size: 10px; font-weight: 800;
}
.uploader-meta { flex: 1; min-width: 0; }
.uploader-filename { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uploader-filesize { font-size: 12px; color: var(--text-2); }
.uploader-remove {
    background: none; border: none; box-shadow: none; padding: 4px 8px;
    color: var(--text-3); font-size: 20px; line-height: 1; cursor: pointer;
}
.uploader-remove:hover { background: none; box-shadow: none; color: var(--danger); }

.uploader-error { margin-top: 9px; color: var(--danger); font-size: 12.5px; font-weight: 500; }
.uploader.is-busy .uploader-drop { pointer-events: none; opacity: 0.6; }

/* ============================================================= DATE PICKER */

.datefield { position: relative; }
.datefield > input { padding-right: 38px; }
.datefield-btn {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 30px; height: 30px; padding: 0;
    background: none; border: none; box-shadow: none;
    color: var(--text-3); display: grid; place-items: center; border-radius: 6px;
}
.datefield-btn:hover { background: var(--surface-3); color: var(--text); box-shadow: none; }
.datefield-btn svg { width: 16px; height: 16px; }

.datepicker {
    position: absolute; z-index: 120; top: calc(100% + 6px); left: 0;
    width: 266px; padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: modal-in 0.15s var(--ease);
}
.datepicker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; gap: 6px; }
.datepicker-title { font-size: 13.5px; font-weight: 700; }
.datepicker-nav {
    width: 27px; height: 27px; padding: 0; border-radius: 6px;
    background: none; border: 1px solid var(--border); box-shadow: none;
    color: var(--text-2); display: grid; place-items: center;
}
.datepicker-nav:hover { background: var(--surface-3); color: var(--text); box-shadow: none; }
.datepicker-nav svg { width: 14px; height: 14px; }

.datepicker-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.datepicker-dow {
    text-align: center; font-size: 10.5px; font-weight: 700;
    color: var(--text-3); text-transform: uppercase; padding-bottom: 4px;
}
.datepicker-day {
    padding: 0; height: 32px; border-radius: 7px;
    background: none; border: none; box-shadow: none;
    color: var(--text); font-size: 13px; font-weight: 500;
}
.datepicker-day:hover { background: var(--surface-3); box-shadow: none; }
.datepicker-day.is-muted { color: var(--text-3); }
.datepicker-day.is-today { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); font-weight: 700; }
.datepicker-day.is-selected { background: var(--accent); color: #fff; font-weight: 700; }
.datepicker-day.is-selected:hover { background: var(--accent-strong); }
.datepicker-foot { display: flex; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.datepicker-foot button { flex: 1; font-size: 12.5px; padding: 6px; }

/* ============================================================== DASHBOARD */

.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px; margin-bottom: 24px;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 18px 20px;
    text-align: left; box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 3px;
    text-decoration: none; color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
a.stat-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
    width: 32px; height: 32px; border-radius: 8px; margin-bottom: 8px;
    background: var(--accent-soft); color: var(--accent);
    display: grid; place-items: center;
}
.stat-icon svg { width: 17px; height: 17px; }
.stat-number { font-size: 26px; font-weight: 700; letter-spacing: -0.8px; line-height: 1.1; }
.stat-label { color: var(--text-2); font-size: 13px; font-weight: 500; }

.quick-links { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.quick-links li a {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 15px; background-color: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); text-decoration: none; font-weight: 500; font-size: 13.5px;
    transition: all 0.15s;
}
.quick-links li a:hover { background-color: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.quick-links li a svg { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }

/* Media grid (header images etc.) */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.media-tile {
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
    background: var(--surface); box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.media-tile:hover { box-shadow: var(--shadow-md); border-color: var(--border-2); }
.media-tile.is-dragging { opacity: 0.4; }
.media-tile.drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.media-tile img { width: 100%; height: 130px; object-fit: cover; background: var(--surface-3); display: block; }
.media-tile-body { padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.media-tile-name { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-tile-order {
    width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
    background: var(--surface-3); color: var(--text-2);
    display: grid; place-items: center; font-size: 11px; font-weight: 700;
}

/* ============================================================== STANDALONE */

body.admin-standalone {
    display: grid; place-items: center; min-height: 100vh; padding: 24px;
    background:
        radial-gradient(1000px 500px at 12% -10%, rgba(74,168,120,0.16), transparent 60%),
        radial-gradient(900px 500px at 105% 110%, rgba(37,99,235,0.12), transparent 55%),
        var(--bg);
}
.standalone-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: 34px; width: 100%; max-width: 420px;
}
.standalone-card h1 { font-size: 21px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.4px; }
.standalone-card p { color: var(--text-2); font-size: 14px; margin-bottom: 22px; }

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-brand .sidebar-mark { width: 42px; height: 42px; font-size: 16px; border-radius: 11px; }
.login-brand h1 { font-size: 18px; margin: 0; }
.login-brand p { font-size: 13px; margin: 0; }

.login-foot { margin-top: 22px; text-align: center; font-size: 12.5px; color: var(--text-3); }
.login-foot a { color: var(--text-2); text-decoration: none; font-weight: 500; }
.login-foot a:hover { color: var(--accent); }

.password-field { position: relative; }
.password-field input { padding-right: 42px; }
.password-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 32px; height: 32px; padding: 0; border-radius: 6px;
    background: none; border: none; box-shadow: none; color: var(--text-3);
    display: grid; place-items: center;
}
.password-toggle:hover { background: var(--surface-3); color: var(--text); box-shadow: none; }
.password-toggle svg { width: 17px; height: 17px; }

/* ============================================================== UTILITIES */

.stack  { display: flex; flex-direction: column; gap: 14px; }
.row    { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }

/* TinyMCE should not look like a foreign body inside our forms */
.tox-tinymce { border-radius: var(--radius-sm) !important; border-color: var(--border-2) !important; }

/* ============================================================ RESPONSIVE */

@media (max-width: 960px) {
    #sidebar-toggle { display: grid; }

    .admin-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.sidebar-open .admin-sidebar { transform: translateX(0); }
    body.sidebar-open::after {
        content: ''; position: fixed; inset: 0; z-index: 50;
        background: rgba(15, 23, 42, 0.45);
    }

    .admin-main { margin-left: 0; }
    .admin-header { padding: 0 16px; }
    .admin-content { padding: 18px 16px 48px; }
    .card, .admin-section { padding: 18px; border-radius: var(--radius); }
    .user-info .username-text { display: none; }
}

@media (max-width: 600px) {
    .form-row { grid-template-columns: 1fr; }
    .col-actions .btn-group { justify-content: flex-start; }
    .drawer { width: 100vw; }
    .toast-stack { left: 12px; right: 12px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
