/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
    --bg-primary: #faf9f7;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #faf9f7;
    --bg-glass: rgba(255, 255, 255, 0.9);
    --bg-sidebar: #1a1a1a;
    --bg-sidebar-hover: #2a2a2a;
    --border-subtle: #ece8e3;
    --border-accent: #c4b5a3;
    --border-sidebar: #333333;

    --text-primary: #1a1a1a;
    --text-secondary: #6b6560;
    --text-muted: #a8a099;
    --text-sidebar: #e8e4df;
    --text-sidebar-muted: #8a8580;

    --accent: #1a1a1a;
    --accent-warm: #c4a882;
    --accent-soft: #e8dfd4;
    --accent-success: #4a7c59;
    --accent-error: #b85450;
    --accent-highlight: #c4a882;

    --gradient-btn: linear-gradient(135deg, #c4a882 0%, #a78a6a 100%);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Outfit', 'Inter', sans-serif;

    --transition-fast: 0.15s ease;
    --transition-smooth: 0.3s ease;

    --sidebar-width: 360px;
}

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

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

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* ── App Layout ────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* ── SIDEBAR ───────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-sidebar);
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-sidebar);
}

.brand-mark {
    width: 32px;
    height: 32px;
    background: var(--gradient-btn);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
}

.brand-name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-sidebar);
    letter-spacing: -0.01em;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 2px;
}

.sidebar-section {
    margin-bottom: 20px;
}

.section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-sidebar-muted);
    margin-bottom: 10px;
    padding-left: 2px;
}

/* ── Upload Zones (Sidebar) ────────────────────────────────────── */
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.upload-grid.triple {
    grid-template-columns: 1fr 1fr 1fr;
}

.upload-zone {
    position: relative;
    border: 1.5px dashed #444;
    border-radius: var(--radius-md);
    padding: 16px 10px 12px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

.upload-zone:hover {
    border-color: var(--accent-warm);
    background: rgba(196, 168, 130, 0.08);
}

.upload-zone.has-file {
    border-style: solid;
    border-color: var(--accent-warm);
    background: rgba(196, 168, 130, 0.1);
}

.upload-zone input[type="file"] {
    display: none;
}

.badge {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--accent-warm);
    color: #fff;
}

.badge.muted {
    background: #555;
    color: #aaa;
}

.upload-icon {
    color: var(--text-sidebar-muted);
    margin-bottom: 6px;
    display: flex;
    justify-content: center;
}

.upload-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-sidebar);
    margin-bottom: 2px;
}

.upload-hint {
    font-size: 0.6rem;
    color: var(--text-sidebar-muted);
}

.upload-zone .preview-img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
}

.upload-zone .remove-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* ── Mini Upload (Watermark) ──────────────────────────────────── */
.mini-upload {
    padding: 8px 10px;
    border: 1.5px dashed #444;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-upload-label {
    font-size: 0.7rem;
    color: var(--text-sidebar-muted);
}

/* ── Form Controls (Sidebar) ──────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-sidebar-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-select,
.form-input {
    width: 100%;
    padding: 7px 10px;
    font-size: 0.75rem;
    border: 1px solid #3a3a3a;
    border-radius: var(--radius-sm);
    background: #2a2a2a;
    color: var(--text-sidebar);
    font-family: var(--font-body);
    transition: border-color var(--transition-fast);
    outline: none;
}

.form-select:focus,
.form-input:focus {
    border-color: var(--accent-warm);
}

textarea.form-input {
    resize: vertical;
    min-height: 60px;
}

.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

/* ── Template Controls ────────────────────────────────────────── */
.template-controls {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    align-items: center;
}

.template-btn {
    padding: 6px 10px;
    font-size: 0.65rem;
    font-weight: 500;
    border: 1px solid #3a3a3a;
    border-radius: var(--radius-sm);
    background: #2a2a2a;
    color: var(--text-sidebar);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.template-btn:hover {
    background: #3a3a3a;
}

.template-btn.primary {
    background: var(--accent-warm);
    border-color: var(--accent-warm);
    color: #fff;
}

.template-btn.primary:hover {
    opacity: 0.9;
}

.template-btn.danger {
    background: var(--accent-error);
    border-color: var(--accent-error);
    color: #fff;
}

/* ── Generate Button ──────────────────────────────────────────── */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-sidebar);
}

