/* ==================================================================
   Gexton E-Library — admin panel
   ================================================================== */

body.admin-body { background: var(--paper); }

.admin { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }

/* ---------------- Sidebar ---------------- */

.side {
    background: var(--slate);
    color: rgba(255, 255, 255, .74);
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.side__brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; }
.side__brand .brand__name { color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.side__brand .brand__sub { font-family: var(--font-mono); font-size: 9px; letter-spacing: .2em; color: rgba(255, 255, 255, .42); text-transform: uppercase; }

.side__label {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .34);
    padding: 16px 10px 8px;
}

.side__nav { display: grid; gap: 3px; }

.side__nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: 11px;
    font-size: 14.5px;
    font-weight: 600;
    color: rgba(255, 255, 255, .74);
    transition: background .15s, color .15s;
}

.side__nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side__nav a svg { flex: none; opacity: .8; }

.side__nav a.is-active {
    background: linear-gradient(100deg, var(--brand) 0%, var(--brand-600) 100%);
    color: #fff;
    box-shadow: 0 8px 20px rgba(255, 106, 0, .3);
}
.side__nav a.is-active svg { opacity: 1; }

.side__nav .pill {
    margin-left: auto;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    padding: 2px 8px;
}
.side__nav a.is-active .pill { background: rgba(0, 0, 0, .22); }

.side__foot { margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .1); }

.side__me { display: flex; align-items: center; gap: 10px; padding: 10px 8px; }
.side__me .av {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(150deg, var(--brand), var(--brand-700));
    display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex: none;
}
.side__me b { display: block; color: #fff; font-size: 13.5px; line-height: 1.3; }
.side__me span { font-size: 11.5px; color: rgba(255, 255, 255, .45); word-break: break-all; }

/* ---------------- Main ---------------- */

.admin-main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 28px;
    background: rgba(242, 244, 247, .88);
    backdrop-filter: blur(12px) saturate(1.5);
    border-bottom: 1px solid var(--line);
}

.topbar__title { min-width: 0; }
.topbar__title h1 { font-size: 21px; letter-spacing: -.026em; }
.topbar__title p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.side-toggle {
    display: none;
    width: 40px; height: 40px;
    border-radius: 11px;
    border: 1px solid var(--line);
    background: var(--surface);
    cursor: pointer;
    place-items: center;
}

.admin-content { padding: 26px 28px 48px; }

/* ---------------- Stat cards ---------------- */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.stat {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 20px;
    box-shadow: var(--sh-1);
    transition: transform .18s ease, box-shadow .18s ease;
}

.stat:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }

.stat__icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: var(--brand-050);
    color: var(--brand-700);
    margin-bottom: 14px;
}

.stat--slate .stat__icon { background: #EDEFF4; color: var(--slate); }
.stat--ok .stat__icon { background: var(--ok-bg); color: var(--ok); }
.stat--warn .stat__icon { background: var(--warn-bg); color: var(--warn); }

.stat__value { font-family: var(--font-display); font-size: 30px; font-weight: 800; letter-spacing: -.035em; line-height: 1; }
.stat__label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 9px; }
.stat__note { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.stat__note b { color: var(--ok); }

/* ---------------- Grid areas ---------------- */

.cols { display: grid; gap: 16px; margin-top: 16px; }
.cols--2-1 { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.cols--1-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------------- Chart ---------------- */

.chart { display: flex; align-items: flex-end; gap: 10px; height: 190px; padding: 8px 2px 0; }

.chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 9px; min-width: 0; }

.chart__bar {
    width: 100%;
    max-width: 46px;
    border-radius: 8px 8px 4px 4px;
    background: linear-gradient(180deg, var(--brand) 0%, var(--brand-600) 100%);
    min-height: 4px;
    position: relative;
    transition: filter .15s;
}
.chart__bar:hover { filter: brightness(1.08); }
.chart__bar--empty { background: var(--line); }

.chart__val {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-2);
}

