/* ─── TeacherMATT Downloader - Dark Theme (Node.js Edition) ─── */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #21262d;
    --accent: #3fb950;
    --accent-hover: #56d364;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --success: #3fb950;
    --warning: #d29922;
    --error: #f85149;
    --border: #30363d;
    --card-hover: #292e36;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
}

.container { max-width: 900px; margin: 0 auto; padding: 20px; }

.header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 0; border-bottom: 1px solid var(--border); margin-bottom: 25px;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
.header h1 { font-size: 20px; font-weight: 700; color: var(--accent); }
.header-subtitle { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.status-dot.offline { background: var(--error); }

.card {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
    transition: border-color 0.2s;
}
.card:hover { border-color: #444c56; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }

.url-input-group { display: flex; gap: 8px; }
.url-input-group input {
    flex: 1; background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 16px; font-size: 15px;
    color: var(--text-primary); outline: none; transition: border-color 0.2s;
}
.url-input-group input:focus { border-color: var(--accent); }
.url-input-group input::placeholder { color: var(--text-secondary); }

.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px;
    border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--card-hover); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #ff6b81; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.options-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.option-group { display: flex; align-items: center; gap: 6px; }
.option-group label { font-size: 13px; color: var(--text-secondary); font-weight: 600; }

select {
    background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px;
    color: var(--text-primary); outline: none; cursor: pointer;
}
select:focus { border-color: var(--accent); }

.format-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.format-badge {
    padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 600;
    cursor: pointer; border: 1px solid var(--border); background: var(--bg-primary);
    color: var(--text-secondary); transition: all 0.2s;
}
.format-badge:hover { border-color: var(--accent); color: var(--accent); }
.format-badge.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.video-info { display: none; gap: 16px; margin-top: 16px; padding: 16px; background: var(--bg-primary); border-radius: var(--radius); border: 1px solid var(--border); }
.video-info.visible { display: flex; }
.video-thumbnail { width: 160px; min-height: 90px; border-radius: var(--radius-sm); background: var(--bg-card); flex-shrink: 0; overflow: hidden; }
.video-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.video-details { flex: 1; min-width: 0; }
.video-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; line-height: 1.3; }
.video-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.video-description { font-size: 12px; color: var(--text-secondary); max-height: 48px; overflow: hidden; line-height: 1.4; }

.playlist-items { margin-top: 12px; max-height: 300px; overflow-y: auto; }
.playlist-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); transition: background 0.2s; }
.playlist-item:hover { background: var(--bg-card); }
.playlist-item-thumb { width: 40px; height: 24px; border-radius: 2px; background: var(--bg-card); flex-shrink: 0; overflow: hidden; }
.playlist-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.playlist-item-title { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playlist-item-dur { font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }

.download-section { margin-top: 8px; }
.download-item { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 8px; }
.download-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.download-title { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.download-status { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 10px; flex-shrink: 0; }
.status-queued { color: var(--text-secondary); background: var(--bg-card); }
.status-downloading { color: var(--warning); background: #2d2a1a; }
.status-processing { color: var(--accent); background: #1a2d1a; }
.status-completed { color: var(--success); background: #1a2d1a; }
.status-error { color: #fff; background: #4a1a1a; }
.status-cancelled { color: var(--text-secondary); background: var(--bg-card); }

.download-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.progress-bar { flex: 1; height: 6px; background: var(--bg-card); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-hover)); border-radius: 3px; transition: width 0.3s ease; }
.progress-text { font-size: 12px; font-weight: 600; color: var(--accent); min-width: 40px; text-align: right; }
.download-meta { display: flex; gap: 16px; font-size: 11px; color: var(--text-secondary); }
.download-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.history-list { max-height: 200px; overflow-y: auto; }
.history-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.history-item:last-child { border-bottom: none; }
.history-icon { font-size: 16px; flex-shrink: 0; }
.history-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { color: var(--text-secondary); font-size: 11px; flex-shrink: 0; }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; max-width: 350px; }
.toast-success { background: #1a3d2a; border: 1px solid var(--success); color: var(--success); }
.toast-error { background: #3d1a1a; border: 1px solid var(--error); color: var(--error); }
.toast-warning { background: #2d2a1a; border: 1px solid var(--warning); color: var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.footer { text-align: center; padding: 30px 0 20px; font-size: 12px; color: var(--text-secondary); border-top: 1px solid var(--border); margin-top: 20px; }
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

@media (max-width: 640px) {
    .container { padding: 12px; }
    .header { flex-direction: column; gap: 8px; text-align: center; }
    .url-input-group { flex-direction: column; }
    .options-row { flex-direction: column; gap: 10px; }
    .video-info.visible { flex-direction: column; }
    .video-thumbnail { width: 100%; height: 140px; }
    .download-header { flex-direction: column; gap: 6px; }
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444c56; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.downloading-active { animation: pulse 1.5s infinite; }