/* Visual Design Token Variables */
:root {
    --bg-dark: #07060f;
    --card-bg: rgba(18, 14, 33, 0.5);
    --border-color: rgba(255, 255, 255, 0.08);
    --accent-primary: linear-gradient(135deg, #6366f1, #a855f7);
    --accent-glow: rgba(99, 102, 241, 0.35);
    --accent-secondary: #ec4899;
    --text-primary: #f4f4f7;
    --text-muted: #9ba1b4;
    --success-glow: rgba(34, 197, 94, 0.2);
    --error-glow: rgba(239, 68, 68, 0.25);
    --transition-smooth: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Global Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Premium Background Mesh Gradient */
.bg-gradient-mesh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 20%, rgba(99, 102, 241, 0.18) 0px, transparent 50%),
        radial-gradient(at 90% 10%, rgba(168, 85, 247, 0.18) 0px, transparent 50%),
        radial-gradient(at 50% 80%, rgba(236, 72, 153, 0.08) 0px, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

/* Application Layout */
.app-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    z-index: 10;
}

/* Header Styles */
.app-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.04);
    padding: 8px 18px;
    border-radius: 100px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.logo-icon {
    width: 22px;
    height: 22px;
    color: #a855f7;
    animation: bounceSlow 3s infinite ease-in-out;
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.logo-text span {
    background: var(--accent-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-title {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.5px;
    background: linear-gradient(180deg, #ffffff 0%, #d8daf0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 580px;
    line-height: 1.6;
    font-weight: 300;
}

/* Main Card - Glassmorphism Panel */
.main-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    padding: 44px;
    box-shadow: 
        0 24px 64px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: var(--transition-smooth);
    position: relative;
}

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

.opacity-0 {
    opacity: 0;
}

/* stage transitions */
.input-stage, .preview-stage, .download-stage {
    animation: fadeIn 0.45s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

/* Stage 1: URL Input styling */
.input-stage {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    border: 1.5px solid var(--border-color);
    border-radius: 16px;
    padding: 6px 6px 6px 18px;
    transition: var(--transition-smooth);
    position: relative;
    width: 100%;
}

.input-group:focus-within {
    border-color: #8b5cf6;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.15);
}

.input-icon-wrapper {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    margin-right: 12px;
}

.input-icon {
    width: 20px;
    height: 20px;
}

.input-group input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 300;
    padding: 10px 0;
}

.input-group input::placeholder {
    color: #6a6f83;
}

/* Paste button styling */
.btn-paste {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-paste:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.btn-paste svg {
    width: 15px;
    height: 15px;
}

/* Buttons styling */
.btn-primary {
    background: var(--accent-primary);
    border: none;
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 15px 30px;
    border-radius: 16px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 25px var(--accent-glow);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.45);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    padding: 12px 24px;
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-secondary svg {
    width: 16px;
    height: 16px;
    transition: var(--transition-smooth);
}

.btn-secondary:hover svg {
    transform: translateX(-3px);
}

/* Spinner Icon */
.spinner-icon {
    animation: rotate 2s linear infinite;
    width: 22px;
    height: 22px;
}

.spinner-icon .path {
    stroke: #ffffff;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

/* Stage 2: Preview Card Grid */
.preview-content {
    display: grid;
    grid-template-columns: 1.1fr 1.2fr;
    gap: 36px;
    align-items: start;
}

.thumbnail-wrapper {
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--border-color);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
    background: #000;
}

.video-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
}

.thumbnail-wrapper:hover .video-thumbnail {
    transform: scale(1.04);
}

.duration-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    border: 0.5px solid rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

.info-wrapper {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.badge-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.platform-badge {
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.25);
    color: #c084fc;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.uploader-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 100px;
}

.video-title {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-primary);
}

.format-selection {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.format-selection label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.select-wrapper {
    position: relative;
    width: 100%;
}

.select-wrapper select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 18px;
    font-size: 0.95rem;
    border-radius: 12px;
    outline: none;
    appearance: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.select-wrapper select:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.1);
}

.select-chevron {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    transition: var(--transition-smooth);
}

.select-wrapper select:focus + .select-chevron {
    transform: translateY(-50%) rotate(180deg);
    color: #c084fc;
}

.button-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.btn-download svg {
    width: 18px;
    height: 18px;
}

/* Stage 3: Download active staging */
.download-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 0;
}

.pulse-ring {
    width: 80px;
    height: 80px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
    position: relative;
    border: 1px solid rgba(139, 92, 246, 0.2);
    animation: pulseGlow 2s infinite;
}

.downloading-icon {
    width: 32px;
    height: 32px;
    color: #a855f7;
    animation: downloadSlide 1.5s infinite ease-in-out;
}

.download-status-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.download-status-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 300;
    max-width: 400px;
    line-height: 1.5;
    margin-bottom: 32px;
}

.progress-container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 100px;
    overflow: hidden;
    border: 0.5px solid var(--border-color);
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: var(--accent-primary);
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
    border-radius: 100px;
    transition: width 0.4s ease;
}

.progress-text-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
}

.progress-percent {
    color: #c084fc;
}

.progress-filesize {
    color: var(--text-muted);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    background: rgba(18, 14, 33, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px 20px;
    min-width: 300px;
    max-width: 420px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: flex-start; /* Aligns icon with the top line of text */
    gap: 12px;
    animation: slideIn 0.35s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.toast.error {
    border-left: 4px solid #ef4444;
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.08);
}

.toast.success {
    border-left: 4px solid #22c55e;
    box-shadow: 0 10px 30px rgba(34, 197, 94, 0.08);
}

.toast.info {
    border-left: 4px solid #6366f1;
}

.toast-message {
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.4;
    padding-top: 1px; /* Vertically aligns text perfectly with the icon */
}

.toast-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    align-self: flex-start; /* Aligns close button with the top line of text */
    padding-top: 2px;
}

.toast-close svg {
    width: 14px;
    height: 14px;
}

/* Animations Keyframes */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@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; }
}

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

@keyframes downloadSlide {
    0% { transform: translateY(-6px); opacity: 0; }
    50% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(6px); opacity: 0; }
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(139, 92, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
    body {
        padding: 16px;
    }
    
    .app-container {
        gap: 24px;
    }
    
    .app-title {
        font-size: 1.75rem;
    }
    
    .app-subtitle {
        font-size: 0.95rem;
    }
    
    .main-card {
        padding: 24px;
        border-radius: 20px;
    }
    
    .preview-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .input-group {
        padding: 4px 4px 4px 12px;
    }
    
    .input-group input {
        font-size: 0.9rem;
    }
    
    .btn-paste {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
    
    .toast-container {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
    
    .toast {
        min-width: unset;
        width: 100%;
    }
}