.chart__label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }

/* Category distribution list */
.dist li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 11px 0; border-bottom: 1px dashed var(--line-2); }
.dist li:last-child { border-bottom: 0; }
.dist__name { font-size: 14px; font-weight: 600; }
.dist__num { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.dist__bar { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.dist__fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), #FFA45C); }

/* ---------------- Tables ---------------- */

.table-wrap { overflow-x: auto; }

.table { width: 100%; font-size: 14.5px; }

.table th {
    text-align: left;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    background: var(--surface-2);
}

.table td { padding: 14px 18px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }

.table__book { display: flex; align-items: center; gap: 13px; min-width: 230px; }
.table__thumb { width: 42px; flex: none; }
.table__thumb .cover { border-radius: 6px; box-shadow: var(--sh-1); }
.table__thumb .cover__initials, .table__thumb .cover__brand, .table__thumb .cover__title { display: none; }
.table__thumb .cover__code { font-size: 7px; margin-left: 8px; }
.table__thumb .cover__fallback { padding: 7px; }
.table__book b { display: block; font-size: 14.5px; font-weight: 700; line-height: 1.3; }
.table__book span { font-size: 12.5px; color: var(--muted); }

.table__actions { display: flex; gap: 6px; justify-content: flex-end; }

.iconlink {
    width: 34px; height: 34px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--surface);
    display: grid; place-items: center;
    color: var(--ink-2);
    cursor: pointer;
    transition: all .14s;
}
.iconlink:hover { border-color: var(--brand); color: var(--brand-700); background: var(--brand-050); }
.iconlink--danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }

/* ---------------- Toolbar ---------------- */

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line-2);
}

.toolbar .searchbar { box-shadow: none; flex: 1 1 220px; padding: 4px 6px 4px 14px; }
.toolbar .searchbar input { padding: 8px 0; font-size: 14.5px; }
.toolbar select {
    padding: 10px 13px;
    border-radius: 999px;
    border: 1.5px solid var(--line);
    background: var(--surface);
    font-size: 14px;
    cursor: pointer;
}
.toolbar select:focus { outline: none; border-color: var(--brand); }

/* ---------------- Upload page ---------------- */

.upload-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }

.dropzone {
    position: relative;
    border: 2px dashed var(--line);
    border-radius: var(--r-lg);
    background: var(--surface-2);
    padding: 30px 22px;
    text-align: center;
    cursor: pointer;
    transition: border-color .16s, background .16s;
}

.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-050); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.dropzone__icon {
    width: 48px; height: 48px;
    margin: 0 auto 12px;
    border-radius: 14px;
    background: var(--brand-050);
    color: var(--brand);
    display: grid; place-items: center;
}
.dropzone.is-over .dropzone__icon { background: #fff; }

.dropzone b { display: block; font-size: 15px; }
.dropzone span { font-size: 13px; color: var(--muted); display: block; margin-top: 5px; }

.dropzone__file {
    display: none;
    align-items: center;
    gap: 12px;
    text-align: left;
    padding: 12px 14px;
    margin-top: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}
.dropzone__file.is-set { display: flex; }
.dropzone__file .fileicon {
    width: 36px; height: 44px; flex: none;
    border-radius: 5px;
    background: var(--danger-bg);
    color: var(--danger);
    display: grid; place-items: center;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    border: 1px solid #F2CFCF;
}
.dropzone__file b { font-size: 14px; word-break: break-all; }
.dropzone__file span { font-size: 12.5px; color: var(--muted); margin: 0; }

.cover-picker { display: flex; gap: 16px; align-items: flex-start; }
.cover-picker__preview { width: 116px; flex: none; }
.cover-picker__preview .cover { border-radius: 10px; border: 1px solid var(--line); box-shadow: var(--sh-1); }
.cover-picker__preview .placeholder {
    aspect-ratio: 3/4;
    border-radius: 10px;
    border: 1.5px dashed var(--line);
    background: var(--surface-2);
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--muted);
    font-size: 11px;
    padding: 10px;
    line-height: 1.5;
}

