/*
 * Canlı üretim ekranı (config['enable_live_streaming_preview']).
 * Koyu bir "stüdyo" arayüzü: üretilen site odakta kalsın diye çevresi sessiz tutuldu.
 * Tek vurgu rengi (sinyal turuncusu) sadece canlı / aktif olan şeyi işaretler; ayrım kutularla değil,
 * ince çizgiler, tipografi ve renk tonuyla yapılır.
 */

#streamingScreen {
    --sp-bg: #09090b;
    --sp-panel: #0e0e11;
    --sp-raise: #16161a;
    --sp-hover: #1e1e23;
    --sp-line: rgba(255, 255, 255, 0.07);
    --sp-line-strong: rgba(255, 255, 255, 0.13);
    --sp-text: #ececef;
    --sp-muted: #8e8e99;
    --sp-faint: #5a5a64;
    --sp-signal: #ff6a2b;
    --sp-signal-soft: rgba(255, 106, 43, 0.13);
    --sp-ok: #8fe3b0;
    --sp-danger: #ff6b6b;
    --sp-ease: cubic-bezier(0.2, 0.7, 0.2, 1);

    position: fixed;
    inset: 0;
    z-index: 60;
    background: var(--sp-bg);
    color: var(--sp-text);
    font-family: Geist, ui-sans-serif, system-ui, sans-serif;
    font-size: 13px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    color-scheme: dark;
}

/* Tailwind'in .hidden'ı stil sırasına göre ezilmesin. */
#streamingScreen .hidden,
.sp-toast.hidden {
    display: none !important;
}

body.streaming-preview-open {
    overflow: hidden;
}

.sp-shell {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    grid-template-rows: 52px minmax(0, 1fr);
    grid-template-areas:
        "top top"
        "rail stage";
    height: 100%;
    animation: sp-enter 0.5s var(--sp-ease) both;
}

/* ---------- Üst bar ---------- */

.sp-topbar {
    grid-area: top;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
    border-bottom: 1px solid var(--sp-line);
}

.sp-brand {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sp-mark {
    display: block;
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 6px;
}

.sp-crumb {
    flex: none;
    color: var(--sp-muted);
    font-weight: 500;
}

.sp-crumb-sep {
    flex: none;
    color: var(--sp-faint);
}

.sp-project {
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-meta {
    display: flex;
    flex: none;
    align-items: center;
    gap: 14px;
}

.sp-live {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 24px;
    padding: 0 10px 0 9px;
    border-radius: 6px;
    background: var(--sp-signal-soft);
    color: var(--sp-signal);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.sp-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: sp-blink 1.6s ease-in-out infinite;
}

.sp-live[data-state="done"] {
    background: rgba(143, 227, 176, 0.1);
    color: var(--sp-ok);
}

.sp-live[data-state="done"] .sp-live-dot {
    animation: none;
}

.sp-live[data-state="error"] {
    background: rgba(255, 107, 107, 0.12);
    color: var(--sp-danger);
}

.sp-elapsed {
    font-variant-numeric: tabular-nums;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}

.sp-model {
    padding-left: 14px;
    border-left: 1px solid var(--sp-line-strong);
    color: var(--sp-muted);
    font-size: 12px;
    white-space: nowrap;
}

.sp-model:empty {
    display: none;
}

.sp-topbar-end {
    display: flex;
    flex: 1 1 0;
    justify-content: flex-end;
}

.sp-actions {
    display: flex;
    gap: 8px;
    animation: sp-enter 0.4s var(--sp-ease) both;
}

.sp-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 7px;
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sp-btn svg {
    width: 14px;
    height: 14px;
}

.sp-btn-ghost {
    color: var(--sp-text);
    box-shadow: inset 0 0 0 1px var(--sp-line-strong);
}

.sp-btn-ghost:hover {
    background: var(--sp-raise);
}

.sp-btn-primary {
    background: var(--sp-text);
    color: var(--sp-bg);
}

.sp-btn-primary:hover {
    background: #ffffff;
}

/* ---------- Sol panel ---------- */

.sp-rail {
    grid-area: rail;
    overflow-y: auto;
    border-right: 1px solid var(--sp-line);
    background: var(--sp-panel);
    scrollbar-width: thin;
    scrollbar-color: var(--sp-hover) transparent;
}

.sp-block {
    padding: 18px 20px 20px;
    border-bottom: 1px solid var(--sp-line);
}

.sp-heading-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.sp-heading {
    margin: 0;
    color: var(--sp-muted);
    font-size: 12px;
    font-weight: 500;
}

.sp-count {
    color: var(--sp-faint);
    font-variant-numeric: tabular-nums;
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
}

.sp-placeholder {
    color: var(--sp-faint);
    font-size: 12px;
}

/* Üretim adımları: dikey zaman çizelgesi */

.sp-steps {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sp-step {
    position: relative;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) auto;
    column-gap: 12px;
    padding-bottom: 16px;
}

.sp-step:last-child {
    padding-bottom: 0;
}

.sp-step::before {
    content: "";
    position: absolute;
    top: 22px;
    bottom: 3px;
    left: 8.5px;
    width: 1px;
    background: var(--sp-line-strong);
    transition: background-color 0.4s ease;
}

.sp-step:last-child::before {
    display: none;
}

.sp-step[data-state="done"]::before {
    background: rgba(255, 255, 255, 0.3);
}

.sp-step-icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px var(--sp-line-strong);
}

.sp-step[data-state="active"] .sp-step-icon {
    box-shadow: inset 0 0 0 1px var(--sp-signal);
}

.sp-step[data-state="active"] .sp-step-icon::after {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--sp-signal);
    animation: sp-blink 1.6s ease-in-out infinite;
}

