/* RapidGo - Clean Responsive UI */

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    line-height: 1.5;
}

/* Navbar */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    text-decoration: none;
}

.logo { font-size: 1.2rem; }
.brand-name { display: none; }

@media (min-width: 480px) {
    .brand-name { display: inline; }
}

.nav-menu {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.nav-link:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.nav-icon { font-size: 1rem; }
.nav-text { display: none; }

@media (min-width: 400px) {
    .nav-text { display: inline; }
    .nav-link { padding: 0.5rem 1rem; }
}

.nav-session {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: monospace;
    background: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Container */
.container {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 1rem;
}

@media (min-width: 768px) {
    .container { padding: 1.5rem; }
}

/* Page Header */
.page-header {
    margin-bottom: 1rem;
}

.page-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.page-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

/* Forms */
.form-group {
    margin-bottom: 0.75rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-hint {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-small {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
}

.btn-full { width: 100%; }

/* Sections */
.section {
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* Task Cards */
.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.task-name {
    font-weight: 500;
    font-size: 0.85rem;
    word-break: break-all;
    flex: 1;
}

.task-name-link {
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
}

.task-name-link:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}

.task-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.task-status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.status-downloading { background: #dbeafe; color: #1d4ed8; }
.status-queued { background: #fef3c7; color: #b45309; }
.status-completed { background: #dcfce7; color: #166534; }
.status-failed { background: #fee2e2; color: #b91c1c; }

.task-status-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.download-mode {
    font-size: 0.65rem;
    font-weight: 500;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    white-space: nowrap;
}

.download-mode.chunked {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #86efac;
}

.download-mode.single {
    background: #f5f5f5;
    color: #737373;
    border: 1px solid #d4d4d4;
}

.progress-container {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s;
}

.task-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.task-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

/* Files Table */
.files-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.files-table th,
.files-table td {
    padding: 0.6rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.files-table th {
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.files-table tr:hover {
    background: var(--bg);
}

.file-name-cell {
    word-break: break-all;
    max-width: 200px;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.file-name-cell .file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.2rem;
    font-size: 0.9rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.btn-icon:hover {
    opacity: 1;
}

/* Folder styles */
.folder-row {
    background: rgba(59, 130, 246, 0.05);
}

.folder-toggle {
    cursor: pointer;
    font-size: 0.7rem;
    margin-right: 0.3rem;
    color: var(--text-muted);
    user-select: none;
}

.folder-name {
    cursor: pointer;
    color: var(--primary);
}

.folder-name:hover {
    text-decoration: underline;
}

.readonly-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

.folder-contents {
    background: var(--surface);
}

.folder-files-container {
    padding: 0.5rem 1rem 0.5rem 2rem;
    background: rgba(0, 0, 0, 0.02);
    border-left: 3px solid var(--primary);
    margin-left: 1rem;
}

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

.folder-file-row {
    border-bottom: 1px solid var(--border);
}

.folder-file-row:last-child {
    border-bottom: none;
}

.folder-file-row td {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
}

.folder-file-row .file-icon-cell {
    width: 30px;
}

.folder-file-row .file-name-cell {
    word-break: break-all;
}

.folder-file-row .file-size-cell {
    width: 80px;
    text-align: right;
    color: var(--text-muted);
}

.folder-file-row .file-actions-cell {
    width: 100px;
    text-align: right;
}

.empty-folder {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
}

.folder-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.folder-pagination .page-info {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.folder-pagination .page-buttons {
    display: flex;
    gap: 0.5rem;
}

.file-actions-cell {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Footer */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.footer-stats {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-label {
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    min-width: 30px;
}

.stat-bar {
    width: 80px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease, background-color 0.3s ease;
}

.cpu-fill { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.ram-fill { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.disk-fill { background: linear-gradient(90deg, #10b981, #34d399); }

/* Color states based on usage */
.stat-fill.warning { background: linear-gradient(90deg, #f59e0b, #fbbf24) !important; }
.stat-fill.danger { background: linear-gradient(90deg, #ef4444, #f87171) !important; }

.stat-value {
    font-weight: 600;
    font-size: 0.7rem;
    min-width: 35px;
    text-align: right;
}

.footer-brand {
    text-align: center;
    margin-top: 0.25rem;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
}

/* Config Form */
.form-section {
    padding: 1rem;
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 1rem;
}

.form-section h3 {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Compress Toolbar */
.compress-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-alt);
    border: 1px solid var(--primary);
    border-radius: 8px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.compress-toolbar .form-input.compact {
    width: 120px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.compress-toolbar .form-select.compact {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}

#selectedCount {
    font-weight: 600;
    color: var(--primary);
}

/* Checkbox Column */
.checkbox-col {
    width: 30px;
    text-align: center;
}

.file-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.file-row.selected {
    background: rgba(99, 102, 241, 0.1);
}

/* Processing overlay */
.processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.processing-modal {
    background: var(--bg);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    max-width: 300px;
}

.processing-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.processing-text {
    font-weight: 600;
    color: var(--text);
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .container { padding: 0.75rem; }
    .card { padding: 0.75rem; }
    .task-card { padding: 0.6rem; }
    
    .files-table th:nth-child(4),
    .files-table td:nth-child(4),
    .files-table th:nth-child(5),
    .files-table td:nth-child(5) {
        display: none;
    }
    
    .file-actions-cell {
        flex-direction: column;
    }
    
    .btn-small {
        padding: 0.35rem 0.5rem;
        font-size: 0.7rem;
    }
    
    .compress-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .compress-toolbar .form-input.compact {
        width: 100%;
    }
}

/* Utility */
.hidden { display: none !important; }
.text-center { text-align: center; }