.progress {
    display: none;
    height: 8px;
    border-radius: 99px;
    background: var(--line-2);
    overflow: hidden;
    margin-top: 16px;
}
.progress.is-on { display: block; }
.progress__bar { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--brand), #FFA45C); transition: width .2s ease; }

.tips li { display: flex; gap: 10px; font-size: 13.5px; color: var(--ink-2); padding: 10px 0; border-bottom: 1px dashed var(--line-2); }
.tips li:last-child { border-bottom: 0; }
.tips i { color: var(--brand); font-style: normal; font-weight: 700; }

/* ---------------- Switch ---------------- */

.switch { display: flex; align-items: center; gap: 11px; cursor: pointer; padding: 9px 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
    width: 42px; height: 24px; border-radius: 99px;
    background: var(--line); position: relative; flex: none;
    transition: background .18s;
}
.switch__track::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; box-shadow: var(--sh-1);
    transition: transform .18s cubic-bezier(.3, 1.4, .5, 1);
}
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--brand); outline-offset: 2px; }
.switch__text b { display: block; font-size: 14px; }
.switch__text span { font-size: 12.5px; color: var(--muted); }

/* ---------------- Request detail ---------------- */

.req-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.req-avatar {
    width: 52px; height: 52px; border-radius: 15px; flex: none;
    background: linear-gradient(150deg, var(--brand), var(--brand-700));
    color: #fff; display: grid; place-items: center;
    font-family: var(--font-display); font-size: 20px; font-weight: 800;
}
.req-quote {
    border-left: 3px solid var(--brand);
    padding: 4px 0 4px 16px;
    color: var(--ink-2);
    white-space: pre-line;
    line-height: 1.7;
    margin: 6px 0 0;
}

.kv { display: grid; grid-template-columns: 128px 1fr; gap: 12px 16px; font-size: 14.5px; }
.kv dt { font-family: var(--font-mono); font-size: 10px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); padding-top: 3px; }
.kv dd { margin: 0; font-weight: 500; }

/* ---------------- Admin login ---------------- */

.admin-auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 30px 20px;
    background:
        radial-gradient(60% 60% at 80% 10%, rgba(255, 106, 0, .28) 0%, transparent 60%),
        linear-gradient(160deg, #171C29 0%, #10141F 100%);
}

.admin-auth__card {
    width: 100%;
    max-width: 404px;
    background: var(--surface);
    border-radius: var(--r-xl);
    padding: 36px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, .4);
}

.admin-auth__card h1 { font-size: 25px; letter-spacing: -.03em; margin: 16px 0 6px; }
.admin-auth__back { display: block; text-align: center; margin-top: 22px; font-size: 13.5px; color: rgba(255, 255, 255, .55); }
.admin-auth__back:hover { color: #fff; }

/* ---------------- Responsive ---------------- */

@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cols--2-1, .cols--1-1 { grid-template-columns: 1fr; }
    .upload-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .admin { grid-template-columns: 1fr; }
    .side {
        position: fixed;
        z-index: 80;
        top: 0; bottom: 0; left: 0;
        width: 252px;
        transform: translateX(-100%);
        transition: transform .24s cubic-bezier(.22, 1, .36, 1);
        box-shadow: 0 0 60px rgba(0, 0, 0, .4);
    }
    .side.is-open { transform: none; }
    .side-toggle { display: grid; }
    .admin-content { padding: 20px 18px 40px; }
    .topbar { padding: 12px 18px; }
}

@media (max-width: 560px) {
    .stats { grid-template-columns: 1fr; }
    .topbar__actions .btn span { display: none; }
    .kv { grid-template-columns: 1fr; gap: 4px 0; }
    .kv dd { margin-bottom: 10px; }
}
