/* ═══════════════════════════════════════════
   admin.css — Админка WebAR Living Book
   Дизайн-система: Lpalo (peach-paper + charcoal-ink + flat)
   Никаких теней, никаких градиентов, никаких серых.
   ═══════════════════════════════════════════ */

/* ── Variables (Lpalo tokens) ── */
:root {
    --peach: #f6e0db;
    --ink:   #000000;
    --snow:  #ffffff;

    --accent:        #ef724f;  /* Ember Orange */
    --accent-magenta: #981082;
    --accent-yellow:  #e7db4c;
    --accent-mint:    #ace2df;
    --accent-blue:    #84bfff;
    --accent-lilac:   #e69dff;

    --font-display: 'Alfa Slab One', ui-sans-serif, system-ui, sans-serif;
    --font-body:    'Manrope', ui-sans-serif, system-ui, sans-serif;

    --radius-pill:  47px;
    --radius-card:  40px;
    --radius-sm:    10px;

    --nav-w: 220px;
    --topbar-h: 72px;
}
/* ═══════════════════════════════════════════
   DARK THEME — AuthKit (frosted glass at midnight)
   Включается атрибутом data-theme="dark" на <html>.
   ═══════════════════════════════════════════ */
[data-theme="dark"] {
    /* canvas, ink, surface */
    --peach: #05060f;   /* midnight canvas */
    --ink:   #d1e4fa;   /* frost glow — текст и hairline-обводки */
    --snow:  #0e1220;   /* glass plate — elevated card surface */

    /* accents — холодная фиолетовая палитра */
    --accent:         #663af3;   /* void violet — CTA / active / err */
    --accent-magenta: #5b21b6;   /* dark violet — hover / root badge */
    --accent-yellow:  #232b3d;   /* muted navy — hover surface */
    --accent-mint:    #163b33;   /* dark teal — ok / done / selected */
    --accent-blue:    #173252;   /* dark blue — processing / sync */
    --accent-lilac:   #2a1e3f;   /* dark lilac — card-lilac */

    /* ── СТИЛЬ (не только цвет) — AuthKit ──
       Типографика: display → Space Grotesk, body/UI → Inter */
    --font-display: 'Space Grotesk', 'aeonikPro', ui-sans-serif, system-ui, sans-serif;
    --font-body:    'Inter', 'Untitled Sans', ui-sans-serif, system-ui, sans-serif;

    /* Радиусы: карточки/модалки 16px, кнопки/пилюли 999px, инпуты/бейджи 6px */
    --radius-pill: 999px;
    --radius-card: 16px;
    --radius-sm:   6px;
}

/* Текст поверх цветных акцентов остаётся светлым */
[data-theme="dark"] .badge-root,
[data-theme="dark"] .btn-primary:hover {
    color: #ffffff;
}

/* Иконки используют stroke="currentColor" — наследуют --ink (в тёмной теме светлый) */
[data-theme="dark"] .icon { color: var(--ink); }

/* Плейсхолдеры инпутов */
[data-theme="dark"] ::placeholder { color: rgba(209, 228, 250, 0.5); }

/* Стрелка select — светлая версия */
[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%23d1e4fa' stroke-width='2'/%3E%3C/svg%3E");
}

/* Инлайн-код — фиолетовая подложка */
[data-theme="dark"] code {
    background: rgba(102, 58, 243, 0.28);
}

/* ── СТИЛЬ AuthKit: фон canvas с halo-подсветкой сверху ── */
[data-theme="dark"] body {
    background:
        radial-gradient(1100px 480px at 50% -8%, rgba(124, 145, 182, 0.16), transparent 62%),
        var(--peach);
}

/* ── СТИЛЬ AuthKit: 2px сплошной чёрный → 1px inset-волосяная граница ──
   Lpalo использует толстые 2px чёрные обводки; AuthKit — мягкие 1px hairline
   из холодного сине-белого. Меняем толщину и цвет, не трогая light-тему. */
