/* ==========================================================================
   YT STREAM - DESIGN SYSTEM & STYLESHEET
   ========================================================================== */

:root {
    --bg-dark: #070a12;
    --card-bg: rgba(18, 24, 38, 0.65);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover-border: rgba(255, 255, 255, 0.18);
    
    --primary: #ff3b5c;
    --primary-hover: #e02e4d;
    --primary-glow: rgba(255, 59, 92, 0.35);

    --accent-violet: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    
    --text-main: #f8fafc;
    --text-sub: #94a3b8;
    --text-muted: #64748b;
    
    --font-heading: 'Outfit', -apple-system, sans-serif;
    --font-body: 'Inter', -apple-system, sans-serif;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 9999px;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
    padding: 2rem 1rem;
}

/* Background Ambient Glow Effects */
.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.5;
}

.glow-1 {
    width: 450px;
    height: 450px;
    background: var(--primary-glow);
    top: -100px;
    left: -100px;
}

.glow-2 {
    width: 500px;
    height: 500px;
    background: rgba(139, 92, 246, 0.25);
    bottom: -150px;
    right: -100px;
}

.glow-3 {
    width: 350px;
    height: 350px;
    background: rgba(6, 182, 212, 0.2);
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Main Container */
.app-container {
    width: 100%;
    max-width: 840px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.5rem 0.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--accent-violet));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    box-shadow: 0 0 20px var(--primary-glow);
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-text p {
    font-size: 0.825rem;
    color: var(--text-sub);
}

.badge {
    background: rgba(255, 59, 92, 0.15);
    color: var(--primary);
    border: 1px solid rgba(255, 59, 92, 0.3);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    color: var(--text-sub);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-green);
    box-shadow: 0 0 10px var(--accent-green);
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    transition: border-color var(--transition-normal);
}

/* Search / URL Input Section */
.search-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.search-label {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}

.search-box {
    display: flex;
    align-items: center;
    background: rgba(10, 14, 26, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 6px 6px 6px 14px;
    gap: 0.5rem;
    transition: all var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

.input-prefix-icon {
    color: var(--primary);
    font-size: 1.25rem;
    display: flex;
    align-items: center;
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.95rem;
}

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

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-sub);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
}

.input-hint {
    font-size: 0.775rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 0 20px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-gradient {
    background: linear-gradient(135deg, var(--primary), var(--accent-violet));
    color: white;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255, 59, 92, 0.5);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: white;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--card-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-lg {
    padding: 0.9rem 1.75rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

.btn-text-only {
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-size: 0.8rem;
    cursor: pointer;
}

.btn-text-only:hover {
    color: var(--primary);
}

/* Spinner Loader */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Skeleton Loading Animation */
.skeleton-container {
    display: flex;
    gap: 1.5rem;
    margin-top: 1.5rem;
    animation: pulse 1.5s infinite ease-in-out;
}

.skeleton-thumb {
    width: 220px;
    height: 124px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
}

.skeleton-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.skeleton-line {
    height: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
}

.skeleton-line.long { width: 90%; }
.skeleton-line.medium { width: 60%; }
.skeleton-line.short { width: 35%; }

/* Video Preview Card */
.content-section {
    margin-top: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.4s ease-out;
}

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

.video-preview-card {
    display: flex;
    gap: 1.5rem;
}

.thumb-wrapper {
    position: relative;
    width: 220px;
    height: 124px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 4px;
    backdrop-filter: blur(4px);
}

.video-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.video-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.meta-row {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-sub);
}

.video-description {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.divider {
    height: 1px;
    background: var(--card-border);
    width: 100%;
}

/* Options & Format Selection */
.options-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.options-wrapper h3 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
}

.format-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    background: rgba(10, 14, 26, 0.6);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-sub);
    padding: 0.65rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tab-btn:hover:not(.active) {
    color: var(--text-main);
}

.quality-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.section-label {
    font-size: 0.8rem;
    color: var(--text-sub);
    font-weight: 500;
}

.chips-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-pill);
    font-size: 0.825rem;
    color: var(--text-sub);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.chip:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
}

.chip.active {
    background: rgba(255, 59, 92, 0.15);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 0 10px var(--primary-glow);
}

.action-row {
    margin-top: 0.5rem;
    display: flex;
    justify-content: flex-end;
}

/* Progress Card */
.progress-section {
    margin-top: 1.5rem;
    animation: fadeIn 0.4s ease-out;
}

.progress-card {
    background: rgba(10, 14, 26, 0.8);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.pulse-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--primary);
    box-shadow: 0 0 12px var(--primary);
    animation: pulseGlow 1.5s infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

.percentage-badge {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--primary);
}

.progress-track {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-pill);
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent-violet), var(--accent-cyan));
    border-radius: var(--radius-pill);
    transition: width 0.3s ease;
    box-shadow: 0 0 15px var(--primary-glow);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    background: rgba(255, 255, 255, 0.02);
    padding: 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.metric-box {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.metric-label {
    font-size: 0.725rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}

.finish-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.finish-actions .btn {
    flex: 1;
}

/* History Section */
.history-section {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-header h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-sub);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    gap: 1rem;
}

.history-item-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
}

.history-item-info img {
    width: 48px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
}

.history-item-title {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: rgba(20, 26, 40, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.error {
    border-color: rgba(255, 59, 92, 0.5);
    box-shadow: 0 10px 30px rgba(255, 59, 92, 0.2);
}

.toast.error i {
    color: var(--primary);
}

.toast.success i {
    color: var(--accent-green);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

/* Responsive layout adjustments */
@media (max-width: 640px) {
    body { padding: 1rem 0.5rem; }
    .video-preview-card { flex-direction: column; }
    .thumb-wrapper { width: 100%; height: 180px; }
    .format-tabs { grid-template-columns: 1fr; }
    .metrics-grid { grid-template-columns: 1fr; }
    .finish-actions { flex-direction: column; }
}
