/* ========================================
   Yapit Shell — sidebar + canvas layout
   Built on BeautifulGrids grid-cell system
   Light theme
   ======================================== */

/* Override old dark tokens → light */
:root {
    --bg-page: #FAFAFA;
    --bg-surface: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-elevated: #F3F4F6;
    --border: #E5E7EB;
    --border-light: #F3F4F6;

    --text-primary: #1A1A1A;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;

    --accent: #f0c850;
    --accent-dim: rgba(240, 200, 80, 0.1);
    --accent-hover: #d4a830;
    --accent-text: #1A1A1A;
    --accent-subtle: rgba(240, 200, 80, 0.15);
    --waveform: #cc9933;
    --waveform-alt: #b8872e;
    --danger: #EF4444;
    --danger-dim: rgba(239, 68, 68, 0.1);
    --success: #10B981;
    --success-dim: rgba(16, 185, 129, 0.1);
}

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

html, body {
    height: 100% !important;
    overflow: hidden !important;
    font-family: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    background: var(--color-bg-primary) !important;
    color: var(--color-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

/* Force Poppins everywhere — kill old font references */
*, *::before, *::after {
    font-family: inherit;
}

/* Old phase sections (hidden compat elements) */
section.phase { display: none !important; }

/* ---- App shell grid ---- */

.app-shell {
    display: grid;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Desktop: sidebar left, canvas right */
@media (min-width: 601px) {
    .app-shell {
        grid-template-columns: var(--grid-cell, 30px) 1fr;
        grid-template-rows: auto 1fr;
        grid-template-areas:
            "header header"
            "sidebar canvas";
    }
}

/* Mobile: canvas on top, sidebar bottom bar */
@media (max-width: 600px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr var(--grid-cell, 30px);
        grid-template-areas:
            "header"
            "canvas"
            "sidebar";
    }
}

/* ---- Header ---- */

.shell-header {
    grid-area: header;
    height: var(--grid-cell, 30px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    z-index: 10;
}

.shell-logo {
    font-family: 'Poppins', sans-serif !important;
    font-size: var(--font-size-heading);
    font-weight: 700;
    color: #8B6914;
    letter-spacing: 1px;
}

.shell-header-center {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Hybrid slider/stepper outside panels — standalone styles */
.hybrid-slider--nav {
    display: flex;
    align-items: center;
    gap: 0;
}

.hybrid-slider--nav .hybrid-btn {
    flex-shrink: 0;
    width: var(--grid-cell, 30px);
    height: var(--grid-cell, 30px);
    border: 1px solid var(--color-border, #E5E7EB);
    background: var(--color-bg-secondary, #fff);
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hybrid-slider--nav .hybrid-btn:hover {
    background: var(--color-bg-tertiary, #F3F4F6);
}

.hybrid-slider--nav .hybrid-btn:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.hybrid-slider--nav .hybrid-track {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    border-top: 1px solid var(--color-border, #E5E7EB);
    border-bottom: 1px solid var(--color-border, #E5E7EB);
    height: var(--grid-cell, 30px);
    min-width: 80px;
}

.hybrid-slider--nav .slider-label {
    font-size: var(--font-size-caption, 10px);
    font-weight: 600;
    color: var(--color-text-muted);
}

.hybrid-slider--nav .slider-value {
    font-size: var(--font-size-caption, 10px);
    font-weight: 600;
    color: var(--color-text-secondary);
}

/* Standalone hybrid-btn used outside panels */
.canvas-actions .hybrid-btn {
    flex-shrink: 0;
    width: var(--grid-cell, 30px);
    height: var(--grid-cell, 30px);
    border: 1px solid var(--color-border, #E5E7EB);
    background: var(--color-bg-secondary, #fff);
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-actions .hybrid-btn:hover {
    background: var(--color-bg-tertiary);
}

.canvas-actions .hybrid-btn:disabled {
    opacity: 0.3;
    pointer-events: none;
}

.canvas-actions .hybrid-track {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    border-top: 1px solid var(--color-border, #E5E7EB);
    border-bottom: 1px solid var(--color-border, #E5E7EB);
    height: var(--grid-cell, 30px);
}

.canvas-actions .slider-label {
    font-size: var(--font-size-caption, 10px);
    font-weight: 600;
    color: var(--color-text-muted);
}

.canvas-actions .slider-value {
    font-size: var(--font-size-caption, 10px);
    font-weight: 600;
    color: var(--color-text-secondary);
}

.shell-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Old scene-nav-compact — replaced by hybrid-slider--nav */

/* ---- Sidebar ---- */

.shell-sidebar {
    grid-area: sidebar;
    display: flex;
    background: var(--color-bg-secondary);
    z-index: 10;
}

/* Desktop: vertical column */
@media (min-width: 601px) {
    .shell-sidebar {
        flex-direction: column;
        width: var(--grid-cell, 30px);
        border-right: 1px solid var(--color-border);
        padding: 2px 0;
        gap: 2px;
    }
}

/* Mobile: horizontal bottom bar */
@media (max-width: 600px) {
    .shell-sidebar {
        flex-direction: row;
        height: var(--grid-cell, 30px);
        border-top: 1px solid var(--color-border);
        justify-content: space-around;
        padding: 0 2px;
    }
}

/* Sidebar buttons */
.sidebar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color 0.15s, background 0.15s;
    font-family: inherit;
    padding: 0;
    border-radius: 0;
    position: relative;
}

@media (min-width: 601px) {
    .sidebar-btn {
        width: var(--grid-cell, 30px);
        height: var(--grid-cell, 30px);
    }
}

@media (max-width: 600px) {
    .sidebar-btn {
        flex: 1;
        height: 100%;
    }
}

.sidebar-btn:hover {
    color: var(--color-text-secondary);
    background: rgba(0, 0, 0, 0.03);
}

/* Active phase = red */
.sidebar-btn.active {
    color: #DC2626;
    background: rgba(239, 68, 68, 0.1);
    box-shadow: inset 3px 0 0 #DC2626;
}

@media (max-width: 600px) {
    .sidebar-btn.active {
        box-shadow: inset 0 -3px 0 #DC2626;
    }
}

/* Completed phase = yellow */
.sidebar-btn.completed {
    color: #8B6914;
    background: rgba(240, 200, 80, 0.1);
}

.sidebar-btn.completed .sidebar-icon::after {
    content: '✓';
    font-size: 7px;
    position: absolute;
    bottom: -1px;
    right: -1px;
}

.sidebar-icon {
    font-size: 14px;
    line-height: 1;
    font-weight: 600;
}

.sidebar-label {
    font-size: 7px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
    margin-top: 1px;
}

/* ---- Canvas area ---- */

.shell-canvas {
    grid-area: canvas;
    position: relative;
    overflow: hidden;
    background: var(--color-bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: padding-left 0.15s ease;
}

/* Canvas content — each phase renders here */
.canvas-view {
    display: none !important;
    width: 100%;
    height: 100%;
    position: relative;
}

.canvas-view.active {
    display: flex !important;
    flex-direction: column;
}

/* ---- Canvas: Script phase ---- */

.canvas-script {
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.canvas-script .script-textarea,
#script-input-view textarea {
    width: 100% !important;
    flex: 1 !important;
    min-height: 0 !important;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text-primary);
    padding: 16px;
    resize: none;
    outline: none;
}

.canvas-script .script-textarea:focus {
    border-color: rgba(240, 200, 80, 0.5);
}

.canvas-script .script-textarea::placeholder {
    color: var(--color-text-muted);
}

/* Card list in script canvas */
.canvas-script .card-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
}

/* Speed bar */
.speed-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

/* ---- Canvas: Record phase ---- */

.canvas-record {
    align-items: center;
    justify-content: center;
}

.canvas-record .camera-area {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--color-bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-record video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.canvas-record .teleprompter-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    pointer-events: none;
}

.canvas-record .teleprompter-text {
    font-size: clamp(18px, 4vw, 32px);
    font-weight: 600;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    text-align: center;
    line-height: 1.5;
}

.canvas-record .record-status {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-caption);
    font-weight: 700;
    color: var(--color-danger);
}

.canvas-record .rec-dot {
    width: 8px;
    height: 8px;
    background: var(--color-danger);
    border-radius: 50%;
    animation: recPulse 1s ease-in-out infinite;
}

@keyframes recPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ---- Canvas: Trim phase — uses glass-card + inline styles ---- */

/* ---- Canvas: Dress/Compose phase ---- */

.canvas-dress {
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.canvas-dress .compose-preview {
    aspect-ratio: 9 / 16;
    max-height: 100%;
    max-width: 100%;
    width: auto;
    background: var(--color-bg-tertiary);
    border-radius: 6px;
    border: 1px solid var(--color-border);
    position: relative;
    overflow: hidden;
}

/* ---- Canvas: Export phase ---- */

.canvas-export {
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* canvas-actions removed — all controls live in panels now */

/* ---- Buttons ---- */

.btn-primary {
    height: var(--grid-cell, 30px);
    background: var(--color-accent, #f0c850);
    color: #111;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: var(--font-size-control);
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
    padding: 0 16px;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.3; pointer-events: none; }

.btn-secondary {
    height: var(--grid-cell, 30px);
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: inherit;
    font-size: var(--font-size-control);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    padding: 0 12px;
}

.btn-secondary:hover { background: var(--color-border-light); }
.btn-secondary:active { transform: scale(0.98); }

.btn-record {
    height: calc(var(--grid-cell, 30px) * 1.5);
    min-width: calc(var(--grid-cell, 30px) * 4);
    background: var(--color-danger);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: var(--font-size-heading);
    font-weight: 700;
    cursor: pointer;
}

.btn-stop {
    height: calc(var(--grid-cell, 30px) * 1.5);
    min-width: calc(var(--grid-cell, 30px) * 4);
    background: var(--color-text-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: var(--font-size-heading);
    font-weight: 700;
    cursor: pointer;
}

/* ---- Countdown ---- */

.countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
}

.countdown-overlay.hidden { display: none; }

.countdown-number {
    font-size: 72px;
    font-weight: 800;
    color: var(--color-accent, #f0c850);
    animation: countPulse 0.8s ease-in-out;
}

@keyframes countPulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* ---- Textarea styling ---- */

textarea {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 16px;
    line-height: 1.85;
    padding: 16px;
    resize: none;
    outline: none;
}

textarea::placeholder {
    color: var(--color-text-muted);
}

textarea:focus {
    border-color: rgba(240, 200, 80, 0.5);
}

/* ---- Input fields ---- */

input[type="text"] {
    background: var(--color-bg-secondary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0 12px;
    height: var(--grid-cell, 30px);
    font-size: var(--font-size-label, 12px);
    outline: none;
}

input[type="text"]:focus {
    border-color: rgba(240, 200, 80, 0.5);
}

/* ---- Utility ---- */

.hidden { display: none !important; }
