/**
 * Video Downloader - Modern Beautiful UI Styles
 * Supports YouTube & Instagram Downloads
 *
 * Design by Muhammad Zaeem Nasir
 * https://github.com/mzaeemnasir
 * https://mzaeemnasir.com
 */

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

/* CSS Variables */
:root {
    /* Colors - Modern gradient palette */
    --color-bg: #0f0f1a;
    --color-bg-secondary: #1a1a2e;
    --color-surface: #16162a;
    --color-surface-hover: #1f1f3a;
    --color-border: #2d2d4a;
    --color-border-focus: #4f46e5;

    --color-text-primary: #ffffff;
    --color-text-secondary: #a0a0b8;
    --color-text-muted: #6b6b80;

    /* Gradient colors */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-youtube: linear-gradient(135deg, #ff0000 0%, #cc0000 100%);
    --gradient-instagram: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    --gradient-success: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --gradient-glow: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);

    --color-primary: #667eea;
    --color-primary-hover: #764ba2;

    --color-success: #38ef7d;
    --color-error: #f5576c;
    --color-warning: #f09433;
    --color-info: #667eea;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-base: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 24px;
    --font-size-2xl: 32px;
    --font-size-3xl: 42px;

    --line-height-tight: 1.25;
    --line-height-normal: 1.5;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(102, 126, 234, 0.3);
    --shadow-glow-strong: 0 0 60px rgba(102, 126, 234, 0.5);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

/* Base Styles */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--color-text-primary);
    background: var(--color-bg);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(102, 126, 234, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(118, 75, 162, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(240, 147, 251, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* Layout */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* Header */
.header {
    background: rgba(22, 22, 42, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-md) 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    color: white;
}

.logo {
    font-size: var(--font-size-xl);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-badges {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.badge-youtube {
    background: rgba(255, 0, 0, 0.15);
    border: 1px solid rgba(255, 0, 0, 0.3);
    color: #ff4444;
}

.badge-instagram {
    background: linear-gradient(45deg, rgba(240, 148, 51, 0.15), rgba(188, 24, 136, 0.15));
    border: 1px solid rgba(220, 39, 67, 0.3);
    color: #f5576c;
}

.badge-free {
    background: rgba(56, 239, 125, 0.15);
    border: 1px solid rgba(56, 239, 125, 0.3);
    color: var(--color-success);
}

/* Hero Section */
.hero {
    padding: var(--space-3xl) 0 var(--space-xl);
    text-align: center;
}

.hero-content {
    max-width: 600px;
    margin: 0 auto;
}

.hero-title {
    font-size: var(--font-size-3xl);
    font-weight: 800;
    line-height: var(--line-height-tight);
    margin-bottom: var(--space-md);
}

.gradient-text {
    background: var(--gradient-glow);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: var(--font-size-lg);
    color: var(--color-text-secondary);
    max-width: 480px;
    margin: 0 auto;
}

/* Main */
.main {
    flex: 1;
    padding: var(--space-xl) 0;
}

/* Section Headers */
.section-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.section-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    color: white;
    flex-shrink: 0;
}

.section-header h2 {
    font-size: var(--font-size-xl);
    font-weight: 700;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin-top: var(--space-xs);
}

/* Download Section */
.download-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
}

.download-section:hover {
    box-shadow: var(--shadow-glow);
    border-color: rgba(102, 126, 234, 0.3);
}

/* Platform Tabs */
.platform-tabs {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    padding: var(--space-xs);
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}

.platform-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    font-family: inherit;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.platform-tab:hover {
    color: var(--color-text-primary);
    background: var(--color-surface-hover);
}

.platform-tab.active {
    background: var(--gradient-primary);
    color: white;
}

.platform-tab[data-platform="youtube"].active {
    background: var(--gradient-youtube);
}

.platform-tab[data-platform="instagram"].active {
    background: var(--gradient-instagram);
}

/* Form */
.download-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.input-group {
    display: flex;
    gap: var(--space-sm);
}

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

.input-icon {
    position: absolute;
    left: var(--space-md);
    color: var(--color-text-muted);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.input-wrapper input {
    flex: 1;
    height: 56px;
    padding: 0 var(--space-md) 0 calc(var(--space-md) * 2 + 20px);
    font-size: var(--font-size-base);
    font-family: inherit;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    transition: all var(--transition-fast);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

.input-wrapper input:focus + .input-icon,
.input-wrapper:has(input:focus) .input-icon {
    color: var(--color-primary);
}

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

.form-row {
    display: flex;
    gap: var(--space-md);
}

.format-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.format-group label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
}

.format-group select {
    height: 52px;
    padding: 0 var(--space-xl) 0 var(--space-md);
    font-size: var(--font-size-sm);
    font-family: inherit;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%236b6b80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    transition: all var(--transition-fast);
}

.format-group select:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    height: 52px;
    padding: 0 var(--space-lg);
    font-size: var(--font-size-sm);
    font-weight: 600;
    font-family: inherit;
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

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

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-glow {
    position: relative;
    overflow: hidden;
}

.btn-glow::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 70%
    );
    transform: rotate(45deg);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

.btn-secondary {
    background-color: var(--color-surface-hover);
    border-color: var(--color-border);
    color: var(--color-text-secondary);
    padding: 0 var(--space-md);
}

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

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    background-color: var(--color-surface-hover);
    border-color: var(--color-border);
    color: var(--color-text-secondary);
}

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

.btn-download {
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--gradient-success);
    color: white;
    border: none;
    border-radius: var(--radius-md);
}

.btn-download:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(56, 239, 125, 0.4);
}