[data-theme="dark"] .card,
[data-theme="dark"] .pill,
[data-theme="dark"] .btn,
[data-theme="dark"] .pill-icon,
[data-theme="dark"] .badge,
[data-theme="dark"] .toast,
[data-theme="dark"] .dropzone,
[data-theme="dark"] .file-card,
[data-theme="dark"] .provider-card,
[data-theme="dark"] .job-card,
[data-theme="dark"] .tgt-card,
[data-theme="dark"] .combobox-dropdown,
[data-theme="dark"] .cover-bar,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    border-color: rgba(186, 215, 247, 0.12);
    border-width: 1px;
}

/* Разделители (nav / topbar / footer / таблицы) → 1px hairline */
[data-theme="dark"] #nav { border-right-color: rgba(186, 215, 247, 0.14); border-right-width: 1px; }
[data-theme="dark"] #topbar { border-bottom-color: rgba(186, 215, 247, 0.14); border-bottom-width: 1px; }
[data-theme="dark"] .nav-footer { border-top-color: rgba(186, 215, 247, 0.14); border-top-width: 1px; }
[data-theme="dark"] .card-header { border-bottom-color: rgba(186, 215, 247, 0.12); border-bottom-width: 1px; }
[data-theme="dark"] .card-footer { border-top-color: rgba(186, 215, 247, 0.12); border-top-width: 1px; }
[data-theme="dark"] th, [data-theme="dark"] td { border-bottom-color: rgba(186, 215, 247, 0.10); border-bottom-width: 1px; }
[data-theme="dark"] .pagination-bar { border-top-color: rgba(186, 215, 247, 0.12); border-top-width: 1px; }

/* ── СТИЛЬ AuthKit: кнопки — 1px inset hairline вместо обычного border ──
   Дизайн: кнопки обводятся внутренней волосяной линией rgba(186,215,247,0.12),
   а не сплошным border'ом. Переводим интерактив на box-shadow. */
[data-theme="dark"] .pill,
[data-theme="dark"] .btn,
[data-theme="dark"] .pill-icon,
[data-theme="dark"] .btn-icon,
[data-theme="dark"] .link-chip {
    border: none;
    box-shadow: inset 0 0 0 1px rgba(186, 215, 247, 0.12);
}

/* ── СТИЛЬ AuthKit: радиусы бейджей → 6px ──
   Дизайн: buttons → 999px, badges/tags → 6px. В Lpalo бейджи делили
   --radius-pill с кнопками, из-за чего в тёмной теме стали круглыми. */
[data-theme="dark"] .badge,
[data-theme="dark"] .job-status,
[data-theme="dark"] .provider-balance {
    border-radius: 6px;
    border-color: rgba(186, 215, 247, 0.12);
    border-width: 1px;
}

/* ── СТИЛЬ AuthKit: frost-glass elevation вместо «плоско» ──
   Карточки читаются как стеклянные пластины, подсвеченные изнутри,
   а не как бумажные панели. Elevation через inset glow + мягкое halo. */
[data-theme="dark"] .card {
    background: rgba(14, 18, 32, 0.82);
    backdrop-filter: blur(12px);
    box-shadow:
        inset 0 1px 1px rgba(216, 236, 248, 0.12),
        inset 0 24px 48px rgba(168, 216, 245, 0.04),
        0 16px 32px rgba(0, 0, 0, 0.3);
}

/* Модалка — почти непрозрачное deep glass с тройным стеком теней */
[data-theme="dark"] #modal {
    background: rgba(5, 6, 15, 0.97);
    box-shadow:
        inset 0 1px 1px rgba(216, 236, 248, 0.2),
        inset 0 24px 48px rgba(168, 216, 245, 0.06),
        0 16px 32px rgba(0, 0, 0, 0.3);
}

/* Цветные карточки сохраняют свои заливки (не затираются glass-фоном .card) */
[data-theme="dark"] .card-accent  { background: var(--accent); }
[data-theme="dark"] .card-mint    { background: var(--accent-mint); }
[data-theme="dark"] .card-blue    { background: var(--accent-blue); }
[data-theme="dark"] .card-lilac   { background: var(--accent-lilac); }
[data-theme="dark"] .card-yellow  { background: var(--accent-yellow); }

