/* VOD Server Web GUI - Dark Theme */
:root {
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-dim: rgba(99, 102, 241, 0.15);
    --success: #22c55e;
    --success-dim: rgba(34, 197, 94, 0.15);
    --warning: #f59e0b;
    --warning-dim: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.15);
    --info: #3b82f6;
    --info-dim: rgba(59, 130, 246, 0.15);

    --bg-body: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #283548;
    --bg-input: #0f172a;
    --bg-table-head: #162032;
    --bg-table-row-hover: rgba(99, 102, 241, 0.05);

    --border: #334155;
    --border-light: #475569;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --sidebar-width: 240px;
    --header-height: 0px;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.4);

    --transition: 150ms ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* Sidebar */
#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}
.logo svg { color: var(--primary); }

.version-badge {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.nav-menu {
    list-style: none;
    padding: 8px;
    flex: 1;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: all var(--transition);
    position: relative;
}
.nav-link:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.nav-link.active {
    background: var(--primary-dim);
    color: var(--primary);
}
.nav-link svg { flex-shrink: 0; }

.badge {
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
    font-weight: 600;
}
.badge.hidden { display: none; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.node-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--text-muted); }
.status-dot.warning { background: var(--warning); }

/* Main Content */
#main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px;
    min-height: 100vh;
}

#page-container { max-width: 1400px; }

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}
.page-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}
.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

/* Stat Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}
.stat-card .stat-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Two-column layout */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* Progress Bar */
.progress-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    width: 100%;
}
.progress-bar .progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.5s ease;
}
.progress-bar.success .progress-fill { background: var(--success); }
.progress-bar.warning .progress-fill { background: var(--warning); }
.progress-bar.danger .progress-fill { background: var(--danger); }

/* Disk usage bar */
.disk-bar {
    height: 20px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}
.disk-bar .disk-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width 0.5s ease;
}
.disk-bar .disk-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
thead th {
    background: var(--bg-table-head);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.9rem;
}
tbody tr:hover {
    background: var(--bg-table-row-hover);
}

/* Status badges */
.status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}
.status.pending     { background: var(--info-dim);    color: var(--info); }
.status.processing  { background: var(--primary-dim); color: var(--primary); }
.status.packaging   { background: var(--warning-dim); color: var(--warning); }
.status.complete    { background: var(--success-dim); color: var(--success); }
.status.failed      { background: var(--danger-dim);  color: var(--danger); }
.status.paused      { background: var(--warning-dim); color: var(--warning); }
.status.cancelled   { background: var(--danger-dim);  color: var(--text-muted); }
.status.online      { background: var(--success-dim); color: var(--success); }
.status.offline     { background: var(--danger-dim);  color: var(--danger); }
.status.unknown     { background: rgba(100,116,139,0.15); color: var(--text-muted); }
.status.ready       { background: var(--success-dim); color: var(--success); }
.status.transferring { background: var(--primary-dim); color: var(--primary); }
.status.downloading { background: var(--info-dim);    color: var(--info); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1.4;
    white-space: nowrap;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn-primary   { background: var(--primary); color: white; }
.btn-success   { background: var(--success); color: white; }
.btn-warning   { background: var(--warning); color: #000; }
.btn-danger    { background: var(--danger);  color: white; }
.btn-outline   { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm        { padding: 4px 10px; font-size: 0.78rem; }
.btn-icon      { padding: 6px; }

/* Forms */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
}
select.form-control {
    cursor: pointer;
}
textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 200ms;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 200ms;
}
.modal-overlay.active .modal {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    padding: 4px;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

/* Toast notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 280px;
    animation: slideIn 200ms ease;
}
.toast.success { background: #166534; color: #bbf7d0; border: 1px solid #22c55e; }
.toast.error   { background: #7f1d1d; color: #fecaca; border: 1px solid #ef4444; }
.toast.info    { background: #1e3a5f; color: #bfdbfe; border: 1px solid #3b82f6; }
.toast.warning { background: #713f12; color: #fef08a; border: 1px solid #f59e0b; }

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state svg {
    margin-bottom: 12px;
    opacity: 0.4;
}
.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.empty-state p {
    font-size: 0.9rem;
}

/* Utility */
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-sm      { font-size: 0.8rem; }
.text-mono    { font-family: 'SFMono-Regular', Consolas, monospace; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.hidden { display: none !important; }

/* Loading spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
    }
    #sidebar.open {
        transform: translateX(0);
    }
    #main-content {
        margin-left: 0;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
}
