/* Cnn2rtl — layout shell, header, stepper, section structure */

html {
    height: 100%;
}

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

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100dvh;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: var(--text-base);
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition), color var(--transition);
    /* App: whole header ~70% of home; stepper indicators/labels match home */
    --header-shell-min-height: 3.57rem;
    --header-shell-padding-block: 0.455rem;
    --header-shell-padding-inline: 1.75rem;
    --header-shell-padding-bottom: 0;
    --header-logo-height: 3.955rem;
    --header-logo-max-width: 14rem;
    --header-subtitle-size: var(--text-xs);
    --header-subtitle-max-width: 420px;
    --stepper-padding-block: 0.3rem;
    --stepper-padding-inline: 1.75rem;
    --stepper-indicator-size: 2.15rem;
    --stepper-indicator-font: 0.875rem;
    --stepper-label-size: 0.875rem;
    --stepper-step-gap: 0.6rem;
    --stepper-connector-height: 3px;
    --stepper-max-width: min(980px, 100%);
    --app-stepper-margin-top: -1.35rem;
}

body:not(.landing-mode) .header-brand {
    gap: 0.04rem;
}

body:not(.landing-mode) .workflow-stepper {
    margin-top: var(--app-stepper-margin-top);
}

body.landing-mode {
    --landing-footer-offset: 0;
    padding-bottom: 0;
    --header-shell-min-height: 5.1rem;
    --header-shell-padding-block: 0.65rem;
    --header-shell-padding-inline: 1.75rem;
    --header-shell-padding-bottom: 0;
    --header-logo-height: 5.65rem;
    --header-logo-max-width: 20rem;
    --header-subtitle-size: var(--text-xs);
    --header-subtitle-max-width: 420px;
    --stepper-padding-block: 0.45rem;
    --stepper-padding-inline: 1.75rem;
    --stepper-indicator-size: 2.15rem;
    --stepper-indicator-font: 0.875rem;
    --stepper-label-size: 0.875rem;
    --stepper-step-gap: 0.6rem;
    --stepper-connector-height: 3px;
    --stepper-max-width: min(980px, 100%);
    --landing-stepper-offset: 0;
    --landing-stepper-margin: 0;
    --header-shell-padding-bottom: 0.35rem;
}

body.landing-mode .header-content {
    align-items: center;
}

body.landing-mode .header-brand {
    gap: 0.08rem;
}

body.landing-mode .workflow-stepper {
    transform: translateY(var(--landing-stepper-offset));
    margin-top: 0.15rem;
    margin-bottom: var(--landing-stepper-margin);
    border-bottom-color: transparent;
}

/* ——— Header ——— */
.app-header {
    position: relative;
    width: 100%;
    flex-shrink: 0;
    overflow: hidden;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    background: #060b14;
    color: var(--header-text);
    padding: var(--header-shell-padding-block) var(--header-shell-padding-inline) 0;
    border-bottom: none;
    transition: padding var(--landing-duration) var(--landing-ease);
    box-shadow: 0 4px 24px rgba(2, 6, 23, 0.28);
    --aurora-x: 0;
    --aurora-y: 0;
}

.app-header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    z-index: 2;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(14, 165, 233, 0.85) 22%,
        rgba(139, 92, 246, 0.85) 50%,
        rgba(16, 185, 129, 0.85) 78%,
        transparent 100%
    );
    background-size: 200% 100%;
    opacity: 0.9;
    pointer-events: none;
    animation: headerBorderShimmer 6s linear infinite;
}

