/**
 * Generator: full-height app column inside dashboard (navbar + canvas + command bar).
 * Height/overflow are owned here and on parent .dc-wrap / .dc-main — not guessed padding for a fixed bar.
 */

/* ----- Dashboard shell: generator fills viewport below header (no page scroll) ----- */
body.dashboard-v2-body:has(#msGeneratorPage) {
    /* FAB is reparented to body — custom props must live on body for calc() to see them */
    --ms-gen-fab-bottom-offset: 200px;
    overflow-x: hidden;
    overflow-y: hidden;
    height: 100dvh;
}

@media (max-width: 1180px) {
    body.dashboard-v2-body:has(#msGeneratorPage) {
        --ms-gen-fab-bottom-offset: 248px;
    }
}

@media (max-width: 900px) {
    body.dashboard-v2-body:has(#msGeneratorPage) {
        --ms-gen-fab-bottom-offset: 300px;
    }
}

body.dashboard-v2-body:has(#msGeneratorPage) .dc-wrap {
    min-height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Override dashboard-v2 “flex: none” so main absorbs remaining height below sticky header */
body.dashboard-v2-body:has(#msGeneratorPage) main.dc-main.d2-main-wrap {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-width: none;
    width: 100%;
}

body.dashboard-v2-body:has(#msGeneratorPage) .dc-footer {
    display: none !important;
}

/* AI Director launcher: sit above command bar + safe area */
body.dashboard-v2-body:has(#msGeneratorPage) #ai-director-floating-wrap {
    bottom: calc(var(--ms-gen-fab-bottom-offset, 200px) + env(safe-area-inset-bottom, 0px)) !important;
}

.ms-generator-page {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    height: 100%;
    /* visible: fixed modals live inside this section; clip only .ms-generator-shell */
    overflow: visible;
    color: #f5f5f5;
    isolation: isolate;
}

/* Inner layout: canvas grows, command strip at bottom (in flow — no clipping) */
.ms-generator-shell {
    position: relative;
    box-sizing: border-box;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 4px 0;
}

/* v2 layout chain: single flex column, no extra viewport min-height fights */
.d2-layout:has(#msGeneratorPage) {
    flex: 1 1 auto;
    min-height: 0;
    align-items: stretch;
    justify-content: flex-start;
    overflow: hidden;
    width: 100%;
}

.main-content-wrapper:has(#msGeneratorPage) {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    align-self: stretch;
    width: 100%;
}

.main-content-wrapper:has(#msGeneratorPage) > main.d2-main {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ms-generator-page .d2-layout,
.ms-generator-page .main-content-wrapper,
.ms-generator-page .d2-main-generator {
    background: transparent;
}

.ms-generator-page .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ----- Generator: Script & Segments modal ----- */
.ms-generator-segments-loading {
    color: rgba(255,255,255,0.72);
    font-size: 0.9rem;
    padding: 14px 0;
}
.ms-generator-segments-empty {
    color: rgba(255,255,255,0.72);
    font-size: 0.9rem;
    padding: 14px 0;
    border: 1px dashed rgba(255,255,255,0.18);
    border-radius: 12px;
    background: rgba(0,0,0,0.18);
    text-align: center;
}
.ms-generator-segments-body {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 14px;
    align-items: start;
}
.ms-generator-segments-script {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ms-generator-segments-script-panel {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.16);
    border-radius: 12px;
    padding: 10px 12px;
}
.ms-generator-segments-script-panel summary {
    cursor: pointer;
    color: rgba(224,231,255,0.92);
    font-weight: 600;
    font-size: 0.9rem;
    list-style: none;
}
.ms-generator-segments-script-panel summary::-webkit-details-marker { display: none; }
.ms-generator-segments-script-text {
    margin-top: 10px;
    white-space: pre-wrap;
    font-size: 0.84rem;
    line-height: 1.35;
    color: rgba(255,255,255,0.78);
    max-height: 240px;
    overflow: auto;
}
.ms-generator-segments-list-wrap {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(0,0,0,0.16);
    border-radius: 12px;
    padding: 10px 10px 8px;
    min-height: 220px;
}
.ms-generator-segments-list-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 4px 8px;
}
.ms-generator-segments-list-meta { font-size: 0.78rem; color: rgba(255,255,255,0.62); }
.ms-generator-segments-list { display: flex; flex-direction: column; gap: 8px; }
.ms-gen-seg-empty { color: rgba(255,255,255,0.68); font-size: 0.86rem; padding: 10px 6px; }
.ms-gen-seg-row {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    padding: 8px;
    display: flex;
    gap: 10px;
    align-items: center;
    text-align: left;
    color: rgba(255,255,255,0.92);
    cursor: pointer;
}
.ms-gen-seg-row:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.18); }
.ms-gen-seg-row.is-selected { border-color: rgba(129,140,248,0.55); background: rgba(79,70,229,0.10); }
.ms-gen-seg-thumb { width: 72px; height: 48px; flex: 0 0 auto; border-radius: 10px; overflow: hidden; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.10); }
.ms-gen-seg-thumb img, .ms-gen-seg-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.ms-gen-seg-thumb video { pointer-events: none; }
.ms-gen-seg-thumb-empty { width: 100%; height: 100%; display: block; background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(0,0,0,0.2)); }
.ms-gen-seg-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ms-gen-seg-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ms-gen-seg-title { font-size: 0.86rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-gen-seg-sub { font-size: 0.78rem; color: rgba(255,255,255,0.70); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-gen-seg-meta { font-size: 0.74rem; color: rgba(255,255,255,0.58); }
.ms-gen-seg-status {
    font-size: 0.72rem;
    padding: 3px 7px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
}
.ms-gen-seg-status--not_started { background: rgba(148,163,184,0.20); border-color: rgba(148,163,184,0.35); }
.ms-gen-seg-status--ready_to_generate { background: rgba(14,165,233,0.18); border-color: rgba(14,165,233,0.35); }
.ms-gen-seg-status--in_progress { background: rgba(99,102,241,0.18); border-color: rgba(129,140,248,0.45); }
.ms-gen-seg-status--generated { background: rgba(245,158,11,0.18); border-color: rgba(245,158,11,0.40); }
.ms-gen-seg-status--approved { background: rgba(34,197,94,0.18); border-color: rgba(34,197,94,0.38); }

@media (max-width: 900px) {
    .ms-generator-segments-body { grid-template-columns: 1fr; }
}