/* Скрим модалки плотнее на тёмном */
[data-theme="dark"] #modal-overlay { background: rgba(0, 0, 0, 0.65); }

/* ── Icon system (Lpalo line-art SVGs) ── */
.icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    width: 20px; height: 20px;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }
.icon-brand { width: 32px; height: 32px; }

/* Spinner animation */
.icon-spin {
    animation: icon-spin 1s linear infinite;
}
@keyframes icon-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--ink);
    background: var(--peach);
    -webkit-font-smoothing: antialiased;
}

/* ── App layout ── */
#app { display: flex; height: 100vh; }

/* ═══════════════════════════════════════════
   NAVIGATION — left pill column
   ═══════════════════════════════════════════ */
#nav {
    width: var(--nav-w);
    min-width: var(--nav-w);
    display: flex;
    flex-direction: column;
    padding: var(--spacing-24, 24px) var(--spacing-16, 16px);
    gap: var(--spacing-24, 24px);
    border-right: 2px solid var(--ink);
    background: var(--peach);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 4px;
}
.nav-brand-icon { font-size: 32px; }
.nav-brand-text {
    font-family: var(--font-display);
    font-size: 25px;
    line-height: 1.24;
    color: var(--ink);
}

.nav-pills {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Pill button */
.pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 500;
    color: var(--ink);
    background: var(--snow);
    border: 2px solid var(--ink);
    border-radius: var(--radius-pill);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s, transform 0.12s;
    text-align: left;
    width: 100%;
}
.pill:hover { background: var(--accent-yellow); }
.pill.active { background: var(--accent); color: var(--ink); }
.pill:active { transform: scale(0.97); }

/* Навигация: светлая тема — крупное скругление (Lpalo pill), тёмная — умеренное (AuthKit) */
[data-theme="dark"] #nav .pill {
    border-radius: 14px;
}

.nav-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 2px solid var(--ink);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ═══════════════════════════════════════════
   MAIN
   ═══════════════════════════════════════════ */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

#topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-30, 30px);
    border-bottom: 2px solid var(--ink);
}

.heading {
    font-family: var(--font-display);
    font-size: 34px;
    line-height: 1.16;
    color: var(--ink);
}
.subheading {
    font-family: var(--font-display);
    font-size: 25px;
    line-height: 1.24;
    color: var(--ink);
}

#topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

#view {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-30, 30px);
    -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════
   CARDS — outlined white cards (no shadows)
   ═══════════════════════════════════════════ */
.card {
    background: var(--snow);
    border: 2px solid var(--ink);
    border-radius: var(--radius-card);
    padding: 0;
    margin-bottom: var(--spacing-24, 24px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 2px solid var(--ink);
    flex-wrap: wrap;
    gap: 12px;
    color: var(--ink);
}

.card-body {
    padding: 24px;
    color: var(--ink);
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 2px solid var(--ink);
    color: var(--ink);
}

/* Color-card variants */
.card-accent  { background: var(--accent); color: var(--ink); }
.card-mint    { background: var(--accent-mint); color: var(--ink); }
.card-blue    { background: var(--accent-blue); color: var(--ink); }
.card-lilac   { background: var(--accent-lilac); color: var(--ink); }
.card-yellow  { background: var(--accent-yellow); color: var(--ink); }

/* ═══════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    font-family: var(--font-body);
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1.5px solid var(--ink);
}

th {
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink);
}

td { color: var(--ink); }

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--accent-mint); }

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    background: var(--snow);
    border: 2px solid var(--ink);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background 0.12s, transform 0.12s;
    white-space: nowrap;
}
.btn:hover { background: var(--accent-yellow); }
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-magenta); color: var(--snow); }

.btn-danger { background: var(--snow); }
.btn-danger:hover { background: var(--accent); }

.btn-sm {
    padding: 6px 16px;
    font-size: 12px;
    width: auto;
    gap: 2px;
}

/* Pill в таблице — не растягивать на всю ячейку */
td .pill {
    width: auto;
    gap: 2px;
}

.btn-icon {
    padding: 8px;
    min-width: 36px;
    justify-content: center;
    border-radius: var(--radius-pill);
    font-size: 16px;
}

.pill-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 18px;
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--snow);
    border: 2px solid var(--ink);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background 0.12s;
}
.pill-icon:hover { background: var(--accent-yellow); }
.pill-icon.quiz-on { background: var(--accent-mint); }
.pill-icon.quiz-on:hover { background: var(--accent); }

