:root {
    --bg-primary: #0a0c16;
    --bg-secondary: #111428;
    --glass-bg: rgba(15, 18, 36, 0.55);
    --glass-border: rgba(255, 255, 255, 0.07);
    --glass-border-hover: rgba(255, 255, 255, 0.15);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-indigo: #6366f1;
    --accent-magenta: #d946ef;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    
    --gradient-primary: linear-gradient(135deg, var(--accent-indigo), var(--accent-magenta));
    --gradient-secondary: linear-gradient(135deg, #06b6d4, #3b82f6);
    --glow-shadow: 0 0 25px rgba(99, 102, 241, 0.35);
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Glowing Orbs */
.glow-bg {
    position: fixed;
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -1;
    filter: blur(80px);
    pointer-events: none;
    animation: float 20s infinite alternate;
}

.glow-bg-secondary {
    position: fixed;
    bottom: -10%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(217, 70, 239, 0.1) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -1;
    filter: blur(80px);
    pointer-events: none;
    animation: float 25s infinite alternate-reverse;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(5%, 5%) scale(1.1); }
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Container */
.app-container {
    width: 100%;
    max-width: 1100px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Glassmorphism Helper */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.card {
    border-radius: 20px;
    padding: 2.5rem;
    transition: var(--transition-smooth);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 2rem;
    height: 2rem;
    color: var(--accent-magenta);
    filter: drop-shadow(0 0 8px rgba(217, 70, 239, 0.6));
}

.logo-text {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text span {
    font-weight: 300;
}

.header-badge {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-green);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Main Content Layout */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Search Section */
.search-section {
    text-align: center;
    position: relative;
    overflow: hidden;
}

.search-section h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(180deg, #ffffff 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.search-section .subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
    font-weight: 300;
}

.url-form {
    max-width: 850px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(7, 9, 21, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 0.5rem 0.5rem 0.5rem 1.5rem;
    transition: var(--transition-smooth);
    position: relative;
}

.input-wrapper:focus-within {
    border-color: transparent;
    box-shadow: var(--glow-shadow), 0 0 0 1px var(--accent-indigo);
}

.input-wrapper::before {
    content: '';
    position: absolute;
    top: -1px; left: -1px; right: -1px; bottom: -1px;
    border-radius: 16px;
    background: var(--gradient-primary);
    z-index: -1;
    opacity: 0;
    transition: var(--transition-smooth);
}

.input-wrapper:focus-within::before {
    opacity: 1;
}

.input-icon {
    color: var(--text-muted);
    margin-right: 1rem;
    flex-shrink: 0;
}

.input-wrapper input {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-family: var(--font-sans);
    padding: 0.75rem 0;
    width: 100%;
}

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

/* Buttons */
.btn {
    border: none;
    outline: none;
    border-radius: 12px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    padding: 0.85rem 2rem;
    box-shadow: 0 4px 15px rgba(217, 70, 239, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(217, 70, 239, 0.4), var(--glow-shadow);
}

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

.btn-icon {
    width: 1.1rem;
    height: 1.1rem;
}

/* Loading Section */
.loading-section {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
}

.spinner-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.spinner {
    width: 3.5rem;
    height: 3.5rem;
    border: 4px solid var(--glass-border);
    border-top: 4px solid var(--accent-magenta);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px rgba(217, 70, 239, 0.2);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Section */
.error-section {
    border-left: 4px solid var(--accent-red);
    background: rgba(239, 68, 68, 0.05);
}

.error-content {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}

.error-icon {
    color: var(--accent-red);
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
}

.error-text h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.error-text p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Preview Section Grid */
.preview-section {
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.preview-grid {
    display: grid;
    grid-template-columns: 1.1fr 1.3fr;
    gap: 2rem;
}

@media (max-width: 868px) {
    .preview-grid {
        grid-template-columns: 1fr;
    }
}

/* Video Info Card */
.video-info-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.75rem;
}

.thumbnail-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

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

.duration-tag {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    color: white;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.video-details h2 {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.uploader-info, .views-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.uploader-info svg, .views-info svg {
    width: 1rem;
    height: 1rem;
    color: var(--text-muted);
}

.video-description {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 1rem;
    line-height: 1.5;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.75rem;
    border-radius: 8px;
}

/* Download Panel / Tabs */
.download-panel-card {
    display: flex;
    flex-direction: column;
    padding: 1.75rem;
    min-height: 400px;
}

.tab-headers {
    display: flex;
    background: rgba(7, 9, 21, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.35rem;
    margin-bottom: 1.75rem;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.75rem 0;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
}

.tab-btn svg {
    width: 1.1rem;
    height: 1.1rem;
}

.tab-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(217, 70, 239, 0.25);
}

.tab-content {
    display: none;
    flex-grow: 1;
    flex-direction: column;
}

.tab-content.active {
    display: flex;
}

.tab-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.tab-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
}

/* Format Option Items */
.format-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.format-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(7, 9, 21, 0.3);
    border: 1px solid var(--glass-border);
    padding: 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.format-option:hover {
    border-color: var(--glass-border-hover);
    background: rgba(255, 255, 255, 0.02);
}

.format-option.selected {
    border-color: var(--accent-indigo);
    background: rgba(99, 102, 241, 0.08);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.1);
}

.option-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.radio-circle {
    width: 18px;
    height: 18px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.format-option.selected .radio-circle {
    border-color: var(--accent-indigo);
}

.format-option.selected .radio-circle::after {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent-indigo);
    border-radius: 50%;
}

.format-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.format-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

/* Big Action Download Button */
.btn-download {
    width: 100%;
    padding: 1rem 0;
    font-size: 1.1rem;
    margin-top: auto;
}

.btn-download:not(.btn-disabled) {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(217, 70, 239, 0.3);
}

.btn-download:not(.btn-disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(217, 70, 239, 0.5), var(--glow-shadow);
}

.btn-disabled {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Modal / Progress Overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(5, 6, 12, 0.8);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: var(--transition-smooth);
}

.modal-content {
    width: 90%;
    max-width: 500px;
    border-radius: 24px;
    padding: 2.5rem;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.modal-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, white, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.progress-status-text {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 2rem;
}

.progress-bar-container {
    height: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 2rem;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 20px;
    transition: width 0.3s ease-out;
    box-shadow: 0 0 10px rgba(217, 70, 239, 0.5);
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    padding: 0.75rem;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Conversion Wave Loader */
.loader-wave {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 6px;
    height: 30px;
}

.loader-wave span {
    width: 6px;
    height: 15px;
    background-color: var(--accent-magenta);
    border-radius: 4px;
    animation: wave 1.2s ease-in-out infinite;
}

.loader-wave span:nth-child(2) { background-color: #c084fc; animation-delay: 0.15s; }
.loader-wave span:nth-child(3) { background-color: var(--accent-indigo); animation-delay: 0.3s; }
.loader-wave span:nth-child(4) { background-color: #818cf8; animation-delay: 0.45s; }
.loader-wave span:nth-child(5) { background-color: var(--accent-cyan); animation-delay: 0.6s; }

@keyframes wave {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(2.2); }
}

/* Footer styling */
.app-footer {
    text-align: center;
    margin-top: 4rem;
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--glass-border);
}

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