/* ============== Variables ============== */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: all 0.2s ease;
}

/* ============== Reset ============== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============== Container ============== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ============== Header ============== */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

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

.logo-icon {
    width: 40px;
    height: 40px;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ============== Cards ============== */
.card {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 600;
}

.title-icon {
    width: 24px;
    height: 24px;
    color: var(--success-color);
}

.error-icon {
    color: var(--error-color);
}

.card-error {
    border-color: var(--error-color);
    background: #fef2f2;
}

/* ============== Provider Selection ============== */
.provider-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.provider-option input {
    display: none;
}

.provider-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.provider-option input:checked + .provider-card {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.provider-card:hover {
    border-color: var(--primary-color);
}

.provider-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.gemini-icon {
    background: linear-gradient(135deg, #4285f4, #34a853);
    color: white;
}

.openrouter-icon {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: white;
    font-size: 0.875rem;
}

.provider-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.provider-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-badge {
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: #fef3c7;
    color: #92400e;
}

.status-badge.configured {
    background: #d1fae5;
    color: #065f46;
}

/* ============== API Key Section ============== */
.api-key-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

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

.reset-key-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.api-key-input-group {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.api-key-input-group .input-field {
    flex: 1;
}

.api-key-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.api-key-hint a {
    color: var(--primary-color);
    text-decoration: none;
}

.api-key-hint a:hover {
    text-decoration: underline;
}

/* ============== Model Selection ============== */
.model-selection {
    margin-top: 1.5rem;
}

/* ============== Form Elements ============== */
.form-group {
    margin-bottom: 1.5rem;
}

.label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.label-hint {
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.input-field,
.select-field,
.textarea-field {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-primary);
    transition: var(--transition);
}

.input-field:focus,
.select-field:focus,
.textarea-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.select-field {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    padding-right: 2.5rem;
}

.textarea-field {
    resize: vertical;
    min-height: 100px;
}

.field-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* ============== Checkbox ============== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.9375rem;
}

.checkbox-label input {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    transition: var(--transition);
    position: relative;
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-label input:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ============== Prompt Textarea ============== */
.prompt-textarea {
    font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    min-height: 250px;
    max-height: 400px;
    resize: vertical;
}

/* ============== Upload Area ============== */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.upload-hint {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.upload-formats {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ============== Video Info ============== */
.video-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.video-preview video {
    width: 100%;
    border-radius: 8px;
    background: #000;
}

.video-details h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    word-break: break-word;
}

.video-details p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.video-details strong {
    color: var(--text-primary);
}

/* ============== Buttons ============== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--background);
}

.btn-large {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

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

.btn-loading {
    display: inline-flex;
}

.spinner {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

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

/* ============== Progress ============== */
.progress-container {
    text-align: center;
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.progress-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

.progress-percent {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.progress-timer {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.results-time {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

/* ============== Results ============== */
.results-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.results-content {
    padding: 1.5rem;
    background: #f8fafc;
    border-radius: 8px;
    max-height: 600px;
    overflow-y: auto;
}

.results-content h1,
.results-content h2,
.results-content h3,
.results-content h4 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.results-content h1:first-child,
.results-content h2:first-child {
    margin-top: 0;
}

.results-content p {
    margin-bottom: 1rem;
}

.results-content ul,
.results-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.results-content li {
    margin-bottom: 0.5rem;
}

.results-content code {
    background: #e2e8f0;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.875em;
}

.results-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.results-content pre code {
    background: none;
    padding: 0;
}

.results-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
}

.results-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.results-content th,
.results-content td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    text-align: left;
}

.results-content th {
    background: #f1f5f9;
    font-weight: 600;
}

/* ============== Error ============== */
.error-message {
    color: var(--error-color);
    margin-bottom: 1rem;
}

/* ============== Toast ============== */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--error-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============== Footer ============== */
.footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

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

    .video-info {
        grid-template-columns: 1fr;
    }

    .provider-selection {
        grid-template-columns: 1fr;
    }

    .api-key-input-group {
        flex-direction: column;
    }

    .results-actions {
        flex-direction: column;
    }

    .results-actions .btn {
        width: 100%;
    }
}
