/* YouTube Downloader - Styles */
:root {
    --bg: #0f0f0f;
    --bg-card: #1a1a2e;
    --bg-input: #16213e;
    --bg-hover: #1f2b47;
    --text: #e0e0e0;
    --text-secondary: #94a3b8;
    --primary: #ff4444;
    --primary-hover: #ff6666;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --success: #22c55e;
    --error: #ef4444;
    --border: #2d3a56;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

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

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

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* Header */
.header {
    text-align: center;
    padding: 40px 0 32px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #ff4444, #ff8888);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 15px;
}

/* Input Section */
.input-section {
    margin-bottom: 24px;
}

.url-input-wrapper {
    display: flex;
    gap: 10px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    transition: border-color 0.3s;
}

.url-input-wrapper:focus-within {
    border-color: var(--primary);
}

.url-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 15px;
    padding: 12px 16px;
    outline: none;
    min-width: 0;
}

.url-input-wrapper input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { 
    opacity: 0.6; 
    cursor: not-allowed;
    transform: none;
}

.error-msg {
    color: var(--error);
    font-size: 13px;
    margin-top: 8px;
    padding-left: 12px;
}

/* Loading */
.loading-section {
    text-align: center;
    padding: 60px 0;
}

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

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

.loading-section p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Video Section */
.video-card {
    display: flex;
    gap: 20px;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.video-thumb {
    position: relative;
    flex-shrink: 0;
    width: 280px;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

.video-thumb img {
    width: 100%;
    display: block;
}

.duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.video-details { flex: 1; min-width: 0; }

.video-details h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 4px;
}

.meta-sep { opacity: 0.4; }

.video-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.video-desc {
    font-size: 13px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

/* Formats */
.formats-section { margin-bottom: 20px; }

.formats-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.format-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.filter-btn {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.formats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.format-item {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.format-item:hover { border-color: var(--accent); }
.format-item.selected {
    border-color: var(--primary);
    background: rgba(255,68,68,0.1);
}

.format-label {
    font-size: 14px;
    font-weight: 600;
}

.format-info {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

.format-item.audio-only {
    border-left: 3px solid #a855f7;
}

.format-item.best-quality {
    border-left: 3px solid var(--success);
}

/* Download Actions */
.download-actions {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.selected-format {
    font-size: 15px;
    margin-bottom: 14px;
    padding: 8px 12px;
    background: rgba(255,68,68,0.1);
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-download {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--success);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-download:hover { background: #16a34a; }
.btn-download:active { transform: scale(0.97); }
.btn-download:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover { background: var(--accent-hover); }
.btn-secondary:active { transform: scale(0.97); }

.download-status {
    margin-top: 12px;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
}

.download-status.success {
    background: rgba(34,197,94,0.1);
    color: var(--success);
    border: 1px solid rgba(34,197,94,0.3);
}

.download-status.error {
    background: rgba(239,68,68,0.1);
    color: var(--error);
    border: 1px solid rgba(239,68,68,0.3);
}

.parse-info {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: right;
}

/* Error Section */
.error-section { margin-bottom: 32px; }

.error-card {
    background: var(--bg-card);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
}

.error-card h3 {
    margin: 12px 0 8px;
    color: var(--error);
}

.error-card p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    word-break: break-all;
}

.btn-retry {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 8px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-retry:hover { background: rgba(59,130,246,0.1); }

/* History */
.history-section {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.history-section h3 {
    font-size: 16px;
    margin-bottom: 16px;
}

.history-list { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
}

.history-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:hover { background: var(--bg-hover); }

.history-thumb {
    width: 120px;
    height: 68px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: #000;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-info h4 {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-info span {
    font-size: 12px;
    color: var(--text-secondary);
}

.history-time {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.history-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px;
    font-size: 14px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 40px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
    opacity: 0.6;
}

/* Helpers */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
    .container { padding: 12px; }
    .header { padding: 24px 0 20px; }
    .logo h1 { font-size: 22px; }

    .url-input-wrapper {
        flex-direction: column;
        background: transparent;
        border: none;
        padding: 0;
        gap: 8px;
    }

    .url-input-wrapper input {
        background: var(--bg-card);
        border: 2px solid var(--border);
        border-radius: var(--radius);
        padding: 14px;
    }

    .url-input-wrapper:focus-within input {
        border-color: var(--primary);
    }

    .btn-primary { justify-content: center; padding: 14px; }

    .video-card { flex-direction: column; padding: 14px; }
    .video-thumb { width: 100%; }
    .formats-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .action-buttons { flex-direction: column; }
    .action-buttons button { justify-content: center; width: 100%; }
}