/* ═══════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

input[type="text"],
input[type="url"],
input[type="number"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    background: var(--snow);
    border: 2px solid var(--ink);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.12s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    background: var(--accent-yellow);
}
::placeholder { color: rgba(0,0,0,0.55); font-weight: 400; }

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%23000' stroke-width='2'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* Search bar */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding: 0 24px;
}
.search-bar input { max-width: 320px; }

/* ═══════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 700;
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-pill);
    background: var(--snow);
    color: var(--ink);
}
.badge-ok    { background: var(--accent-mint); color: var(--ink); }
.badge-warn  { background: var(--accent-yellow); color: var(--ink); }
.badge-err   { background: var(--accent); color: var(--ink); }
.badge-root  { background: var(--accent-magenta); color: var(--snow); }

/* ═══════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════ */
#modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
}
#modal-overlay.hidden { display: none; }

#modal {
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    color: var(--ink);
}
#modal-title {
    font-family: var(--font-display);
    font-size: 25px;
    color: var(--ink);
}
#modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    color: var(--ink);
}
#modal-footer {
    color: var(--ink);
}

/* ═══════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════ */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    background: var(--snow);
    border: 2px solid var(--ink);
    border-radius: var(--radius-pill);
    min-width: 240px;
    max-width: 380px;
    animation: toast-in 0.2s ease;
}
.toast-ok   { border-color: var(--ink); background: var(--accent-mint); }
.toast-err  { border-color: var(--ink); background: var(--accent); }

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ═══════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--ink);
}
.empty-state-icon   { font-size: 48px; margin-bottom: 12px; }
.empty-state-text   { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.empty-state-hint   { font-size: 14px; font-weight: 400; opacity: 0.6; }

/* ═══════════════════════════════════════════
   COMBOBOX
   ═══════════════════════════════════════════ */
.combobox-wrap { position: relative; }
.combobox-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 200px;
    overflow-y: auto;
    background: var(--snow);
    border: 2px solid var(--ink);
    border-radius: var(--radius-sm);
    display: none;
}

/* В карточке страниц — дропдауны приклеены к карточке, не обрезаются #view */
.card-book-detail .combobox-dropdown {
    position: fixed;
    max-height: 340px;
    min-width: 260px;
    z-index: 60;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    border: 2px solid var(--ink);
    border-radius: var(--radius-sm);
    box-shadow: none;
}

/* Таблица внутри card-book-detail — строки не обрезают контент */
.card-book-detail td {
    overflow: visible;
}
.card-book-detail .combobox-wrap {
    overflow: visible;
}
.combobox-dropdown.open { display: block; }
.combobox-option {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--ink);
    border-bottom: 1.5px solid var(--ink);
}
.combobox-option:last-child { border-bottom: none; }
.combobox-option:hover { background: var(--accent-yellow); }

/* Combobox option row with thumbnail */
.cbx-option-row {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 6px 10px !important;
}
.cbx-option-thumb-wrap {
    flex-shrink: 0;
    width: 48px;
    height: 36px;
    border-radius: 4px;
    overflow: hidden;
    border: 1.5px solid var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--peach);
}
.cbx-option-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.cbx-option-thumb-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-yellow);
}
.cbx-option-thumb-empty {
    border-style: dashed;
}
.cbx-option-info {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    line-height: 1.4;
}

.combobox-create {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
    background: var(--accent-mint);
    border-top: 2px solid var(--ink);
    text-align: center;
}
.combobox-create:hover { background: var(--accent); }

/* ═══════════════════════════════════════════
   DROPZONE
   ═══════════════════════════════════════════ */