.sp-step[data-state="active"] .sp-step-icon::before {
    content: "";
    position: absolute;
    inset: -4px;
    border: 1px solid var(--sp-signal);
    border-radius: 50%;
    opacity: 0;
    animation: sp-ripple 2.2s var(--sp-ease) infinite;
}

.sp-step[data-state="done"] .sp-step-icon {
    background: var(--sp-text);
    box-shadow: none;
}

.sp-step[data-state="done"] .sp-step-icon::after {
    content: "";
    width: 8px;
    height: 4.5px;
    border-bottom: 1.5px solid var(--sp-bg);
    border-left: 1.5px solid var(--sp-bg);
    transform: translateY(-1px) rotate(-45deg);
}

.sp-step-body {
    min-width: 0;
}

.sp-step-title {
    display: block;
    color: var(--sp-faint);
    font-size: 13px;
    font-weight: 500;
    transition: color 0.3s ease;
}

.sp-step[data-state="active"] .sp-step-title,
.sp-step[data-state="done"] .sp-step-title {
    color: var(--sp-text);
}

.sp-step-note {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: var(--sp-faint);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-step[data-state="active"] .sp-step-note {
    color: var(--sp-muted);
}

.sp-step-time {
    padding-top: 2px;
    color: var(--sp-faint);
    font-variant-numeric: tabular-nums;
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
}

.sp-step[data-state="active"] .sp-step-time {
    color: var(--sp-signal);
}

.sp-step[data-state="done"] .sp-step-time {
    color: var(--sp-muted);
}

/* Tasarım kararları */

.sp-decision + .sp-decision {
    margin-top: 18px;
}

.sp-decision-label {
    display: block;
    margin-bottom: 8px;
    color: var(--sp-faint);
    font-size: 11.5px;
}

.sp-palette {
    display: flex;
    height: 46px;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 0 0 1px var(--sp-line);
}

.sp-palette.is-empty,
.sp-fonts.is-empty {
    align-items: center;
    height: 46px;
    padding: 0 12px;
    border-radius: 8px;
    background: repeating-linear-gradient(135deg, transparent 0 7px, rgba(255, 255, 255, 0.03) 7px 8px);
    box-shadow: inset 0 0 0 1px var(--sp-line);
}

.sp-fonts.is-empty {
    display: flex;
}

.sp-swatch {
    display: flex;
    flex: 1 1 0;
    align-items: flex-end;
    min-width: 0;
    padding: 6px 7px;
    font-size: 10px;
    font-weight: 500;
    animation: sp-swatch-in 0.55s var(--sp-ease) both;
}

.sp-swatch span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-fonts {
    display: grid;
    gap: 10px;
}

.sp-font {
    padding: 10px 12px 12px;
    border-radius: 8px;
    background: var(--sp-raise);
    animation: sp-enter 0.45s var(--sp-ease) both;
}

.sp-font-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    color: var(--sp-muted);
    font-size: 11.5px;
}

.sp-font-role {
    color: var(--sp-faint);
}