.header-aurora {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.header-aurora::before {
    content: '';
    position: absolute;
    z-index: 0;
    inset: -55% -35%;
    background:
        radial-gradient(circle at 12% 55%, rgba(14, 165, 233, 0.48) 0%, transparent 54%),
        radial-gradient(circle at 38% 45%, rgba(59, 130, 246, 0.38) 0%, transparent 50%),
        radial-gradient(circle at 58% 58%, rgba(139, 92, 246, 0.42) 0%, transparent 48%),
        radial-gradient(circle at 78% 42%, rgba(236, 72, 153, 0.22) 0%, transparent 44%),
        radial-gradient(circle at 92% 52%, rgba(16, 185, 129, 0.4) 0%, transparent 46%);
    animation:
        headerAuroraShift 11s ease-in-out infinite alternate,
        headerAuroraHue 16s ease-in-out infinite alternate;
}

.header-aurora::after {
    content: '';
    position: absolute;
    z-index: 1;
    inset: -30% -80%;
    background: linear-gradient(
        102deg,
        transparent 0%,
        rgba(14, 165, 233, 0.18) 12%,
        rgba(59, 130, 246, 0.32) 24%,
        rgba(139, 92, 246, 0.38) 38%,
        rgba(192, 132, 252, 0.28) 50%,
        rgba(16, 185, 129, 0.34) 64%,
        rgba(45, 212, 191, 0.26) 76%,
        rgba(14, 165, 233, 0.22) 88%,
        transparent 100%
    );
    background-size: 220% 100%;
    filter: blur(34px);
    mix-blend-mode: screen;
    opacity: 0.82;
    animation: headerAuroraRipple 9s ease-in-out infinite;
}

.header-aurora-parallax {
    position: absolute;
    z-index: 2;
    inset: 0;
    will-change: transform;
    transform: translate3d(calc(var(--aurora-x) * 52px), calc(var(--aurora-y) * 26px), 0);
}

.header-aurora-track {
    position: absolute;
    display: block;
    will-change: transform;
    top: 50%;
}

.header-aurora-orb {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    filter: blur(42px);
}

.header-aurora-track-a {
    width: 240px;
    height: 220px;
    left: -2%;
    margin-top: -110px;
    animation: headerOrbDriftA 13s ease-in-out infinite;
}

.header-aurora-track-a .header-aurora-orb {
    background: rgba(14, 165, 233, 0.85);
}

.header-aurora-track-b {
    width: 220px;
    height: 200px;
    left: 34%;
    margin-top: -100px;
    animation: headerOrbDriftB 10s ease-in-out infinite;
}

.header-aurora-track-b .header-aurora-orb {
    background: rgba(139, 92, 246, 0.78);
}

.header-aurora-track-c {
    width: 230px;
    height: 215px;
    right: -2%;
    left: auto;
    margin-top: -108px;
    animation: headerOrbDriftC 14s ease-in-out infinite;
}

.header-aurora-track-c .header-aurora-orb {
    background: rgba(16, 185, 129, 0.75);
}

.header-aurora-veil {
    position: absolute;
    z-index: 3;
    inset: 0;
    background:
        linear-gradient(115deg,
            rgba(6, 11, 20, 0.3) 0%,
            rgba(8, 15, 30, 0.06) 42%,
            rgba(6, 11, 20, 0.26) 100%);
}

[data-theme="dark"] .header-aurora-veil {
    background:
        linear-gradient(115deg,
            rgba(2, 6, 23, 0.38) 0%,
            rgba(15, 23, 42, 0.1) 42%,
            rgba(2, 6, 23, 0.34) 100%);
}

.header-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    max-width: 100%;
    min-height: var(--header-shell-min-height);
    padding-bottom: var(--header-shell-padding-bottom);
    transition:
        min-height var(--landing-duration) var(--landing-ease),
        padding-bottom var(--landing-duration) var(--landing-ease);
}

.header-left {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1 1 auto;
}

.header-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    max-width: 100%;
    width: auto;
    box-shadow: none;
    transition: gap var(--landing-duration) var(--landing-ease);
}

.header-brand:hover {
    transform: none;
    box-shadow: none;
}

.header-brand:hover .header-brand-logo {
    filter: brightness(1.1) saturate(1.06);
    transform: translateY(-1px);
}

.header-brand-logo {
    display: block;
    width: auto;
    height: var(--header-logo-height);
    max-width: min(100%, var(--header-logo-max-width));
    object-fit: contain;
    object-position: left center;
    mix-blend-mode: lighten;
    transition:
        height var(--landing-duration) var(--landing-ease),
        max-width var(--landing-duration) var(--landing-ease),
        filter 0.2s ease,
        transform 0.2s ease;
}

.header-brand-subtitle {
    font-size: var(--header-subtitle-size);
    font-weight: 400;
    line-height: 1.25;
    color: rgba(226, 232, 240, 0.82);
    max-width: var(--header-subtitle-max-width);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition:
        font-size var(--landing-duration) var(--landing-ease),
        max-width var(--landing-duration) var(--landing-ease);
}

.header-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.625rem;
    flex-shrink: 0;
}

.header-toolbar {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}

.header-toolbar-divider {
    width: 1px;
    height: 26px;
    margin: 0 0.1rem;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(255, 255, 255, 0.34) 50%,
        transparent 100%
    );
    flex-shrink: 0;
    opacity: 0.72;
}

.header-tool-glass {
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition:
        background var(--transition),
        border-color var(--transition),
        box-shadow var(--transition),
        transform var(--transition-fast),
        color var(--transition);
}

.header-tool-glass:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(186, 230, 253, 0.45);
    box-shadow:
        0 0 18px rgba(14, 165, 233, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Theme toggle */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    color: var(--header-text);
    cursor: pointer;
}

.theme-toggle:hover {
    transform: none;
}

.theme-toggle svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    fill: currentColor;
    pointer-events: none;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}

/* Tema claro → luna; tema oscuro → sol */
[data-theme="light"] .theme-toggle .icon-moon,
:root:not([data-theme]) .theme-toggle .icon-moon {
    display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}

