/* ========================================
   Reset & Base Styles
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
}

:root {
    --primary: #1d9bf0;
    --primary-dark: #1a8cd8;
    --primary-light: #8ecdf8;
    --text: #0f1419;
    --text-light: #536471;
    --bg: #ffffff;
    --bg-secondary: #f7f9f9;
    --border: #eff3f4;
    --error: #f4212e;
    --success: #00ba7c;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --error-bg: #fff1f2;
    --error-border: #ffe4e6;
}

/* ========================================
   Initial Load Animation Prevention
   ======================================== */
/* 初始加载时禁用动画，加载完成后通过 JS 移除此类 */
.no-animations .logo,
.no-animations .input-section {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}

/* Dark mode colors */
[data-theme="dark"] {
    --primary: #1d9bf0;
    --primary-dark: #1a8cd8;
    --primary-light: #8ecdf8;
    --text: #e7e9ea;
    --text-light: #8b98a5;
    --bg: #000000;
    --bg-secondary: #0a0a0a;
    --border: #2f3336;
    --error: #f4212e;
    --success: #00ba7c;
    --shadow: 0 1px 3px rgba(255, 255, 255, 0.05);
    --shadow-md: 0 2px 8px rgba(255, 255, 255, 0.08);
    --shadow-lg: 0 8px 16px rgba(255, 255, 255, 0.1);
    --error-bg: #200a0a;
    --error-border: #3a1515;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-secondary);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* Theme transition - only enabled after page load */
body.animations-enabled {
    transition: background-color var(--transition-slow), color var(--transition);
}

/* ========================================
   Layout
   ======================================== */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 3.5rem 2rem;
    flex: 1;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    font-size: 1.875rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.875rem;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo-icon {
    width: 36px;
    height: 36px;
    color: #1d9bf0;
    flex-shrink: 0;
    transition: opacity var(--transition);
}

.logo:hover .logo-icon {
    opacity: 0.8;
}

/* ========================================
   Input Section
   ======================================== */
.input-section {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.25rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-slow);
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.url-input {
    width: 100%;
    padding: 1.125rem 1.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: all var(--transition);
    outline: none;
    margin-bottom: 1.25rem;
}

.url-input::placeholder {
    color: var(--text-light);
    transition: color var(--transition);
}

.url-input:hover {
    border-color: var(--primary-light);
}

.url-input:focus,
.url-input:focus-visible {
    border-color: var(--primary);
    outline: none;
    border-radius: var(--radius);
}

.download-btn {
    width: 100%;
    padding: 1rem 1.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1.0625rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.download-btn:hover {
    background: var(--primary-dark);
    /* box-shadow: 0 2px 8px rgba(29, 155, 240, 0.15); */
}

.download-btn:active {
    transform: scale(0.98);
}

.download-btn:disabled {
    background: var(--text-light);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}


/* ========================================
   Loading Spinner
   ======================================== */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 2.5rem;
    overflow: hidden;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

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

.loading-spinner p {
    color: var(--text-light);
    font-size: 0.9375rem;
    font-weight: 500;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

/* ========================================
   Error Message
   ======================================== */
.error-message {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1.125rem 1.25rem;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: var(--radius);
    color: var(--error);
    font-size: 0.9375rem;
    margin-top: 1.25rem;
    animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-8px);
    }

    75% {
        transform: translateX(8px);
    }
}

.error-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    animation: scaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes scaleIn {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

/* ========================================
   Video Preview
   ======================================== */
.video-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.25rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all var(--transition-slow);
}

.section-title {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1.75rem;
    position: relative;
    padding-bottom: 0.75rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
}

.video-container {
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-md);
}

.video-container video {
    width: 100%;
    display: block;
    max-height: 540px;
}

.video-info {
    margin-bottom: 1.75rem;
    padding: 1.25rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    transition: background-color var(--transition);
}

.video-info h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.625rem;
    line-height: 1.5;
}

.video-author {
    color: var(--text-light);
    font-size: 0.9375rem;
    font-weight: 500;
}

/* ========================================
   Quality Options
   ======================================== */
.quality-options h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1.125rem;
}

.quality-buttons {
    display: flex;
    gap: 0.875rem;
    flex-wrap: wrap;
}

.quality-btn {
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

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

.quality-btn:active {
    transform: scale(0.97);
}

/* ========================================
   Footer
   ======================================== */
.footer {
    text-align: center;
    padding: 2.5rem 0;
    color: var(--text-light);
    font-size: 0.9rem;
    background: var(--bg-secondary);
    margin-top: auto;
    border-top: 1px solid var(--border);
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-text {
    margin: 0;
    color: var(--text-light);
    font-size: 0.875rem;
}

.heart {
    color: #e74c3c;
    display: inline-block;
    animation: heartbeat 1.8s ease-in-out infinite;
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    15% {
        transform: scale(1.15);
    }

    30% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.1);
    }

    60% {
        transform: scale(1);
    }
}

.footer-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: all var(--transition);
}

.footer-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.footer-links {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

.social-link {
    color: var(--text-light);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem;
    border-radius: 50%;
    transition: all var(--transition);
    opacity: 0.7;
}

.social-link:hover {
    color: var(--primary);
    opacity: 1;
}

.social-link svg {
    flex-shrink: 0;
}

/* ========================================
   Utility Classes
   ======================================== */
.hidden {
    display: none !important;
}

/* Expand animation for input section */
.expand-enter {
    max-height: 500px;
    opacity: 1;
    overflow: hidden;
}

.expand-exit {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .container {
        padding: 2.5rem 1.5rem;
    }

    .input-section,
    .video-preview {
        padding: 1.75rem;
    }

    .logo {
        font-size: 1.625rem;
        gap: 0.75rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 2rem 1rem;
    }

    .input-section,
    .video-preview {
        padding: 1.5rem;
    }

    .logo {
        font-size: 1.5rem;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
    }

    .url-input {
        padding: 1rem 1.25rem;
        font-size: 16px;
    }

    .download-btn {
        padding: 0.9375rem 1.5rem;
        font-size: 1rem;
    }

    .section-title {
        font-size: 1.25rem;
    }

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

    .quality-btn {
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1rem;
    }

    .video-container video {
        max-height: 400px;
    }

    .footer {
        padding: 2rem 0;
    }

    .footer-content {
        gap: 0.75rem;
    }

    .footer-text {
        font-size: 0.8125rem;
    }

    .social-link {
        padding: 0.5rem;
    }

    .social-link svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 420px) {
    .container {
        padding: 1.5rem 0.75rem;
    }

    .input-section,
    .video-preview {
        padding: 1.25rem;
    }

    .logo {
        font-size: 1.375rem;
    }
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.video-preview:not(.hidden) {
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Selection color */
::selection {
    background: var(--primary);
    color: white;
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Input keeps its own border-radius */
.url-input:focus-visible {
    outline: none;
}