/* ═══════════════════════════════════════════════
   Ростендер Парсер — Стили (тёмная тема)
   ═══════════════════════════════════════════════ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-input: #252836;
    --bg-hover: #2a2d3a;

    --text-primary: #e4e6ec;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.3);

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --border: #2d3140;
    --border-light: #363b4a;

    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;

    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);

    --transition: 0.2s ease;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ═══════ Контейнер ═══════ */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ═══════ Шапка ═══════ */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    font-size: 28px;
}

.app-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.version {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 4px;
}

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

.user-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 10px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.user-icon {
    font-size: 16px;
}

/* ═══════ Кнопки ═══════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    background: transparent;
    color: var(--text-primary);
    white-space: nowrap;
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 0 16px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-input);
    border-color: var(--border-light);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: var(--radius-sm);
    font-size: 16px;
}

.btn-icon:hover:not(:disabled) {
    background: var(--bg-hover);
}

.btn-logout:hover:not(:disabled) {
    color: var(--warning);
}

.btn-exit {
    color: var(--text-muted);
}

.btn-exit:hover:not(:disabled) {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.btn-parse {
    min-width: 140px;
    height: 46px;
    font-size: 15px;
}

.btn-clear {
    color: var(--text-muted);
}

/* ═══════ Спиннер ═══════ */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════ Экраны ═══════ */
.screen {
    flex: 1;
}

.hidden {
    display: none !important;
}

/* ═══════ Экран логина ═══════ */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px 36px;
    text-align: center;
}

.login-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.login-card h2 {
    font-size: 22px;
    margin-bottom: 8px;
}

.login-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-form {
    text-align: left;
}

/* ═══════ Карточка ═══════ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

/* ═══════ Формы ═══════ */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
    outline: none;
}

.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input::placeholder {
    color: var(--text-muted);
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ═══════ Строка ввода URL ═══════ */
.input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.url-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.url-icon {
    position: absolute;
    left: 14px;
    font-size: 16px;
    z-index: 1;
    pointer-events: none;
}

.url-input {
    padding-left: 40px;
    height: 46px;
    font-size: 14px;
    font-family: var(--font-mono);
}

/* ═══════ История ═══════ */
.history-section {
    margin-bottom: 16px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.history-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--text-primary);
}

/* ═══════ Индикатор загрузки ═══════ */
.loading-bar {
    height: 3px;
    background: var(--bg-input);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 20px;
}

.loading-bar-fill {
    height: 100%;
    width: 30%;
    background: var(--accent);
    border-radius: 2px;
    animation: loading 1.2s ease-in-out infinite;
}

@keyframes loading {
    0% { margin-left: -30%; }
    50% { margin-left: 70%; }
    100% { margin-left: 130%; }
}

/* ═══════ Результаты ═══════ */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.results-card {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    font-size: 12px;
    padding: 2px 8px;
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    font-weight: 500;
}

/* ═══════ Таблица информации ═══════ */
.table-wrapper {
    overflow-x: auto;
}

.info-table {
    width: 100%;
    border-collapse: collapse;
}

.info-table tr {
    border-bottom: 1px solid var(--border);
}

.info-table tr:last-child {
    border-bottom: none;
}

.info-table td {
    padding: 10px 14px;
    font-size: 13px;
    vertical-align: top;
}

.info-table td:first-child {
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    width: 40%;
}

.info-table td:last-child {
    color: var(--text-primary);
    word-break: break-word;
    font-family: var(--font-mono);
    font-size: 12px;
}

/* ═══════ Таблица файлов ═══════ */
.files-table {
    width: 100%;
    border-collapse: collapse;
}

.files-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.files-table td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.files-table tr:last-child td {
    border-bottom: none;
}

.files-table .file-name {
    color: var(--text-primary);
    font-weight: 500;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.files-table .file-size {
    color: var(--text-secondary);
    white-space: nowrap;
}

.files-table .file-date {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

.file-actions {
    display: flex;
    gap: 4px;
}

.file-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.file-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--text-primary);
}

.file-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
}

.file-status.downloading {
    color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

.file-status.completed {
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.file-status.error {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ═══════ Действия с файлами ═══════ */
.files-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.no-files {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-size: 14px;
}

/* ═══════ Кнопки экспорта ═══════ */
.export-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding-bottom: 40px;
    flex-wrap: wrap;
}

/* ═══════ Настройки трекера ═══════ */
#trackerSettings .form-group {
    margin-bottom: 14px;
}

#trackerSettings .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

#trackerStatus a {
    color: var(--accent);
    text-decoration: none;
}

#trackerStatus a:hover {
    text-decoration: underline;
}

/* ═══════ Toast уведомления ═══════ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 400px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 3.2s forwards;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.toast-success {
    background: #065f46;
    border: 1px solid #059669;
}

.toast-error {
    background: #7f1d1d;
    border: 1px solid #dc2626;
}

.toast-warning {
    background: #78350f;
    border: 1px solid #d97706;
}

.toast-info {
    background: #1e3a5f;
    border: 1px solid #3b82f6;
}

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

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ═══════ Адаптивность ═══════ */
@media (max-width: 640px) {
    .app-container {
        padding: 0 12px;
    }
    .app-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    .header-right {
        align-self: flex-end;
    }
    .input-row {
        flex-wrap: wrap;
    }
    .btn-parse {
        width: 100%;
    }
    .files-actions,
    .export-actions {
        flex-direction: column;
    }
    .files-table .file-name {
        max-width: 150px;
    }
    .info-table td:first-child {
        width: auto;
    }
}

/* ═══════ Скроллбар ═══════ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