/* ——— Workflow stepper (inside dark header) ——— */
.workflow-stepper {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    width: 100%;
    margin-bottom: 0;
    background: transparent;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    padding: var(--stepper-padding-block) var(--stepper-padding-inline);
    transform: translateY(0);
    transform-origin: center top;
    transition:
        padding var(--landing-duration) var(--landing-ease),
        transform var(--landing-duration) var(--landing-ease),
        margin-top var(--landing-duration) var(--landing-ease),
        margin-bottom var(--landing-duration) var(--landing-ease),
        border-bottom-color var(--landing-duration) var(--landing-ease);
}

body.landing-exiting .workflow-stepper {
    will-change: transform, margin-top, margin-bottom;
}

.workflow-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    max-width: var(--stepper-max-width);
    margin: 0 auto;
    list-style: none;
    transition: max-width var(--landing-duration) var(--landing-ease);
}

.workflow-step {
    display: flex;
    align-items: center;
    gap: var(--stepper-step-gap);
    flex: 0 1 auto;
    min-width: min-content;
    position: relative;
    transition: gap var(--landing-duration) var(--landing-ease);
}

.workflow-step:not(:last-child)::after {
    content: '';
    flex: 1 1 1.25rem;
    width: 1.25rem;
    min-width: 0.65rem;
    max-width: 2.25rem;
    height: var(--stepper-connector-height);
    background: rgba(148, 163, 184, 0.35);
    margin: 0 0.3rem;
    border-radius: var(--radius-full);
    transition: height var(--landing-duration) var(--landing-ease);
}

.workflow-step.is-complete:not(:last-child)::after,
.workflow-step.is-active:not(:last-child)::after {
    background: var(--success);
}

.workflow-step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--stepper-indicator-size);
    height: var(--stepper-indicator-size);
    border-radius: var(--radius-full);
    font-size: var(--stepper-indicator-font);
    font-weight: 600;
    flex-shrink: 0;
    background: rgba(15, 23, 42, 0.55);
    color: rgba(226, 232, 240, 0.88);
    border: 2px solid rgba(148, 163, 184, 0.38);
    transition:
        width var(--landing-duration) var(--landing-ease),
        height var(--landing-duration) var(--landing-ease),
        font-size var(--landing-duration) var(--landing-ease),
        background-color var(--transition-slow),
        color var(--transition-slow),
        border-color var(--transition-slow);
}

.workflow-step.is-active .workflow-step-indicator {
    background: rgba(14, 165, 233, 0.22);
    color: #e0f2fe;
    border-color: rgba(56, 189, 248, 0.72);
}

.workflow-step.is-complete .workflow-step-indicator {
    background: rgba(16, 185, 129, 0.2);
    color: #a7f3d0;
    border-color: rgba(52, 211, 153, 0.65);
}

.workflow-step-label {
    font-size: var(--stepper-label-size);
    font-weight: 500;
    color: rgba(226, 232, 240, 0.78);
    white-space: nowrap;
    overflow: visible;
    text-overflow: unset;
    flex: 0 0 auto;
    transition:
        font-size var(--landing-duration) var(--landing-ease),
        color var(--transition);
}

.workflow-step.is-active .workflow-step-label {
    color: #f8fafc;
    font-weight: 600;
}

.workflow-step.is-complete .workflow-step-label {
    color: #bbf7d0;
}

.workflow-step-btn {
    display: flex;
    align-items: center;
    gap: inherit;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-align: left;
    appearance: none;
    -webkit-appearance: none;
    box-shadow: none;
}

.workflow-step-btn:hover .workflow-step-label,
.workflow-step-btn:focus-visible .workflow-step-label {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.workflow-step-btn:focus-visible {
    outline: none;
}

.workflow-step--terminal {
    cursor: default;
}

/* ——— Three-column shell ——— */
.container {
    display: flex;
    flex: 1 0 auto;
    align-items: stretch;
    min-height: var(--shell-height);
    width: 100%;
    padding: 0.5rem;
    gap: 0.5rem;
}

.sidebar-left,
.sidebar-right {
    flex: 0 0 22%;
    min-width: 220px;
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    align-self: stretch;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border);
}