.dropzone {
    border: 2px dashed var(--ink);
    border-radius: var(--radius-card);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: background 0.12s;
    margin-bottom: 16px;
}
.dropzone:hover, .dropzone.dragover { background: var(--accent-yellow); }
.dropzone-icon  { font-size: 32px; margin-bottom: 8px; }
.dropzone-text  { font-size: 14px; font-weight: 500; color: var(--ink); }
.dropzone-hint  { font-size: 12px; color: var(--ink); opacity: 0.5; margin-top: 4px; }

/* ═══════════════════════════════════════════
   FILE GRID
   ═══════════════════════════════════════════ */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 0 24px 24px;
}
.file-card {
    background: var(--snow);
    border: 2px solid var(--ink);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.file-card-thumb {
    width: 100%;
    height: 140px;
    border-radius: 6px;
    overflow: hidden;
    border: 1.5px solid var(--ink);
    background: var(--peach);
    display: flex;
    align-items: center;
    justify-content: center;
}
.file-card-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.file-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-yellow);
}
.file-card-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--ink);
    word-break: break-all;
}
.file-card-meta { font-size: 11px; color: var(--ink); opacity: 0.5; }

/* ═══════════════════════════════════════════
   BOOK DETAIL PAGES — tall card for 2+ pages
   ═══════════════════════════════════════════ */
.card-book-detail .card-body {
    min-height: 320px;
    padding: 30px 24px;
}
.card-book-detail td,
.card-book-detail th {
    padding-top: 18px;
    padding-bottom: 18px;
}

/* ═══════════════════════════════════════════
   COVER BAR
   ═══════════════════════════════════════════ */
/* ═══════════════════════════════════════════
   COVER BAR
   ═══════════════════════════════════════════ */
.cover-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    margin: 0 24px 16px;
    background: var(--accent-mint);
    border: 2px solid var(--ink);
    border-radius: var(--radius-sm);
    color: var(--ink);
}
.cover-bar-preview {
    width: 64px; height: 64px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid var(--ink);
}

/* ═══════════════════════════════════════════
   STATUS DOT
   ═══════════════════════════════════════════ */
.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    border: 1.5px solid var(--ink);
}
.status-dot.ok     { background: var(--accent-mint); }
.status-dot.warn   { background: var(--accent-yellow); }
.status-dot.bad    { background: var(--accent); }
.status-dot.sync   { background: var(--accent-blue); animation: pulse 1s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── code style ── */
code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    background: var(--accent-yellow);
    padding: 2px 6px;
    border-radius: 4px;
}

/* ═══════════════════════════════════════════
   TARGET GALLERY — миниатюры в модалке ключа
   ═══════════════════════════════════════════ */
.tgt-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    padding: 4px 0;
    margin: 8px 0;
}

.tgt-card {
    position: relative;
    border: 2px solid var(--ink);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
    background: var(--snow);
}
.tgt-card:hover { transform: scale(1.03); border-color: var(--accent); }
.tgt-card:active { transform: scale(0.98); }

.tgt-card-selected {
    border-color: var(--accent);
    background: var(--accent-mint);
}

.tgt-card-img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    display: block;
}

.tgt-card-placeholder {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-yellow);
}

.tgt-card-label {
    padding: 6px 8px;
    line-height: 1.2;
}

.tgt-card-check {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--ink);
}

/* ═══════════════════════════════════════════
   TARGET TABLE THUMBNAILS
   ═══════════════════════════════════════════ */
.tgt-table-thumb-wrap {
  width: 52px;
  height: 40px;
  border-radius: 6px;
  border: 1.5px solid var(--ink);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--peach);
}
.tgt-table-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Book cover thumbnail in table */
.book-cover-thumb-wrap {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--snow);
}
.book-cover-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Page thumbnail in table */
.page-thumb-wrap {
  width: 52px;
  height: 40px;
  border-radius: 6px;
  border: 1.5px solid var(--ink);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--peach);
}
.page-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Video table thumbnail */
.vid-table-thumb-wrap {
  width: 64px;
  height: 44px;
  border-radius: 6px;
  border: 1.5px solid var(--ink);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--peach);
}
.vid-table-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ═══════════════════════════════════════════
   PAGINATION BAR
   ═══════════════════════════════════════════ */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-top: 2px solid var(--ink);
    color: var(--ink);
    flex-wrap: wrap;
    gap: 10px;
}
.pagination-bar select {
    width: auto;
    padding: 6px 28px 6px 10px;
    font-size: 13px;
    border-radius: var(--radius-pill);
}

