:root {
    --bg-color: #0b0f19;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(17, 24, 39, 0.4);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --error: #ef4444;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

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

/* Background animated orbs */
.background-orbs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite ease-in-out alternate;
}

.orb-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: rgba(59, 130, 246, 0.4);
    animation-delay: 0s;
}

.orb-2 {
    bottom: -20%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: rgba(139, 92, 246, 0.3);
    animation-delay: -5s;
}

.orb-3 {
    top: 40%;
    left: 60%;
    width: 300px;
    height: 300px;
    background: rgba(16, 185, 129, 0.2);
    animation-delay: -10s;
}

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

.container {
    width: 100%;
    max-width: 800px;
    padding: 2rem;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Glass Panel Utility */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 1rem;
    animation: slideDown 0.6s ease-out forwards;
}

.app-header .logo {
    font-size: 3rem;
    margin-bottom: 1rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.app-header h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

.app-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Form */
.downloader-card {
    animation: fadeIn 0.8s ease-out forwards;
}

.input-group {
    display: flex;
    gap: 1rem;
}

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

.input-icon {
    position: absolute;
    left: 1.2rem;
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

input[type="url"] {
    width: 100%;
    padding: 1.2rem 1.2rem 1.2rem 3rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

input[type="url"]::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

input[type="url"]:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

input[type="url"]:focus + .input-icon, 
.input-wrapper:focus-within .input-icon {
    color: var(--primary);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 0 2rem;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px var(--primary);
}

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

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

.error-msg {
    margin-top: 1rem;
    color: var(--error);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Result Section */
.result-section {
    animation: slideUp 0.6s ease-out forwards;
}

.result-card {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 2rem;
}

.thumbnail-container {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 9/16;
    background: #000;
    border: 1px solid var(--glass-border);
}

.thumbnail-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.thumbnail-container:hover img {
    transform: scale(1.05);
}

.duration-badge {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.download-options {
    display: flex;
    flex-direction: column;
}

.download-options h3 {
    margin-bottom: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.quality-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.quality-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    color: var(--text-main);
    text-decoration: none;
    transition: all 0.2s ease;
}

.quality-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    transform: translateX(4px);
}

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

.quality-label {
    font-weight: 600;
    font-size: 1.05rem;
}

.quality-size {
    color: var(--text-muted);
    font-size: 0.85rem;
    background: rgba(255,255,255,0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
}

.download-icon {
    color: var(--primary);
    font-size: 1.2rem;
}

.hidden {
    display: none !important;
}

/* Animations */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Progress Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    display: none !important;
    opacity: 0;
}

.modal-content {
    width: 90%;
    max-width: 450px;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: slideUp 0.4s ease-out;
}

.modal-header {
    text-align: center;
}

.modal-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
    animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.modal-header h2 {
    font-weight: 700;
    font-size: 1.5rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 0.5rem;
}

.progress-percentage {
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
}

.progress-size {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--primary-gradient);
    border-radius: 10px;
    transition: width 0.2s ease-out;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer 1.5s infinite linear;
}

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

.modal-footer-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 640px) {
    .input-group {
        flex-direction: column;
    }
    
    .btn-primary {
        width: 100%;
        padding: 1.2rem;
        justify-content: center;
    }
    
    .result-card {
        grid-template-columns: 1fr;
    }
    
    .thumbnail-container {
        max-width: 250px;
        margin: 0 auto;
    }
    
    .app-header h1 {
        font-size: 2.2rem;
    }
}

/* Dramatic Animations */
.dramatic-bg {
    background: rgba(40, 0, 0, 0.85);
    backdrop-filter: blur(15px);
}

.dramatic-icon {
    animation: intense-pulse 1s infinite alternate;
}

@keyframes intense-pulse {
    0% { transform: scale(1); filter: drop-shadow(0 0 10px red); }
    100% { transform: scale(1.2); filter: drop-shadow(0 0 30px red); }
}

.dramatic-shake {
    animation: intense-shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
    animation-iteration-count: infinite;
}

@keyframes intense-shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(4px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-8px, 0, 0); }
    40%, 60% { transform: translate3d(8px, 0, 0); }
}
