/* ── Wizard Layout System ── */
.wizard-layout {
    display: flex;
    gap: 4rem;
    align-items: flex-start;
}

.wizard-sidebar {
    flex: 0 0 22rem;
    position: sticky;
    top: 12rem;
}

.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.wizard-sidebar .sidebar-actions button {
    width: 100%;
}

.wizard-sidebar .button-wrap {
    margin-top: 0;
}

.wizard-content {
    flex: 1;
    min-width: 0;
}

.wizard-row {
    display: flex;
    gap: 2rem;
}

.wizard-row > * {
    flex: 1;
    min-width: 0;
}

@media screen and (max-width: 1024px) {
    .wizard-layout {
        flex-direction: column;
        gap: 2rem;
    }

    .wizard-sidebar {
        flex: none;
        width: 100%;
        position: static;
    }

    .wizard-content {
        width: 100%;
    }
}

@media screen and (max-width: 768px) {
    .wizard-row {
        flex-direction: column;
    }
}

/* ── Step Tracker ── */

/* --- Base --- */
.step-tracker h3 {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.2rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--black-light);
    margin: 0 0 2rem 0;
    padding-left: 0.5rem;
    text-align: left;
}

.step-tracker h3 ~ h3 {
    margin-top: 3rem;
}

.step-tracker-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.step-tracker-item {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding: 1.2rem 0;
    position: relative;
}

.step-tracker-item:not(:last-child)::after {
    content: "";
    position: absolute;
    left: calc(1.4rem - 1px);
    top: 4rem;
    width: 2px;
    height: calc(100% - 1.6rem);
    background: var(--white-dark);
}

.step-tracker-item.current:not(:last-child)::after,
.step-tracker-item.completed:not(:last-child)::after {
    background: var(--brand);
}

.step-tracker-circle {
    width: 2.8rem;
    height: 2.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: 600;
    background: var(--white);
    color: var(--black-light);
    border: 2px solid var(--white-dark);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    transition: all 0.3s;
}

.step-tracker-item.current .step-tracker-circle,
.step-tracker-item.completed .step-tracker-circle {
    background: var(--brand);
    color: var(--white);
    border-color: var(--brand);
}

.step-tracker-item.current .step-tracker-circle {
    animation: stepPulse 1.8s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(70, 81, 148, 0.5);
}

@keyframes stepPulse {
    0% { box-shadow: 0 0 0 0 rgba(70, 81, 148, 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(70, 81, 148, 0); }
    100% { box-shadow: 0 0 0 0 rgba(70, 81, 148, 0); }
}

.step-tracker-label {
    font-size: 1.4rem;
    color: var(--black-light);
    transition: color 0.3s;
}

.step-tracker-item.current .step-tracker-label {
    color: var(--brand);
    font-weight: 500;
}

.step-tracker-item.completed .step-tracker-label {
    color: var(--brand);
}

/* --- Terminated state (cancelled / expired / failed) --- */
.step-tracker.step-tracker-terminated .step-tracker-item.current .step-tracker-circle,
.step-tracker.step-tracker-terminated .step-tracker-item.completed .step-tracker-circle {
    background: var(--danger);
    border-color: var(--danger);
}
.step-tracker.step-tracker-terminated .step-tracker-item.current .step-tracker-circle {
    animation: stepPulseRed 1.8s ease-in-out infinite;
}
@keyframes stepPulseRed {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    70% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}
.step-tracker.step-tracker-terminated .step-tracker-item.current .step-tracker-label,
.step-tracker.step-tracker-terminated .step-tracker-item.completed .step-tracker-label {
    color: var(--danger);
}
.step-tracker.step-tracker-terminated .step-tracker-item.current:not(:last-child)::after,
.step-tracker.step-tracker-terminated .step-tracker-item.completed:not(:last-child)::after {
    background: var(--danger);
}

.step-tracker-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    font-size: 1rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: var(--danger);
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-radius: 0.4rem;
    vertical-align: middle;
    margin-left: 0.5rem;
}