/* ═══════════════════════════════════════════
   LINK CHIPS — целевые связи (ключ↔видео)
   ═══════════════════════════════════════════ */
.link-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px 3px 4px;
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-pill);
    background: var(--snow);
    font-size: 11px;
    cursor: pointer;
    transition: background 0.12s;
}
.link-chip:hover { background: var(--accent-yellow); }
.link-chip:active { transform: scale(0.96); }

/* Highlight flash for cross-page navigation */
tr.highlight-flash td {
    animation: highlight-flash 1.8s ease-out;
}
@keyframes highlight-flash {
    0%   { background: var(--accent); }
    100% { background: transparent; }
}
.link-chip-thumb {
    width: 28px;
    height: 22px;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--peach);
    flex-shrink: 0;
}
.link-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.link-thumb-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-yellow);
}

/* ═══════════════════════════════════════════
   AI GENERATION PAGE
   ═══════════════════════════════════════════ */

.ai-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .ai-layout { grid-template-columns: 1fr; }
}

/* Provider cards */
.provider-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.provider-card {
    border: 2px solid var(--ink);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: pointer;
    text-align: center;
    background: var(--snow);
    transition: background 0.12s, transform 0.12s, border-color 0.12s;
}
.provider-card:hover { background: var(--accent-yellow); transform: scale(1.02); }
.provider-card:active { transform: scale(0.98); }
.provider-card.selected {
    border-color: var(--accent);
    background: var(--accent-mint);
}
.provider-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-style: dashed;
}
.provider-card .provider-name {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 4px;
}
.provider-card .provider-cost {
    font-size: 16px;
    margin-bottom: 6px;
}
.provider-card .provider-key-status {
    font-size: 11px;
    opacity: 0.6;
}
.provider-card .provider-balance {
    font-size: 11px;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--ink);
    display: inline-block;
    cursor: default;
}
.provider-balance.active    { background: var(--accent-mint); }
.provider-balance.exhausted { background: var(--accent); color: var(--ink); cursor: pointer; }
.provider-balance.locked    { background: var(--accent); cursor: pointer; }
.provider-balance.invalid   { background: var(--accent-yellow); }
.provider-balance.error     { background: var(--accent-yellow); opacity: 0.7; }
.provider-balance.unknown   { opacity: 0.5; }

/* API key input inline */
.key-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.key-row input {
    flex: 1;
    font-family: monospace;
    font-size: 13px;
}

/* Prompt area */
.prompt-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.prompt-area textarea {
    min-height: 100px;
    resize: vertical;
    font-family: var(--font-body);
}

/* Job list */
.job-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.job-card {
    border: 2px solid var(--ink);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    background: var(--snow);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.job-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.job-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--ink);
}
.job-status.queued { background: var(--accent-blue); }
.job-status.processing { background: var(--accent-yellow); }
.job-status.done { background: var(--accent-mint); }
.job-status.failed { background: var(--accent); }

.job-prompt {
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
    max-height: 40px;
    overflow: hidden;
    opacity: 0.7;
}

/* Анимированный индикатор генерации («Генерируется…») */
.job-progress {
    position: relative;
    height: 6px;
    border-radius: 999px;
    background: var(--accent-yellow);
    border: 1.5px solid var(--ink);
    overflow: hidden;
}
.job-progress-bar {
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    animation: job-progress 1.2s ease-in-out infinite;
}
@keyframes job-progress {
    0%   { left: -40%; }
    100% { left: 100%; }
}

.job-video-preview {
    width: 100%;
    max-height: 200px;
    border-radius: 6px;
    border: 1.5px solid var(--ink);
    background: var(--ink);
}

.job-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Sparkle animation for generate button */
@keyframes sparkle {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
.sparkle-anim .icon {
    animation: sparkle 0.5s ease-in-out infinite;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--peach); }
::-webkit-scrollbar-thumb { background: var(--ink); border-radius: 4px; }