.generate-btn {
    width: 100%;
    padding: 12px;
    background: var(--gradient-btn);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-smooth);
    letter-spacing: 0.02em;
}

/* ── Toggle Switch ─────────────────────────────────────────────── */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #444;
    border-radius: 22px;
    transition: background var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--accent-warm);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(18px);
}

.generate-btn:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(196, 168, 130, 0.3);
}

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

.generate-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ── MAIN CONTENT ──────────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}

.topbar-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.topbar-link {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent-warm);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

.topbar-link:hover {
    opacity: 0.7;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.card-title svg {
    color: var(--accent-warm);
    flex-shrink: 0;
}

/* ── Progress Section ──────────────────────────────────────────── */
.progress-section {
    display: none;
}

.progress-section.active {
    display: block;
}

.progress-bar-container {
    width: 100%;
    height: 4px;
    background: var(--accent-soft);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-warm);
    border-radius: 2px;
    transition: width 0.5s ease;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.progress-status {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.progress-percent {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-warm);
}

/* ── Steps Timeline ────────────────────────────────────────────── */
.steps-timeline {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.step-item.active {
    background: rgba(196, 168, 130, 0.08);
}

.step-item.done {
    opacity: 0.5;
}

.step-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.step-item.active .step-icon {
    background: var(--accent-warm);
    color: #fff;
}

.step-item.done .step-icon {
    background: var(--accent-success);
    color: #fff;
}

.step-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.step-item.active .step-label {
    color: var(--text-primary);
    font-weight: 500;
}

/* ── Analysis Panel ────────────────────────────────────────────── */
.analysis-panel {
    display: none;
}

.analysis-panel.active {
    display: block;
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}

.analysis-item {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.analysis-item .label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-warm);
    margin-bottom: 4px;
}

.analysis-item .value {
    font-size: 0.78rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* ── Prompt Panel ──────────────────────────────────────────────── */
.prompt-panel {
    display: none;
}

.prompt-panel.active {
    display: block;
}

.prompt-text {
    font-size: 0.8rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.scene-block {
    background: var(--bg-primary);
    border-left: 3px solid var(--accent-warm);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 12px 14px;
    margin-top: 10px;
}

.scene-block .scene-title {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.scene-block .scene-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ── Result Section ────────────────────────────────────────────── */
.result-section {
    display: none;
}

.result-section.active {
    display: block;
}

.result-video-wrapper {
    width: 100%;
    max-width: 500px;
    margin: 0 auto 16px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
}

.result-video-wrapper video {
    width: 100%;
    display: block;
}

.result-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-btn {
    padding: 10px 20px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-body);
    border: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.action-btn:hover {
    background: var(--bg-card-hover);
}

.btn-download {
    background: var(--accent-warm);
    color: #fff;
    border-color: var(--accent-warm);
}

.btn-download:hover {
    opacity: 0.9;
    background: var(--accent-warm);
}

.btn-whatsapp {
    background: #25D366;
    border: none;
    color: white;
}

.btn-whatsapp:hover {
    opacity: 0.9;
    background: #25D366;
}

/* ── Error ─────────────────────────────────────────────────────── */
.error-message {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    color: var(--accent-error);
    font-size: 0.82rem;
}

.error-message.active {
    display: flex;
}

/* ── Empty State ───────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 400px;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon {
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.82rem;
    max-width: 340px;
    line-height: 1.6;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
        height: auto;
    }

    body {
        overflow: auto;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-sidebar);
    }

    .sidebar-scroll {
        max-height: 60vh;
    }

    .main-content {
        min-height: 60vh;
    }

    .content-area {
        padding: 16px;
    }

    .empty-state {
        min-height: 200px;
    }
}