/* public/css/styles.css — VideoArchive uploader (Warm Beige), стиль как у VideoCatalog. */

/* ─── Theme variables ─────────────────────────────────────────────────── */

:root {
    --bg:          40 30% 96%;
    --surface:     0 0% 100%;
    --muted:       38 25% 92%;
    --border:      36 20% 86%;
    --ring:        352 55% 42%;
    --fg:          30 18% 14%;
    --fg-muted:    32 12% 42%;
    --primary:     352 55% 38%;
    --primary-fg:  40 30% 96%;
    --accent:      32 55% 62%;
    --success:     130 30% 38%;
    --warning:     35 75% 50%;
    --danger:      0 55% 52%;
    --info:        210 35% 50%;
    --shadow:      30 30% 20%;

    --radius-sm: 6px;
    --radius:    12px;
    --radius-lg: 20px;
}

/* ─── Base ────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

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

body {
    background: hsl(var(--bg));
    color: hsl(var(--fg));
    font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 12px 0;
    font-weight: 600;
    color: hsl(var(--fg));
}

/* ─── Scrollbars ──────────────────────────────────────────────────────── */

* {
    scrollbar-width: thin;
    scrollbar-color: hsl(var(--border)) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: hsl(var(--border));
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--fg-muted));
    background-clip: padding-box;
    border: 2px solid transparent;
}

/* ─── Layout ──────────────────────────────────────────────────────────── */

.page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px;
}

.header {
    border-bottom: 1px solid hsl(var(--border));
    background: hsl(var(--surface));
}

.header__row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-top: 10px;
    padding-bottom: 10px;
}

.header__titles {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    line-height: 1.2;
}

.header__title {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    color: hsl(var(--fg));
}

.header__subtitle {
    font-size: 12px;
    color: hsl(var(--fg-muted));
}

.header__user {
    display: flex;
    gap: 10px;
    align-items: center;
    color: hsl(var(--fg-muted));
    font-size: 13px;
    flex-shrink: 0;
}
.header__user .btn { padding: 6px 12px; font-size: 13px; }

/* ─── Buttons ─────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    background: hsl(var(--surface));
    color: hsl(var(--fg));
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: hsl(var(--muted)); }
.btn:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-fg));
    border: 1px solid transparent;
}
.btn--primary:hover { background: hsl(var(--primary) / 0.9); }

.btn--danger {
    background: hsl(var(--danger));
    color: #fff;
    border: 1px solid transparent;
}
.btn--danger:hover { background: hsl(var(--danger) / 0.9); }

.btn--ghost { background: transparent; border: 1px solid hsl(var(--border)); }
.btn--ghost:hover { background: hsl(var(--muted)); }

.btn--block { width: 100%; }

.btn--sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

/* Спиннер для кнопок в состоянии загрузки */
.btn.is-loading {
    pointer-events: none;
}
.btn.is-loading::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
    vertical-align: -3px;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* ─── Forms ───────────────────────────────────────────────────────────── */

.field { margin-bottom: 16px; }

.label {
    display: block;
    font-size: 13px;
    color: hsl(var(--fg-muted));
    margin-bottom: 6px;
    font-weight: 500;
}

.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    background: hsl(var(--surface));
    color: hsl(var(--fg));
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color .15s;
}
.input:focus {
    outline: 2px solid hsl(var(--ring));
    outline-offset: -1px;
    border-color: transparent;
}

/* PIN-поле: крупное, моноширинное, с разрядкой */
.input--pin {
    text-align: center;
    font-size: 26px;
    letter-spacing: 10px;
    padding: 14px;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    background: hsl(var(--muted) / 0.4);
}

/* ─── Card ────────────────────────────────────────────────────────────── */

.card {
    background: hsl(var(--surface));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 1px 2px hsl(var(--shadow) / 0.04);
}

/* ─── Login ───────────────────────────────────────────────────────────── */

.login-wrap {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.login-card {
    max-width: 420px;
    width: 100%;
    padding: 28px;
    box-shadow: 0 8px 24px hsl(var(--shadow) / 0.08);
}

.login-card__title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 6px 0;
    text-align: center;
}

.login-card__lead {
    text-align: center;
    color: hsl(var(--fg-muted));
    font-size: 13px;
    margin: 0 0 24px 0;
}

/* ─── Dropzone ────────────────────────────────────────────────────────── */

.dropzone {
    background: hsl(var(--surface));
    border: 2px dashed hsl(var(--border));
    border-radius: var(--radius);
    padding: 72px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.dropzone:hover,
.dropzone.is-dragover {
    border-color: hsl(var(--primary) / 0.55);
    background: hsl(var(--primary) / 0.04);
}

.dropzone__icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.7;
}

.dropzone__hint {
    font-size: 17px;
    font-weight: 600;
    color: hsl(var(--fg));
    margin-bottom: 6px;
}

