@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --bg-main: #0a0b10;
    --bg-card: rgba(18, 20, 32, 0.65);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.15);
    --accent-primary: #8b5cf6;     /* Purple */
    --accent-secondary: #06b6d4;   /* Cyan */
    --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 50%, #06b6d4 100%);
    --accent-gradient-hover: linear-gradient(135deg, #a78bfa 0%, #60a5fa 50%, #22d3ee 100%);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --font-sans: 'Inter', sans-serif;
    --font-display: 'Outfit', sans-serif;
    --glow-shadow: 0 0 20px rgba(139, 92, 246, 0.15);
    --glow-shadow-hover: 0 0 30px rgba(139, 92, 246, 0.3);
}

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

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

/* Background animated glow orbs */
.bg-glow-orb-1, .bg-glow-orb-2 {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    z-index: -1;
    opacity: 0.12;
    pointer-events: none;
}

.bg-glow-orb-1 {
    background: var(--accent-primary);
    top: -200px;
    right: -100px;
    animation: orb-float 20s infinite alternate ease-in-out;
}

.bg-glow-orb-2 {
    background: var(--accent-secondary);
    bottom: -200px;
    left: -100px;
    animation: orb-float 25s infinite alternate-reverse ease-in-out;
}

@keyframes orb-float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 80px) scale(1.15); }
}

/* Main Layout */
.app-container {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Header styling */
header {
    text-align: center;
    margin-bottom: 2.5rem;
    animation: fadeInDown 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-icon {
    font-size: 2.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

h1 {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h1 span {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 400;
    margin-top: 0.5rem;
}

/* Main Card */
.converter-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5), var(--glow-shadow);
    transition: box-shadow 0.5s ease, border-color 0.5s ease;
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.converter-card:hover {
    border-color: rgba(139, 92, 246, 0.2);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5), var(--glow-shadow-hover);
}

/* Glowing card outline effect */
.converter-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent-gradient);
}

/* Form Styles */
.input-group {
    display: flex;
    gap: 0.75rem;
    position: relative;
}

.url-input-wrapper {
    position: relative;
    flex-grow: 1;
}

.url-input-wrapper svg {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: color 0.3s ease;
    width: 20px;
    height: 20px;
}

.url-input {
    width: 100%;
    background: rgba(15, 17, 28, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.1rem 1.1rem 1.1rem 3.2rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1.05rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.url-input:focus {
    border-color: var(--accent-primary);
    background: rgba(15, 17, 28, 0.8);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.25);
}

.url-input:focus + svg {
    color: var(--accent-primary);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 0 2rem;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    background: var(--accent-gradient-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

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

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

/* Spinner Loader */
.spinner {
    animation: rotate 1.5s linear infinite;
    width: 20px;
    height: 20px;
}

.spinner circle {
    stroke: currentColor;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

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

@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* Video Preview Container */
.video-preview-container {
    margin-top: 2.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 2.5rem;
    display: none; /* Controlled by JS */
    animation: fadeInUp 0.5s ease-out;
}

.video-info-card {
    display: flex;
    gap: 1.5rem;
    background: rgba(15, 17, 28, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.video-thumbnail-wrapper {
    position: relative;
    flex-shrink: 0;
    width: 220px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.video-thumbnail {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.video-info-card:hover .video-thumbnail {
    transform: scale(1.05);
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.video-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.video-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-author {
    color: var(--text-secondary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.video-author svg {
    color: var(--accent-secondary);
    width: 16px;
    height: 16px;
}

/* Formats Grid Layout */
.format-section-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.formats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.format-card {
    background: rgba(15, 17, 28, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.1rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.format-card:hover {
    border-color: var(--border-hover);
    background: rgba(15, 17, 28, 0.7);
    transform: translateY(-2px);
}

.format-card.active {
    border-color: var(--accent-primary);
    background: rgba(139, 92, 246, 0.08);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
}

.format-card.active::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 24px;
    height: 24px;
    background: var(--accent-primary);
    clip-path: polygon(100% 0, 0 0, 100% 100%);
}

.format-card.active::before {
    content: '✓';
    position: absolute;
    top: 2px;
    right: 4px;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    z-index: 1;
}

.format-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.format-badge {
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.format-badge.audio {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-secondary);
}

.format-badge.video {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-primary);
}

.format-icon {
    color: var(--text-secondary);
}

.format-card.active .format-icon {
    color: var(--accent-primary);
}

.format-name {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.format-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.download-action-wrapper {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
}

.btn-download {
    width: 100%;
    max-width: 280px;
    padding: 1.1rem 2rem;
    font-size: 1.15rem;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.1rem 2rem;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 150px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

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

/* Progress Section */
.progress-container {
    margin-top: 2rem;
    background: rgba(15, 17, 28, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 1.75rem;
    display: none; /* Controlled by JS */
    animation: fadeInUp 0.4s ease-out;
}

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

.progress-status {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-status .pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-secondary);
    animation: pulse 1.5s infinite;
}

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

.progress-percent {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--accent-secondary);
}

.progress-bar-bg {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    border-radius: 999px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.detail-item svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

/* Success Download Card */
.download-ready-card {
    margin-top: 2rem;
    background: rgba(16, 185, 129, 0.06);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 18px;
    padding: 1.75rem;
    text-align: center;
    display: none;
    animation: fadeInUp 0.4s ease-out;
}

.download-ready-icon {
    width: 48px;
    height: 48px;
    background: rgba(16, 185, 129, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--success);
    margin: 0 auto 1rem;
    font-size: 1.5rem;
}

.download-ready-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.download-ready-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 16px;
    padding: 1rem 2.5rem;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-success:hover {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

/* Alert Notification styles */
.alert {
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    border-radius: 14px;
    font-size: 0.95rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: shake 0.5s ease-in-out;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.alert svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Footer info */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    animation: fadeIn 1.2s ease-out;
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

footer a:hover {
    color: var(--accent-primary);
}

/* Animation utilities */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

/* Responsiveness */
@media (max-width: 768px) {
    .app-container {
        padding: 1.5rem 1rem;
    }
    
    h1 {
        font-size: 2.2rem;
    }
    
    .converter-card {
        padding: 1.5rem;
        border-radius: 20px;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .btn-primary {
        padding: 1.1rem;
        width: 100%;
    }
    
    .video-info-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1rem;
    }
    
    .video-thumbnail-wrapper {
        width: 100%;
        max-width: 280px;
    }
    
    .formats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

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