/* ═══════ Base ═══════ */
:root {
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-input: #1a1a25;
    --bg-hover: #1e1e2a;
    --border: #2a2a3a;
    --text: #e8e8f0;
    --text-muted: #8888a0;
    --accent: #4a9eff;
    --accent-hover: #3a8eef;
    --green: #4ade80;
    --red: #f87171;
    --orange: #fb923c;
    --yellow: #facc15;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* ═══════ Login ═══════ */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow);
}

.login-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}
.login-logo .material-icons-round { font-size: 32px; color: #fff; }

.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-form { display: flex; flex-direction: column; gap: 12px; }

.login-error, .auth-error {
    color: var(--red);
    font-size: 13px;
    min-height: 20px;
    margin-top: 4px;
}

/* ═══════ Input Group ═══════ */
.input-group {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    transition: border-color 0.2s;
}
.input-group:focus-within { border-color: var(--accent); }
.input-group .material-icons-round { color: var(--text-muted); font-size: 20px; }
.input-group input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 15px;
    padding: 12px 0;
    outline: none;
    font-family: inherit;
}
.input-group input::placeholder { color: var(--text-muted); }

/* ═══════ Buttons ═══════ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary .material-icons-round { font-size: 20px; }

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}
.btn-sm:hover { background: var(--bg-hover); }
.btn-sm .material-icons-round { font-size: 16px; }

.btn-sm.green { border-color: var(--green); color: var(--green); }
.btn-sm.green:hover { background: rgba(74,222,128,0.1); }
.btn-sm.orange { border-color: var(--orange); color: var(--orange); }
.btn-sm.orange:hover { background: rgba(251,146,60,0.1); }
.btn-sm.red { border-color: var(--red); color: var(--red); }
.btn-sm.red:hover { background: rgba(248,113,113,0.1); }
.btn-sm.accent { border-color: var(--accent); color: var(--accent); }
.btn-sm.accent:hover { background: rgba(74,158,255,0.1); }

/* ═══════ Header ═══════ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-left h1 { font-size: 20px; font-weight: 700; }
.header-icon {
    font-size: 28px;
    color: var(--accent);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-extension {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    padding: 6px 14px;
    border-radius: 20px;
    text-decoration: none;
    transition: opacity 0.2s, transform 0.2s;
}
.btn-extension:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}
.btn-extension .material-icons-round { font-size: 16px; }

.disk-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    padding: 6px 12px;
    background: var(--bg-input);
    border-radius: 20px;
}
.disk-info .material-icons-round { font-size: 16px; }

.tg-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    padding: 6px 14px;
    background: var(--bg-input);
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}
.tg-status:hover { background: var(--bg-hover); }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-dot.connected { background: var(--green); }
.status-dot.disconnected { background: var(--red); }

/* ═══════ Modal ═══════ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.modal-header h2 { font-size: 18px; }
.auth-step { display: flex; flex-direction: column; gap: 16px; }

/* ═══════ Main Content ═══════ */
.main-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.card h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    color: var(--text);
}
.card h2 .material-icons-round { color: var(--accent); font-size: 22px; }

/* ═══════ Scanner ═══════ */
.scanner-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}
.scanner-row .flex-grow { flex: 1; }

.scan-result { margin-top: 20px; }
.scan-info {
    display: flex;
    gap: 24px;
    padding: 16px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}
.scan-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.scan-stat .material-icons-round { color: var(--accent); font-size: 20px; }

.download-config h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}
.config-row {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}
.config-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.config-field label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}
.config-field input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}
.config-field input:focus { border-color: var(--accent); }
.config-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ═══════ Tasks ═══════ */
.tasks-list { display: flex; flex-direction: column; gap: 12px; }
.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    padding: 24px;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.task-info { flex: 1; }
.task-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}
.task-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.task-progress {
    width: 160px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
}
.progress-text {
    font-size: 12px;
    color: var(--text-muted);
}

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

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.status-badge.downloading { background: rgba(74,158,255,0.15); color: var(--accent); }
.status-badge.paused { background: rgba(251,146,60,0.15); color: var(--orange); }
.status-badge.completed { background: rgba(74,222,128,0.15); color: var(--green); }
.status-badge.error { background: rgba(248,113,113,0.15); color: var(--red); }
.status-badge.cancelled { background: rgba(136,136,160,0.15); color: var(--text-muted); }
.status-badge.pending { background: rgba(136,136,160,0.15); color: var(--text-muted); }

/* ═══════ Archives ═══════ */
.archives-list { display: flex; flex-direction: column; gap: 8px; }

.archive-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.archive-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: rgba(74,158,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}
.archive-icon .material-icons-round { color: var(--accent); font-size: 20px; }

.archive-info { flex: 1; }
.archive-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
}
.archive-meta {
    font-size: 12px;
    color: var(--text-muted);
}

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

/* ═══════ Toast ═══════ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    box-shadow: var(--shadow);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }
.toast.warning { border-color: var(--orange); color: var(--orange); }

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

/* ═══════ Responsive ═══════ */
@media (max-width: 640px) {
    .header { padding: 12px 16px; }
    .header-left h1 { display: none; }
    .main-content { padding: 16px; }
    .scanner-row { flex-direction: column; }
    .config-row { flex-direction: column; }
    .scan-info { flex-direction: column; gap: 8px; }
    .task-item { flex-direction: column; align-items: stretch; }
    .task-progress { width: 100%; align-items: stretch; }
    .task-actions { justify-content: flex-end; }
    .disk-info { display: none; }
}