.sidebar-left {
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.sidebar-right > *:not(#processLog) {
    flex-shrink: 0;
}

.main-content {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.sidebar-left,
.main-content,
.sidebar-right {
    transition:
        opacity 0.32s var(--ui-ease),
        filter 0.32s var(--ui-ease);
}

.container.is-workflow-nav-fading .sidebar-left,
.container.is-workflow-nav-fading .main-content,
.container.is-workflow-nav-fading .sidebar-right {
    opacity: 0;
    pointer-events: none;
}

.sidebar-left.is-workflow-locked,
.main-content.is-workflow-locked,
.sidebar-right.is-workflow-locked {
    opacity: 0.42;
    filter: grayscale(0.45) saturate(0.65);
    pointer-events: none;
    user-select: none;
}

.sidebar-left.is-workflow-locked h2,
.main-content.is-workflow-locked h2,
.sidebar-right.is-workflow-locked h2,
.sidebar-left.is-workflow-locked h3,
.main-content.is-workflow-locked h3,
.sidebar-right.is-workflow-locked h3,
.sidebar-left.is-workflow-locked h4,
.main-content.is-workflow-locked h4,
.sidebar-right.is-workflow-locked h4 {
    color: var(--text-muted, #94a3b8);
}

.sidebar-left.is-workflow-active,
.main-content.is-workflow-active,
.sidebar-right.is-workflow-active {
    opacity: 1;
    filter: none;
    box-shadow: var(--shadow-sm),
        0 0 0 1px color-mix(in srgb, var(--primary, #3b82f6) 16%, transparent);
}

.sidebar-left h2,
.main-content h2,
.sidebar-right h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-subtle);
    letter-spacing: -0.01em;
}

/* ——— Footer ——— */
footer,
.footer-compact {
    width: 100%;
    flex-shrink: 0;
    margin-top: auto;
    background: var(--footer-bg);
    color: var(--footer-text);
    padding: 0.875rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-top: 1px solid var(--border);
    font-size: var(--text-sm);
    line-height: 1.5;
    opacity: 1;
    transition: opacity 0.38s var(--landing-ease);
}

body.footer-dormant .footer-compact {
    opacity: 0;
    pointer-events: none;
}

body.landing-mode .footer-compact {
    position: relative;
    z-index: 1;
    margin-top: auto;
}

footer a {
    color: var(--footer-link);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.footer-compact p {
    margin: 0.15rem 0;
    width: 100%;
    max-width: 52rem;
    text-align: center;
}

.footer-disclaimer {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 0.35rem !important;
}

/* ——— Responsive ——— */
@media (max-width: 1100px) {
    .container {
        flex-wrap: wrap;
        min-height: auto;
    }

    .sidebar-left,
    .sidebar-right {
        flex: 1 1 100%;
        min-width: unset;
    }

    .main-content {
        flex: 1 1 100%;
    }

}

@media (max-width: 1280px) {
    .header-brand-subtitle {
        display: none;
    }

    body {
        --app-stepper-margin-top: 0;
    }

    body:not(.landing-mode) .workflow-stepper,
    body.landing-mode .workflow-stepper {
        margin-top: 0;
    }

    body.landing-mode {
        --header-shell-padding-bottom: 0.25rem;
    }
}

@media (max-width: 900px) {
    body:not(.landing-mode) .workflow-stepper {
        margin-top: 0;
    }

    body {
        --app-stepper-margin-top: 0;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    body {
        --header-shell-min-height: 3.25rem;
        --header-shell-padding-block: 0.385rem;
        --header-shell-padding-inline: 1.25rem;
        --header-shell-padding-bottom: 0;
        --header-logo-height: 3.395rem;
        --header-logo-max-width: 12.25rem;
        --header-subtitle-size: var(--text-xs);
        --header-subtitle-max-width: 420px;
        --stepper-padding-block: 0.25rem;
        --stepper-padding-inline: 1.25rem;
        --stepper-indicator-size: 1.95rem;
        --stepper-indicator-font: 0.75rem;
        --stepper-label-size: 0.75rem;
        --stepper-max-width: 100%;
        --app-stepper-margin-top: -0.85rem;
    }

    body:not(.landing-mode) .workflow-step-label {
        display: none;
    }

    body.landing-mode {
        --landing-footer-offset: 0;
        --header-shell-min-height: 4.65rem;
        --header-shell-padding-block: 0.55rem;
        --header-shell-padding-inline: 1.25rem;
        --header-shell-padding-bottom: 0;
        --header-logo-height: 4.85rem;
        --header-logo-max-width: 17.5rem;
        --stepper-padding-block: 0.35rem;
        --stepper-padding-inline: 1.25rem;
        --stepper-indicator-size: 1.95rem;
        --stepper-indicator-font: 0.75rem;
        --stepper-label-size: 0.75rem;
        --stepper-max-width: 100%;
        --landing-stepper-offset: 0;
        --landing-stepper-margin: 0;
        --header-shell-padding-bottom: 0.2rem;
    }

    body.landing-mode .header-content {
        flex-direction: row;
        align-items: center;
        gap: 0.65rem;
    }

    body.landing-mode .workflow-step-label {
        display: none;
    }

    .header-brand-subtitle {
        max-width: 100%;
    }

    .header-right {
        justify-content: center;
    }

    .container {
        flex-direction: column;
        padding: 0.5rem;
    }

    .sidebar-left,
    .main-content,
    .sidebar-right {
        flex: 1 1 100%;
        border-radius: var(--radius-md);
    }
}