.btn-cancel {
    width: 44px;
    height: 44px;
    padding: 0;
    background-color: transparent;
    border-color: var(--color-border);
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
}

.btn-cancel:hover:not(:disabled) {
    background-color: var(--color-error);
    border-color: var(--color-error);
    color: white;
}

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    animation: spin 1s linear infinite;
}

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

.btn-loading {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Video Preview */
.video-preview {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    margin-top: var(--space-lg);
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.video-preview img {
    width: 140px;
    height: 79px;
    object-fit: cover;
    border-radius: var(--radius-md);
    background-color: var(--color-border);
}

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

.preview-info h3 {
    font-size: var(--font-size-sm);
    font-weight: 600;
    line-height: var(--line-height-tight);
    margin-bottom: var(--space-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.preview-info p {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

/* Error Message */
.error-message {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md);
    margin-top: var(--space-lg);
    background: rgba(245, 87, 108, 0.1);
    border: 1px solid rgba(245, 87, 108, 0.3);
    border-radius: var(--radius-lg);
    color: var(--color-error);
    font-size: var(--font-size-sm);
}

.error-message svg {
    flex-shrink: 0;
    margin-top: 2px;
}

/* Jobs Section */
.jobs-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
}

.jobs-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-3xl) var(--space-md);
    color: var(--color-text-muted);
    text-align: center;
}

.empty-state svg {
    margin-bottom: var(--space-lg);
    opacity: 0.3;
}

.empty-state p {
    font-weight: 600;
    font-size: var(--font-size-lg);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-sm);
}

.empty-state span {
    font-size: var(--font-size-sm);
}

/* Job Card */
.job-card {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.job-card:hover {
    border-color: var(--color-border-focus);
    box-shadow: var(--shadow-sm);
}

.job-thumbnail {
    flex-shrink: 0;
    width: 120px;
    height: 68px;
    background-color: var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.job-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.job-content {
    flex: 1;
    min-width: 0;
}

.job-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    line-height: var(--line-height-tight);
    margin-bottom: var(--space-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.job-meta {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.job-status {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
}

/* Status colors */
.job-card[data-status="queued"] .status-dot {
    background-color: var(--color-text-muted);
}

.job-card[data-status="processing"] .status-dot {
    background: var(--gradient-primary);
    animation: pulse 1.5s ease-in-out infinite;
}

.job-card[data-status="completed"] .status-dot {
    background: var(--gradient-success);
}

.job-card[data-status="failed"] .status-dot {
    background-color: var(--color-error);
}

.job-card[data-status="cancelled"] .status-dot {
    background-color: var(--color-warning);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* Progress Bar */
.job-progress {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.progress-bar {
    flex: 1;
    height: 6px;
    background-color: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

.progress-text {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-text-secondary);
    min-width: 40px;
    text-align: right;
}

/* Job Actions */
.job-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Footer */
.footer {
    padding: var(--space-xl) 0;
    text-align: center;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.footer-note {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.developer-credit {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    flex-wrap: wrap;
    justify-content: center;
}

.heart-icon {
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.developer-link {
    font-weight: 600;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.developer-link:hover {
    filter: brightness(1.2);
}

.github-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--color-bg);
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

.github-link:hover {
    background: var(--color-text-primary);
    color: var(--color-bg);
    transform: scale(1.1);
}

/* Supported Platforms Info */
.platforms-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
    padding: var(--space-md);
    margin-top: var(--space-lg);
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.platform-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.platform-item.youtube { color: #ff4444; }
.platform-item.instagram { color: #f5576c; }

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 var(--space-md);
    }

    .hero-title {
        font-size: var(--font-size-2xl);
    }

    .header-badges {
        display: none;
    }

    .platform-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .platform-tab {
        flex-shrink: 0;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 var(--space-sm);
    }

    .download-section,
    .jobs-section {
        padding: var(--space-lg);
        border-radius: var(--radius-lg);
    }

    .hero {
        padding: var(--space-xl) 0 var(--space-lg);
    }

    .hero-title {
        font-size: var(--font-size-xl);
    }

    .hero-subtitle {
        font-size: var(--font-size-base);
    }

    .input-group {
        flex-direction: column;
    }

    .input-wrapper input {
        width: 100%;
    }

    .btn-secondary span {
        display: none;
    }

    .btn-secondary {
        width: 56px;
        padding: 0;
    }

    .job-card {
        flex-direction: column;
    }

    .job-thumbnail {
        width: 100%;
        height: 140px;
    }

    .job-actions {
        justify-content: flex-end;
    }

    .section-header {
        flex-direction: column;
        text-align: center;
    }

    .developer-credit {
        flex-direction: column;
        gap: var(--space-xs);
    }
}

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

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Selection */
::selection {
    background: rgba(102, 126, 234, 0.3);
    color: var(--color-text-primary);
}