.dropzone__sub {
    color: hsl(var(--fg-muted));
    font-size: 13px;
}

.dropzone input[type=file] { display: none; }

/* ─── Modal (как в VideoCatalog) ──────────────────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    background: hsl(var(--shadow) / 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    padding: 16px;
}

.modal__content {
    background: hsl(var(--surface));
    border-radius: var(--radius);
    padding: 24px;
    max-width: 560px;
    width: calc(100% - 32px);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px hsl(var(--shadow) / 0.25);
    position: relative;
}

.modal__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid hsl(var(--border));
}

.modal__title { font-size: 18px; font-weight: 600; margin: 0; }

.modal__close {
    background: transparent;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: hsl(var(--fg-muted));
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
}
.modal__close:hover {
    background: hsl(var(--muted));
    color: hsl(var(--fg));
}

.modal__foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid hsl(var(--border));
}

.modal__center { text-align: center; }

/* ─── Файлы (списочком) ──────────────────────────────────────────────── */

.files-list {
    background: hsl(var(--muted) / 0.4);
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    padding: 6px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 4px;
}

.file-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    font-size: 13px;
    gap: 12px;
}

.file-row__name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: hsl(var(--fg));
}

.file-row__size {
    color: hsl(var(--fg-muted));
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.file-row__error {
    color: hsl(var(--danger));
    flex-shrink: 0;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-row--total {
    border-top: 1px solid hsl(var(--border));
    margin-top: 4px;
    padding-top: 10px;
    font-weight: 500;
}

/* ─── Radio как chip-btn (стиль VideoCatalog) ────────────────────────── */

.chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip-radio {
    flex: 1;
    min-width: 110px;
    cursor: pointer;
    user-select: none;
}
.chip-radio input { display: none; }

.chip-radio__face {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid hsl(var(--border));
    background: hsl(var(--surface));
    color: hsl(var(--fg));
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, border-color .15s, color .15s;
}

.chip-radio:hover .chip-radio__face {
    border-color: hsl(var(--primary) / 0.4);
}

.chip-radio input:checked + .chip-radio__face {
    background: hsl(var(--primary));
    color: hsl(var(--primary-fg));
    border-color: hsl(var(--primary));
}

/* ─── Progress ────────────────────────────────────────────────────────── */

.progress {
    height: 10px;
    background: hsl(var(--muted));
    border-radius: 999px;
    overflow: hidden;
    margin: 12px 0 10px;
}

.progress__bar {
    height: 100%;
    width: 0%;
    background: hsl(var(--primary));
    transition: width .2s;
}

.progress__text {
    color: hsl(var(--fg-muted));
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.progress__stats {
    margin-top: 4px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.progress__heartbeat {
    margin-top: 8px;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: hsl(var(--warning) / 0.15);
    color: hsl(var(--warning));
    border: 1px solid hsl(var(--warning) / 0.4);
}

.progress__current {
    margin-top: 16px;
    font-size: 14px;
}
.progress__filename {
    font-weight: 500;
    word-break: break-all;
    color: hsl(var(--fg));
    margin-top: 2px;
}

/* ─── Success / partial-error ────────────────────────────────────────── */

.status-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: hsl(var(--success));
    color: #fff;
    font-size: 28px;
    line-height: 56px;
    text-align: center;
    margin: 4px auto 14px;
    font-weight: 700;
}
.status-icon--warn { background: hsl(var(--warning)); }

.link-box {
    display: flex;
    gap: 8px;
    margin: 14px 0 6px;
}

.link-box .input {
    flex: 1;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
    font-size: 13px;
    background: hsl(var(--muted) / 0.4);
}

.btn-copy.is-copied {
    background: hsl(var(--success));
    color: #fff;
    border-color: transparent;
}

.link-hint {
    font-size: 12px;
    color: hsl(var(--fg-muted));
    text-align: left;
}

.errors-block {
    margin-top: 16px;
    text-align: left;
}
.errors-title {
    font-size: 13px;
    color: hsl(var(--danger));
    font-weight: 500;
    margin-bottom: 6px;
}

/* ─── Inline error / toast ───────────────────────────────────────────── */

.alert {
    color: hsl(var(--danger));
    background: hsl(var(--danger) / 0.08);
    border: 1px solid hsl(var(--danger) / 0.25);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
    font-size: 13px;
}

/* ─── История загрузок ────────────────────────────────────────────────── */

.history-card {
    margin-top: 24px;
}

.history-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid hsl(var(--border));
}

.history-card__title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    transition: background .15s;
}
.history-row:hover { background: hsl(var(--muted) / 0.6); }

.history-row__time {
    font-size: 12px;
    color: hsl(var(--fg-muted));
    font-variant-numeric: tabular-nums;
    font-family: ui-monospace, monospace;
    white-space: nowrap;
}

.history-row__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-row__title {
    font-size: 14px;
    font-weight: 600;
    color: hsl(var(--fg));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-row__meta {
    font-size: 12px;
    color: hsl(var(--fg-muted));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-row__chip {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 999px;
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
    font-size: 11px;
    font-weight: 500;
    margin-right: 6px;
}

.history-row__chip--warn {
    background: hsl(var(--warning) / 0.18);
    color: hsl(35 70% 35%);
}

.history-row__copy,
.history-row__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid hsl(var(--border));
    color: hsl(var(--fg-muted));
    cursor: pointer;
    font-size: 14px;
    transition: background .15s, color .15s, border-color .15s;
    text-decoration: none;
}
.history-row__copy:hover,
.history-row__link:hover {
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
    border-color: hsl(var(--primary) / 0.4);
}
.history-row__copy.is-copied {
    background: hsl(var(--success));
    border-color: transparent;
    color: #fff;
}

.history-empty {
    text-align: center;
    color: hsl(var(--fg-muted));
    font-size: 13px;
    padding: 16px;
}

/* ─── Utility ─────────────────────────────────────────────────────────── */

.muted     { color: hsl(var(--fg-muted)); }
.hidden    { display: none !important; }
.center    { text-align: center; }
.row       { display: flex; gap: 12px; align-items: center; }
.stack     { display: flex; flex-direction: column; gap: 12px; }
.mt-8      { margin-top: 8px; }
.mt-16     { margin-top: 16px; }
.mb-8      { margin-bottom: 8px; }
.mb-16     { margin-bottom: 16px; }

/* ─── Mobile (≤600px) ─────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .page { padding: 16px 14px; }

    /* Шапка: компактнее, прячем подзаголовок чтобы не давить кнопку «Выйти» */
    .header__row { gap: 10px; padding-top: 8px; padding-bottom: 8px; }
    .header__title { font-size: 16px; }
    .header__subtitle { display: none; }
    .header__user .btn { padding: 8px 12px; font-size: 13px; }

    /* Инпуты: ≥16px чтобы iOS не зумил на focus */
    .input { font-size: 16px; padding: 12px 12px; }
    .input--pin { font-size: 28px; letter-spacing: 8px; padding: 16px; }

    /* Кнопки: тач-таргет минимум ~44px */
    .btn { padding: 12px 18px; font-size: 15px; }
    .btn--sm { padding: 8px 14px; font-size: 13px; }

    /* Drop-зона компактнее по высоте */
    .dropzone { padding: 48px 18px; }
    .dropzone__icon { font-size: 42px; margin-bottom: 12px; }
    .dropzone__hint { font-size: 16px; }
    .dropzone__sub { font-size: 13px; }

    /* Модалки: на весь экран комфортнее */
    .modal { padding: 8px; }
    .modal__content { padding: 18px 16px; max-height: 92vh; }
    .modal__head { margin-bottom: 12px; padding-bottom: 10px; }
    .modal__title { font-size: 16px; }
    .modal__foot { gap: 8px; flex-wrap: wrap; }
    .modal__foot .btn { flex: 1; }

    /* Радио-чипы: 3 в ряд на узких — позволяем переноситься, но широкие */
    .chip-radio { min-width: calc(33% - 8px); }

    /* Логин */
    .login-card { padding: 22px 18px; }
    .login-card__title { font-size: 20px; }

    /* Прогресс */
    .progress { height: 12px; }     /* проще попасть взглядом */
    .progress__filename { font-size: 13px; }

    /* Список файлов в модалке */
    .files-list { max-height: 140px; }
    .file-row { padding: 8px 10px; font-size: 13px; }

    /* Иконка статуса */
    .status-icon { width: 52px; height: 52px; line-height: 52px; font-size: 26px; }

    /* Link-box: input + кнопка copy остаются в строку, но кнопка крупнее */
    .link-box { gap: 6px; }

    /* История: дата уходит наверх, чтобы не давить ширину строки */
    .history-card { padding: 16px 14px; }
    .history-card__title { font-size: 15px; }

    .history-row {
        grid-template-columns: 1fr auto auto;
        grid-template-areas:
            "time time time"
            "body copy link";
        gap: 4px 10px;
        padding: 10px 8px;
    }
    .history-row__time { grid-area: time; }
    .history-row__body { grid-area: body; min-width: 0; }
    .history-row__copy { grid-area: copy; width: 38px; height: 38px; }
    .history-row__link { grid-area: link; width: 38px; height: 38px; }
}

/* ─── Мини-телефоны (≤360px) — ещё чуть плотнее ───────────────────────── */

@media (max-width: 360px) {
    .header__user { gap: 6px; }
    .chip-radio { min-width: calc(50% - 8px); }   /* в 2 ряда */
    .dropzone { padding: 36px 14px; }
}