/* --- Variant: vertical (default desktop sidebar) — horizontal on mobile --- */
@media screen and (max-width: 1024px) {
    .step-tracker:not(.step-tracker-compact) h3 {
        display: none;
    }

    .step-tracker:not(.step-tracker-compact) .step-tracker-list {
        display: flex;
        overflow-x: auto;
        gap: 0;
        padding-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
    }

    .step-tracker:not(.step-tracker-compact) .step-tracker-list::-webkit-scrollbar {
        display: none;
    }

    .step-tracker:not(.step-tracker-compact) .step-tracker-item {
        flex-direction: column;
        flex: 0 0 7rem;
        padding: 0 0.6rem;
    }

    .step-tracker:not(.step-tracker-compact) .step-tracker-item:not(:last-child)::after {
        left: calc(50% + 1.4rem);
        top: calc(1.4rem - 1px);
        width: calc(100% - 0.8rem);
        height: 2px;
        transform: translateY(-50%);
    }

    .step-tracker:not(.step-tracker-compact) .step-tracker-label {
        font-size: 1.1rem;
        text-align: center;
        margin-top: 0.5rem;
        white-space: normal;
        word-wrap: break-word;
        line-height: 1.3;
    }
}

@media screen and (max-width: 768px) {
    .step-tracker:not(.step-tracker-compact) {
        margin-bottom: 1rem;
        overflow: visible;
    }

    .step-tracker:not(.step-tracker-compact) .step-tracker-list {
        justify-content: center;
        padding-top: 1rem;  /* room for pulse effect */
    }

    .step-tracker:not(.step-tracker-compact) .step-tracker-item {
        flex: 0 0 6rem;
        padding: 0 0.4rem;
    }

    .step-tracker:not(.step-tracker-compact) .step-tracker-item:not(:last-child)::after {
        top: 1.2rem;  /* circle center: 2.4rem / 2 */
    }

    .step-tracker:not(.step-tracker-compact) .step-tracker-circle {
        width: 2.4rem;
        height: 2.4rem;
        font-size: 1.1rem;
    }

    .step-tracker:not(.step-tracker-compact) .step-tracker-label {
        font-size: 0.95rem;
    }
}

/* --- Variant: compact (popup stepper) --- */
.step-tracker-compact .step-tracker-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.step-tracker-compact .step-tracker-item {
    gap: 1rem;
    padding: 0.6rem 0;
}

.step-tracker-compact .step-tracker-item:not(:last-child)::after {
    left: calc(1.1rem - 1px);
    top: 2.8rem;
    height: auto;
    bottom: -0.6rem;
}

.step-tracker-compact .step-tracker-circle {
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.1rem;
}

.step-tracker-compact .step-tracker-label {
    font-size: 1.3rem;
}

.step-tracker-compact .step-tracker-circle i {
    font-size: 1rem;
}

/* --- Variant: nav (wizard step navigation) --- */
.step-tracker-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--white-dark);
}

.step-tracker-nav .button-secondary {
    padding: 1.2rem 3rem;
    border-radius: 0.6rem;
    font-size: 1.5rem;
    font-weight: 500;
    background: var(--white);
    color: var(--black);
    border: 1px solid var(--white-dark);
    cursor: pointer;
    transition: all 0.2s;
}

.step-tracker-nav .button-secondary:hover {
    background: var(--white-light);
}

.step-tracker-nav .button-primary {
    padding: 1.2rem 4rem;
    border-radius: 0.6rem;
    font-size: 1.5rem;
    font-weight: 500;
    background: var(--brand);
    color: var(--white);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.step-tracker-nav .button-primary:hover {
    background: var(--brand-dark);
}

/* --- Variant: active (wizard card show/hide) --- */
.request-cards .request-card.step-tracker-active {
    display: block;
    animation: stepTrackerFadeIn 0.3s ease-out;
}

@keyframes stepTrackerFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media screen and (max-width: 768px) {
    .wizard-content {
        overflow: hidden;
    }

    .step-tracker-nav {
        margin-top: 2rem;
        padding-top: 1.5rem;
    }

    .step-tracker-nav .button-secondary,
    .step-tracker-nav .button-primary {
        padding: 1rem 0;
        font-size: 1.4rem;
        flex: 1;
        text-align: center;
        min-width: 0;
    }
}