.sp-font-specimen {
    display: block;
    margin-top: 6px;
    overflow: hidden;
    font-size: 22px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-title-value {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}

.sp-title-value.is-empty {
    color: var(--sp-faint);
    font-size: 12px;
}

/* Bölümler */

.sp-sections {
    display: grid;
    gap: 1px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sp-section {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 26px;
    color: var(--sp-muted);
    font-size: 12.5px;
    animation: sp-row-in 0.4s var(--sp-ease) both;
}

.sp-section-index {
    width: 18px;
    color: var(--sp-faint);
    font-variant-numeric: tabular-nums;
}

.sp-section-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-section-state {
    color: var(--sp-signal);
    font-family: Geist, ui-sans-serif, system-ui, sans-serif;
    font-size: 11px;
}

.sp-section.is-active {
    color: var(--sp-text);
}

.sp-section.is-active .sp-section-index {
    color: var(--sp-signal);
}

.sp-block-last {
    border-bottom: 0;
}

.sp-heading-count {
    margin-left: 4px;
    color: var(--sp-faint);
    font-variant-numeric: tabular-nums;
}

.sp-note {
    margin: 0 20px 16px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12.5px;
    line-height: 1.5;
}

.sp-note-warn {
    background: rgba(255, 176, 64, 0.08);
    color: #f1c27d;
}

.sp-note-error {
    background: rgba(255, 107, 107, 0.1);
    color: #ff9d9d;
}

/* ---------- Önizleme sahnesi ---------- */

.sp-stage {
    grid-area: stage;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.sp-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 48px;
    padding: 0 16px;
    border-bottom: 1px solid var(--sp-line);
}

.sp-url {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: 520px;
    height: 30px;
    padding: 0 12px;
    border-radius: 7px;
    background: var(--sp-panel);
    box-shadow: inset 0 0 0 1px var(--sp-line);
    color: var(--sp-muted);
    font-variant-numeric: tabular-nums;
    font-size: 11.5px;
}

.sp-url svg {
    flex: none;
    width: 13px;
    height: 13px;
    color: var(--sp-faint);
}

.sp-url span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-toolbar-end {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.sp-devices {
    display: flex;
    padding: 2px;
    border-radius: 8px;
    background: var(--sp-panel);
    box-shadow: inset 0 0 0 1px var(--sp-line);
}

.sp-device-btn {
    display: grid;
    place-items: center;
    width: 30px;
    height: 26px;
    border-radius: 6px;
    color: var(--sp-faint);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sp-device-btn:hover {
    color: var(--sp-text);
}

.sp-device-btn[aria-pressed="true"] {
    background: var(--sp-hover);
    color: var(--sp-text);
}

.sp-device-btn svg {
    width: 15px;
    height: 15px;
}

.sp-follow {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 30px;
    padding: 0 11px;
    border-radius: 7px;
    box-shadow: inset 0 0 0 1px var(--sp-line);
    color: var(--sp-muted);
    font-size: 12px;
    white-space: nowrap;
    cursor: default;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sp-follow::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--sp-faint);
}

.sp-follow[data-state="building"]::before {
    background: var(--sp-signal);
    animation: sp-blink 1.6s ease-in-out infinite;
}

.sp-follow[data-state="final"] {
    color: var(--sp-text);
}

.sp-follow[data-state="final"]::before {
    background: var(--sp-ok);
}

/* Üretim sürerken önizlemenin üstündeki şeffaf kalkan: kaydırma ve tıklamalar iframe'e ulaşmaz. */
.sp-shield {
    position: absolute;
    inset: 0;
    z-index: 2;
    cursor: default;
}

.sp-shield-hint {
    position: absolute;
    bottom: 18px;
    left: 50%;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(14, 14, 17, 0.85);
    box-shadow: 0 0 0 1px var(--sp-line-strong), 0 12px 30px -12px rgba(0, 0, 0, 0.7);
    color: var(--sp-text);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, 6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.sp-shield:hover .sp-shield-hint {
    opacity: 1;
    transform: translate(-50%, 0);
}

.sp-canvas {
    display: flex;
    flex: 1 1 auto;
    justify-content: center;
    min-height: 0;
    padding: 20px;
    background: var(--sp-bg);
}

.sp-device {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 100%;
    transition: width 0.5s var(--sp-ease);
}

.sp-device[data-device="tablet"] {
    width: 834px;
}

.sp-device[data-device="mobile"] {
    width: 390px;
}

.sp-frame {
    position: relative;
    height: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.09), 0 28px 80px -28px rgba(0, 0, 0, 0.85);
}

.sp-iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #ffffff;
}

/* Bekleme ekranı: model düşünürken kendini çizen bir sayfa planı */

.sp-skeleton {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    background: #0d0d10;
    transition: opacity 0.35s ease;
}

.sp-blueprint {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.sp-bp {
    fill: none;
    stroke: rgba(255, 255, 255, 0.17);
    stroke-width: 1.25;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: sp-draw 7s cubic-bezier(0.65, 0, 0.35, 1) var(--d, 0s) infinite both;
}

.sp-bp.is-faint {
    stroke: rgba(255, 255, 255, 0.08);
}

.sp-bp.is-accent {
    stroke: var(--sp-signal);
}

.sp-scan {
    position: absolute;
    top: -22%;
    right: 0;
    left: 0;
    height: 22%;
    border-bottom: 1px solid rgba(255, 106, 43, 0.4);
    background: linear-gradient(to bottom, rgba(255, 106, 43, 0), rgba(255, 106, 43, 0.06));
    animation: sp-scan 4.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.sp-skeleton-caption {
    position: relative;
    z-index: 1;
    padding: 72px 32px 30px;
    background: linear-gradient(to top, #0d0d10 50%, rgba(13, 13, 16, 0));
}

.sp-skeleton-name {
    margin: 0;
    overflow: hidden;
    font-size: clamp(30px, 4.4vw, 60px);
    font-weight: 600;
    letter-spacing: -0.035em;
    line-height: 1.02;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-skeleton-brief {
    display: -webkit-box;
    max-width: 62ch;
    margin: 14px 0 0;
    overflow: hidden;
    color: var(--sp-muted);
    font-size: 13px;
    line-height: 1.6;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.sp-skeleton-brief:empty {
    display: none;
}

.sp-finalizing {
    display: none;
}

/* Üretim bitti, kaydedilen dosya yükleniyor: akan önizlemenin üstünü buzlu bir katman örter. */
.sp-skeleton.is-finalizing {
    align-items: center;
    justify-content: center;
    background: rgba(9, 9, 11, 0.5);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.sp-skeleton.is-finalizing > :not(.sp-finalizing) {
    display: none;
}

.sp-skeleton.is-finalizing .sp-finalizing {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    padding: 0 16px;
    border-radius: 10px;
    background: var(--sp-raise);
    box-shadow: 0 0 0 1px var(--sp-line-strong), 0 20px 50px -20px rgba(0, 0, 0, 0.8);
    font-size: 12.5px;
}

.sp-spinner {
    width: 14px;
    height: 14px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--sp-signal);
    border-radius: 50%;
    animation: sp-spin 0.8s linear infinite;
}

.sp-skeleton.is-fading {
    opacity: 0;
    pointer-events: none;
}

/* ---------- Bildirim ---------- */

.sp-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 70;
    max-width: 360px;
    padding: 11px 14px;
    border-radius: 9px;
    background: #16161a;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 20px 50px -20px rgba(0, 0, 0, 0.7);
    color: #ececef;
    font-size: 12.5px;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.sp-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Animasyonlar ---------- */

@keyframes sp-enter {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

@keyframes sp-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

@keyframes sp-ripple {
    0% { opacity: 0.6; transform: scale(0.7); }
    100% { opacity: 0; transform: scale(1.5); }
}

@keyframes sp-draw {
    0% { stroke-dashoffset: 1; opacity: 1; }
    35% { stroke-dashoffset: 0; opacity: 1; }
    82% { stroke-dashoffset: 0; opacity: 1; }
    100% { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes sp-scan {
    0% { top: -22%; }
    100% { top: 100%; }
}

@keyframes sp-spin {
    to { transform: rotate(360deg); }
}

@keyframes sp-row-in {
    from { opacity: 0; transform: translateX(-6px); }
}

@keyframes sp-swatch-in {
    from { transform: translateY(100%); }
}

/* ---------- Duyarlı yerleşim ---------- */

@media (max-width: 1180px) {
    .sp-shell {
        grid-template-columns: 300px minmax(0, 1fr);
    }
}

@media (max-width: 900px) {
    .sp-shell {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }

    .sp-topbar {
        position: sticky;
        top: 0;
        z-index: 5;
        flex: none;
        height: 52px;
        background: var(--sp-bg);
    }

    /* Mobilde önizleme önce gelir, üretim kaydı altında okunur. */
    .sp-stage {
        order: 1;
        flex: none;
        height: 68vh;
    }

    .sp-rail {
        order: 2;
        overflow: visible;
        border-top: 1px solid var(--sp-line);
        border-right: 0;
    }

    .sp-crumb,
    .sp-crumb-sep,
    .sp-model,
    .sp-devices {
        display: none;
    }

    .sp-canvas {
        padding: 12px;
    }
}

@media (max-width: 560px) {
    .sp-topbar:has(.sp-actions:not(.hidden)) .sp-meta,
    .sp-elapsed {
        display: none;
    }

    .sp-skeleton-caption {
        padding: 56px 20px 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sp-shell,
    .sp-actions,
    .sp-font,
    .sp-section,
    .sp-swatch,
    .sp-live-dot,
    .sp-follow::before,
    .sp-step-icon::before,
    .sp-step-icon::after {
        animation: none !important;
    }

    .sp-bp {
        animation: none;
        stroke-dashoffset: 0;
    }

    .sp-scan {
        display: none;
    }

    .sp-device {
        transition: none;
    }
}
