/* ===== VARIABLES ===== */
:root {
    --bg-base: #0a0a0b;
    --bg-elevated: #141416;
    --bg-surface: #1c1c1f;
    --bg-hover: #252528;
    
    --accent: #00d4ff;
    --accent-hover: #00b8e6;
    --accent-glow: rgba(0, 212, 255, 0.15);
    
    --text-primary: #ffffff;
    --text-secondary: #a0a0a5;
    --text-muted: #6b6b70;
    
    --border: #2a2a2e;
    --border-hover: #3a3a3f;
    
    --success: #00c853;
    --error: #ff4757;
    --warning: #ffa502;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    
    --transition: 0.2s ease;
}

/* ===== RESET ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== BASE ===== */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* ===== LAYOUT ===== */
.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== HEADER ===== */
header {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: var(--bg-base);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 400;
}

/* ===== MAIN ===== */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ===== CARD ===== */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.card-icon {
    font-size: 1.25rem;
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ===== INPUT ===== */
.input-wrapper {
    display: flex;
    gap: 10px;
}

.input-wrapper input {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-base);
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-icon {
    font-size: 1.1rem;
    transition: transform var(--transition);
}

.btn-primary:hover .btn-icon {
    transform: translateX(3px);
}

.btn-download {
    width: 100%;
    padding: 16px 24px;
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-base);
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 8px;
    border-radius: var(--radius-md);
}

.btn-download:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-icon-left {
    font-size: 1.2rem;
}

/* ===== ERROR MESSAGE ===== */
.error-message {
    margin-top: 12px;
    padding: 12px 16px;
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 0.9rem;
    display: none;
}

.error-message.show {
    display: block;
}

/* ===== LOADING ===== */
.loading {
    text-align: center;
    padding: 48px 24px;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-secondary);
}

/* ===== VIDEO PREVIEW ===== */
.video-preview {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.thumbnail-wrapper {
    position: relative;
    flex-shrink: 0;
}

.thumbnail-wrapper img {
    width: 160px;
    height: 90px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
}

.duration-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.85);
    color: var(--text-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
}

.video-info {
    flex: 1;
    display: flex;
    align-items: center;
}

.video-info h3 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== SECTIONS ===== */
.section {
    margin-bottom: 24px;
}

.section:last-of-type {
    margin-bottom: 16px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.section-icon {
    font-size: 1.1rem;
}

.section-header h3 {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ===== TOGGLE GROUP (Format Selection) ===== */
.toggle-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.toggle-option {
    cursor: pointer;
}

.toggle-option input {
    display: none;
}

.toggle-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 12px;
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.toggle-option:hover .toggle-content {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.toggle-option input:checked + .toggle-content {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.toggle-icon {
    font-size: 1.5rem;
}

.toggle-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.toggle-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== RESOLUTION GRID ===== */
.resolution-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.radio-label {
    cursor: pointer;
}

.radio-label input {
    display: none;
}

.radio-label span {
    display: block;
    padding: 12px 8px;
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition);
}

.radio-label:hover span {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.radio-label input:checked + span {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--accent);
}

/* ===== CHECKBOX ===== */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.checkbox-wrapper:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
}

.checkbox-wrapper input {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 5px;
    transition: var(--transition);
    position: relative;
    flex-shrink: 0;
}

.checkbox-wrapper input:checked + .checkbox-custom {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-wrapper input:checked + .checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--bg-base);
    font-size: 0.75rem;
    font-weight: 700;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.checkbox-icon {
    font-size: 1.1rem;
}

/* ===== TIME INPUTS ===== */
.time-inputs {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
}

.time-field {
    flex: 1;
}

.time-field label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.time-field input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    text-align: center;
    transition: var(--transition);
}

.time-field input::placeholder {
    color: var(--text-muted);
}

.time-field input:focus {
    outline: none;
    border-color: var(--accent);
}

.time-separator {
    color: var(--text-muted);
    font-size: 1.2rem;
    padding-bottom: 10px;
}

/* ===== FOOTER ===== */
footer {
    text-align: center;
    padding-top: 32px;
    margin-top: auto;
}

footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== PROGRESS BAR (for download page) ===== */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-surface);
    border-radius: 4px;
    overflow: hidden;
    margin: 20px 0;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s;
    border-radius: 4px;
}

.progress-bar.animated {
    width: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 50%, var(--accent) 100%);
    background-size: 200% 100%;
    animation: progress-animation 1.5s linear infinite;
}

@keyframes progress-animation {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#progressStatus {
    color: var(--text-primary);
    margin-bottom: 10px;
}

#progressMessage {
    color: var(--text-secondary);
    margin-top: 10px;
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 440px;
    width: 90%;
    box-shadow: var(--shadow);
}

.modal-content h3 {
    margin-bottom: 12px;
    font-size: 1.2rem;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .container {
        padding: 24px 16px;
    }
    
    .logo h1 {
        font-size: 1.5rem;
    }
    
    .logo-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .card {
        padding: 20px;
    }
    
    .input-wrapper {
        flex-direction: column;
    }
    
    .input-wrapper input,
    .btn {
        width: 100%;
    }
    
    .video-preview {
        flex-direction: column;
    }
    
    .thumbnail-wrapper img {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }
    
    .toggle-group {
        grid-template-columns: 1fr 1fr;
    }
    
    .resolution-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .time-inputs {
        flex-direction: column;
        gap: 16px;
    }
    
    .time-separator {
        display: none;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-buttons .btn {
        width: 100%;
    }
}
