/* VideoKitt — app dashboard UI */

:root {
    --bg: #eef0f3;
    --surface: #fff;
    --sidebar: #1a1d24;
    --sidebar-hover: #252932;
    --sidebar-active: #2d3340;
    --sidebar-text: #9aa3b2;
    --sidebar-text-active: #fff;
    --border: #dde1e6;
    --text: #1a1d24;
    --text-muted: #6b7280;
    --accent: #6d4cf0;
    --accent-hover: #5a3cd6;
    --ok: #16a34a;
    --ok-bg: #ecfdf3;
    --warn: #ca8a04;
    --warn-bg: #fefce8;
    --bad: #dc2626;
    --bad-bg: #fef2f2;
    --idle: #6b7280;
    --idle-bg: #f3f4f6;
    --sidebar-w: 220px;
    --topbar-h: 52px;
    --radius: 6px;
    --font: 'IBM Plex Sans', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App shell ── */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    transition: transform 0.2s;
}

.sidebar-brand {
    padding: 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
}

.brand-mark {
    width: 30px;
    height: 30px;
    background: var(--accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
}

.nav-group { margin-bottom: 20px; }

.nav-label {
    display: block;
    padding: 4px 10px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #5c6470;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
}

.nav-item.active svg { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.sidebar-foot {
    padding: 12px 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    text-decoration: none;
}

.user-chip:hover {
    background: var(--sidebar-hover);
    text-decoration: none;
    color: #fff;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--sidebar-active);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.user-info { display: flex; flex-direction: column; }

.user-name { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.2; }
.user-role { font-size: 11px; color: #5c6470; }

.app-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text);
}

.sidebar-toggle svg { width: 20px; height: 20px; }

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.content {
    padding: 20px;
    flex: 1;
}

/* ── Grid / layout helpers ── */

.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-main-side { display: grid; grid-template-columns: 1fr 420px; gap: 14px; }
.mt-14 { margin-top: 14px; }
.mt-20 { margin-top: 20px; }
.mb-14 { margin-bottom: 14px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-center { text-align: center; }
.text-mono { font-family: ui-monospace, monospace; font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Panel (card) ── */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    min-height: 44px;
}

.panel-head h2,
.panel-head h3 {
    font-size: 13px;
    font-weight: 600;
}

.panel-body { padding: 16px; }
.panel-body-flush { padding: 0; }

.panel-foot {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Stat boxes ── */

.stat-box { padding: 16px; }

.stat-box .val {
    font-size: 26px;
    font-weight: 600;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-box .lbl {
    font-size: 12px;
    color: var(--text-muted);
}

.stat-box .sub {
    font-size: 11px;
    margin-top: 6px;
}

.stat-ok .val { color: var(--ok); }
.stat-warn .val { color: var(--warn); }
.stat-bad .val { color: var(--bad); }

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-ghost {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-ghost:hover { background: #f5f6f8; color: var(--text); }

.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Forms ── */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.field .hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
}

.check-row:hover { border-color: var(--accent); }
.check-row input { accent-color: var(--accent); }

.check-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* ── Table ── */

.table-scroll { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.data th,
table.data td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    background: #fafbfc;
}

table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fafbfc; }

table.data .actions { text-align: right; white-space: nowrap; }

/* ── Badges ── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.badge i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-ok i { background: var(--ok); }

.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-warn i { background: var(--warn); }

.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-bad i { background: var(--bad); }

.badge-idle { background: var(--idle-bg); color: var(--idle); }
.badge-idle i { background: var(--idle); }

.tag {
    display: inline-block;
    padding: 2px 7px;
    background: var(--idle-bg);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

.tag-primary { background: #efeafe; color: var(--accent); }

/* ── Upload zone ── */

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.over {
    border-color: var(--accent);
    background: #f4f1ff;
}

.dropzone p { color: var(--text-muted); font-size: 13px; margin-top: 6px; }
.dropzone strong { font-size: 14px; }
.dropzone input { display: none; }

.dropzone-sm {
    padding: 24px 16px;
}

.dropzone-sm strong { font-size: 13px; }
.dropzone-sm p { font-size: 12px; }

/* ── Progress ── */

.progress {
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress > span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
}

.queue-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.queue-row:last-child { border-bottom: none; }
.queue-row .info { flex: 1; min-width: 0; }
.queue-row .info strong { display: block; font-weight: 500; }
.queue-row .info span { font-size: 12px; color: var(--text-muted); }
.queue-row .bar-wrap { width: 120px; }

/* ── Replica / server list ── */

.mirror-row {
    display: grid;
    grid-template-columns: 140px 90px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.mirror-row:last-child { border-bottom: none; }
.mirror-row .host { font-weight: 600; }

/* ── Activity log ── */

.log-list { list-style: none; }

.log-item {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.log-item:last-child { border-bottom: none; }

.log-item time {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

/* ── Copy input ── */

.copy-row {
    display: flex;
    gap: 6px;
}

.copy-row input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: ui-monospace, monospace;
    font-size: 12px;
    background: #fafbfc;
}

/* ── Toolbar ── */

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.toolbar .search {
    flex: 1;
    max-width: 260px;
}

.toolbar .search input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
}

.toolbar .spacer { flex: 1; }

/* ── Tabs (inside .panel) ── */

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    flex-wrap: wrap;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
}

.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-divider {
    border-top: 1px solid var(--border);
}

.upload-progress {
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.upload-progress .queue-row { border-bottom: none; }

table.data .col-check {
    width: 36px;
    text-align: center;
    padding-left: 14px;
    padding-right: 8px;
}

table.data .col-check input { accent-color: var(--accent); }

.input-inline {
    width: 100%;
    max-width: 280px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
}

.input-inline:focus {
    outline: none;
    border-color: var(--accent);
}

.input-inline:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

table.data tr.is-off td { opacity: 0.45; }

table.data tr.is-off .input-inline { pointer-events: none; }

/* ── Empty ── */

.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ── Auth ── */

.auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg);
}

.auth-box {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
}

.auth-box h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.auth-box .sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.auth-foot {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.auth-foot a { color: var(--text-muted); }

/* ── Toggle switch ── */

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    gap: 12px;
}

.toggle-row:last-child { border-bottom: none; }

.toggle-row span { color: var(--text-muted); font-size: 12px; display: block; }

/* ── Responsive ── */

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-main-side { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .grid-2, .grid-3, .grid-4, .check-grid, .field-row { grid-template-columns: 1fr; }
    .mirror-row { grid-template-columns: 1fr; gap: 6px; }
}

/* ── Flash / misc ── */

.flash {
    padding: 11px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
}
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: #bbf7d0; }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: #fecaca; }

[hidden] { display: none !important; }

.guide {
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.6;
}
.guide h4 { font-size: 12px; color: var(--text); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.guide ol, .guide ul { padding-left: 18px; margin: 6px 0; }
.guide li { margin-bottom: 4px; }
.guide code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-family: ui-monospace, monospace; font-size: 11px; }
.guide strong { color: var(--text); }

.test-result { margin-top: 10px; font-size: 12px; display: none; }
.test-result.show { display: block; }
.test-result.ok { color: var(--ok); }
.test-result.bad { color: var(--bad); }

.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 14px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--text);
    background: var(--surface);
}
.pagination a:hover { background: #f5f6f8; text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .disabled { opacity: 0.45; pointer-events: none; }

.error-text {
    color: var(--bad);
    font-size: 12px;
    background: var(--bad-bg);
    border: 1px solid #fecaca;
    border-radius: 4px;
    padding: 6px 8px;
    margin-top: 6px;
    word-break: break-word;
    white-space: pre-wrap;
}

.log-item .error-text { margin-top: 6px; }

.upload-item .meta { font-size: 12px; color: var(--text-muted); }

.spinner {
    width: 13px; height: 13px;
    border: 2px solid rgba(0,0,0,0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.7s linear infinite;
    vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dz-disabled { opacity: 0.55; pointer-events: none; }

/* ── Video-specific ── */

.quality-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
@media (max-width: 768px) { .quality-grid { grid-template-columns: repeat(2, 1fr); } }

.q-chip {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
}
.q-chip:hover { border-color: var(--accent); }
.q-chip input { accent-color: var(--accent); }
.q-chip .q-name { font-weight: 600; }
.q-chip .q-meta { font-size: 11px; color: var(--text-muted); }

.video-thumb {
    width: 92px;
    height: 52px;
    border-radius: 4px;
    object-fit: cover;
    background: #11131a;
    flex-shrink: 0;
    display: block;
}
.video-cell { display: flex; align-items: center; gap: 12px; }
.video-thumb-fallback {
    width: 92px; height: 52px; border-radius: 4px; background: #11131a;
    display: flex; align-items: center; justify-content: center; color: #4b5563; flex-shrink: 0;
}
.video-thumb-fallback svg { width: 22px; height: 22px; }

/* ── Public watch / player ── */

.watch-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #0f1115;
    color: #e5e7eb;
}
.watch-header {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
}
.watch-logo { font-weight: 600; font-size: 15px; color: #fff; text-decoration: none; }
.watch-content { flex: 1; max-width: 1000px; width: 100%; margin: 0 auto; padding: 24px 20px; }
.player-shell { background: #000; border-radius: 8px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,0.4); }
.player-shell video { width: 100%; display: block; }
.watch-meta { margin-top: 18px; }
.watch-meta h1 { font-size: 20px; font-weight: 600; color: #fff; margin-bottom: 8px; }
.watch-tags { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: #9aa3b2; font-size: 13px; }
.watch-tags .tag { background: rgba(255,255,255,0.08); color: #cbd5e1; }
.watch-desc { margin-top: 14px; color: #9aa3b2; font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.watch-footer { text-align: center; padding: 16px; font-size: 12px; color: #6b7280; }
.watch-processing {
    aspect-ratio: 16/9; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; color: #9aa3b2; background: #11131a;
}
.embed-page { margin: 0; background: #000; }
.embed-page .player-shell { border-radius: 0; height: 100vh; }
.embed-page video { height: 100vh; object-fit: contain; }

:root { --plyr-color-main: #6d4cf0; }
