* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #10b981;
    --success-dark: #059669;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --secondary: #6b7280;
    --bg-primary: #f9fafb;
    --bg-secondary: #ffffff;
    --sidebar-bg: #1f2937;
    --sidebar-hover: #374151;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    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;
}

/* Dashboard Layout */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header svg {
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

.nav-menu {
    flex: 1;
    padding: 20px 0;
}

.nav-section-title {
    padding: 20px 20px 8px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-item.nav-item-submenu {
    padding-left: 30px;
    font-size: 0.9rem;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-logout {
    width: 100%;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fee2e2;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 20px 30px;
    overflow-y: auto;
}

.top-header {
    margin-bottom: 30px;
}

.top-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Content Sections */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.card-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.card-body {
    padding: 24px;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-primary);
    margin-bottom: 20px;
}

.upload-area:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.upload-area.drag-over {
    border-color: var(--primary);
    background: #dbeafe;
}

.upload-prompt svg {
    color: var(--primary);
    margin-bottom: 16px;
}

.upload-prompt p {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-weight: 500;
}

.file-types {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* File Info */
.file-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 8px;
    margin-bottom: 20px;
}

.file-icon {
    font-size: 2rem;
}

.file-details {
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
}

.file-size {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.btn-remove {
    background: var(--danger);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 4px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-dark);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-dark);
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: var(--warning-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* Task Info */
.task-info {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 8px;
}

.info-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.info-value {
    color: var(--text-primary);
}

.mono {
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

/* Badge */
.badge {
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.badge.processing {
    background: #dbeafe;
    color: #1e40af;
}

.badge.completed {
    background: #d1fae5;
    color: #065f46;
}

.badge.failed {
    background: #fee2e2;
    color: #991b1b;
}

/* Progress */
.progress-section {
    margin: 24px 0;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
}

.progress-bar {
    height: 24px;
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    border-radius: 12px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 24px 0;
}

.stat-card {
    padding: 20px;
    background: var(--bg-primary);
    border-radius: 12px;
    text-align: center;
    border: 2px solid transparent;
}

.stat-card.stat-completed {
    border-color: var(--success);
}

.stat-card.stat-failed {
    border-color: var(--danger);
}

.stat-card.stat-skipped {
    border-color: var(--secondary);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 24px;
}

/* Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.metric-display {
    display: flex;
    align-items: baseline;
    justify-content: center;
    margin-bottom: 16px;
}

.metric-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
}

.metric-unit {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-left: 4px;
}

.metric-bar {
    height: 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 12px;
}

.metric-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    border-radius: 6px;
    transition: width 0.5s ease;
}

.metric-detail {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.download-info {
    display: grid;
    gap: 12px;
    margin-bottom: 20px;
}

.download-stat {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 8px;
}

.download-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.download-value {
    font-weight: 700;
    color: var(--text-primary);
}

/* Logs */
.logs-container {
    max-height: 600px;
    overflow-y: auto;
}

.logs-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.logs-empty svg {
    color: var(--text-light);
    margin-bottom: 16px;
}

.log-item {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.log-item:last-child {
    border-bottom: none;
}

.log-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.log-status.pending {
    background: #fbbf24;
}

.log-status.downloading {
    background: #3b82f6;
    animation: pulse 1.5s infinite;
}

.log-status.converting {
    background: #8b5cf6;
    animation: pulse 1.5s infinite;
}

.log-status.completed {
    background: #10b981;
}

.log-status.failed {
    background: #ef4444;
}

.log-status.skipped {
    background: #6b7280;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.log-content {
    flex: 1;
}

.log-row {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.log-url {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 600px;
}

.log-info {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Cookies Section */
.cookies-info-box {
    background: #eff6ff;
    border: 1px solid #3b82f6;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.info-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.cookies-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 8px;
    margin-bottom: 24px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--secondary);
    flex-shrink: 0;
}

.status-indicator.active {
    background: var(--success);
}

.status-title {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 2px;
}

.status-text {
    color: var(--text-primary);
    font-size: 0.95rem;
}

.error-box {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 16px;
    border-left: 4px solid var(--danger);
}

.success-box {
    background: #d1fae5;
    color: #065f46;
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 16px;
    border-left: 4px solid var(--success);
}

/* Importer Section */
.importer-container {
    width: 100%;
}

.importer-page {
    display: none;
}

.importer-page.active {
    display: block;
}

.importer-info-box {
    background: #eff6ff;
    border: 1px solid #3b82f6;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
}

.table thead th {
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    background: var(--bg-primary);
    font-weight: 600;
}

.table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.table-striped tbody tr:nth-of-type(odd) {
    background: var(--bg-primary);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }

    .main-content {
        margin-left: 200px;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }
}

/* Current Download Status */
.current-download-status {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.3);
    animation: fadeIn 0.3s ease-in;
}

.current-download-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 14px;
    opacity: 0.9;
}

.current-download-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.current-download-info span {
    font-size: 14px;
}

.download-row {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0.9;
}

.download-row #currentDownloadRow {
    font-weight: 700;
    font-size: 18px;
}

.download-progress {
    flex: 1;
    text-align: center;
}

.download-progress #currentDownloadPercent {
    font-weight: 700;
    font-size: 24px;
}

.download-speed {
    text-align: right;
    font-weight: 600;
}

.download-speed #currentDownloadSpeed {
    font-size: 18px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
    }

    .main-content {
        margin-left: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
    
    .current-download-info {
        flex-direction: column;
        gap: 8px;
    }
    
    .download-progress, .download-speed {
        text-align: center;
    }
}
