/* =========================================================
   style_navigation.css — Section top bar + wizard layout
   Replaces the old vertical sidebar and horizontal nav.
   Driven by sections_registry.php → topbar tabs in form1.php.
   ========================================================= */


/* ─────────────────────────────────────────────
   Top bar container
   Always visible, sticky below the titlebar.
   ───────────────────────────────────────────── */
.section-topbar {
    position: sticky;
    top: var(--titlebar-height, 0px);
    /* z-index 149: above AI panel (101) but the two never share horizontal space
       on desktop — topbar stops before the AI panel begins (see right below).
       No z-index conflict possible. */
    z-index: 149;

    /* AI panel is hidden on mobile — topbar reclaims full width */
    .section-topbar {
        width: 100%;
    }

    background-color: var(--element_contrast, #fff);
    box-shadow: 0 2px 5px var(--element_shadow_dark, rgba(0,0,0,0.08));
    padding: 0 8px;

    /* Ensure it doesn't collapse */
    min-height: 46px;
}

/* ─────────────────────────────────────────────
   Tabs row (scrollable)
   ───────────────────────────────────────────── */
.topbar-tabs {
    display: flex;
    align-items: stretch;
    gap: 2px;

    /* Horizontal scroll on overflow (mobile) */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;

    /* Hide scrollbar but keep scrollability */
    scrollbar-width: none;          /* Firefox */
}

.topbar-tabs::-webkit-scrollbar {
    display: none;                  /* Chrome / Safari */
}


/* ─────────────────────────────────────────────
   Individual tab
   ───────────────────────────────────────────── */
.topbar-tab {
    display: inline-flex;
    align-items: center;
    gap: 5px;

    padding: 8px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;

    font-family: var(--font-main, sans-serif);
    font-size: var(--fs-sm, 0.9rem);
    font-weight: var(--fw-regular, 400);
    color: var(--Default_Text, #555);

    /* Bottom accent line (invisible by default) */
    border-bottom: 3px solid transparent;

    transition: background-color 0.15s ease,
                border-color 0.15s ease,
                color 0.15s ease;
}

/* Hover */
.topbar-tab:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

/* Active (current wizard step) */
.topbar-tab.active {
    font-weight: var(--fw-medium, 500);
    color: var(--Default_Text, #1a1a2e);
    background-color: var(--tab-color, transparent);
    border-bottom-color: var(--tab-color, var(--navy, #1a1a2e));
}

/* Keyboard focus */
.topbar-tab:focus-visible {
    outline: 2px solid rgba(235, 170, 63, 0.85);
    outline-offset: -2px;
    border-radius: 4px;
}


/* ─────────────────────────────────────────────
   Tab inner elements
   ───────────────────────────────────────────── */
.topbar-tab-icon {
    font-size: 1.05em;
    line-height: 1;
}

.topbar-tab-label {
    line-height: 1;
}


/* ─────────────────────────────────────────────
   Progress badge (% pill inside each tab)

   Color states set by JS:
     .topbar-progress-badge--empty    → neutral grey   (0%)
     .topbar-progress-badge--partial  → amber          (1-99%)
     .topbar-progress-badge--complete → green + ✓      (100%)
   Default state (no modifier) is --empty.
   ───────────────────────────────────────────── */
.topbar-progress-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 28px;
    padding: 1px 6px;
    border-radius: 999px;

    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.4;

    /* Default (empty / 0%) */
    background-color: rgba(0, 0, 0, 0.08);
    color: #888;

    transition: background-color 0.25s ease, color 0.25s ease;
}

/* In-progress (1–99%) — set by JS */
.topbar-progress-badge--partial {
    background-color: #fdf0d5;
    color: #a67c00;
}

/* Complete (100%) — set by JS */
.topbar-progress-badge--complete {
    background-color: #d4edda;
    color: #2e7d32;
}

/* Non-tracked sections (e.g. Submit) — no badge visible */
.topbar-progress-badge--no-track {
    display: none;
}


/* ─────────────────────────────────────────────
   Wizard sections
   Only the .active section is visible.
   ───────────────────────────────────────────── */
.wizard-section {
    display: none;
    /* Reserve space for fixed titlebar + sticky topbar when scrollIntoView fires */
    scroll-margin-top: calc(var(--chat-top-offset, 120px) + var(--medium-padding, 16px));
}

.wizard-section.active {
    display: block;
}

/* Fade-in animation on section switch */
.wizard-section.wizard-fade-in {
    animation: wizardFadeIn 200ms ease;
}

@keyframes wizardFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}


/* ─────────────────────────────────────────────
   Prev / Next buttons at bottom of each section
   ───────────────────────────────────────────── */
.wizard-nav-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--medium-padding, 16px) 0;
    margin-top: var(--medium-padding, 16px);
}

/* Previous — ghost / outline style */
.wizard-prev {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 20px;
    border: 1px solid var(--navy, #1a1a2e);
    border-radius: 8px;
    background: transparent;
    color: var(--navy, #1a1a2e);
    font-family: var(--font-main, sans-serif);
    font-size: var(--fs-sm, 0.9rem);
    font-weight: var(--fw-medium, 500);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.wizard-prev:hover {
    background-color: var(--navy, #1a1a2e);
    color: #fff;
}

/* Next — filled / primary style */
.wizard-next {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    background-color: var(--navy, #1a1a2e);
    color: #fff;
    font-family: var(--font-main, sans-serif);
    font-size: var(--fs-sm, 0.9rem);
    font-weight: var(--fw-medium, 500);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: background-color 0.15s ease;
}

.wizard-next:hover {
    background-color: var(--navy_over, #2c2c54);
}

/* Focus for both */
.wizard-prev:focus-visible,
.wizard-next:focus-visible {
    outline: 2px solid rgba(235, 170, 63, 0.85);
    outline-offset: 3px;
}


/* ─────────────────────────────────────────────
   Responsive — small screens
   Tabs scroll horizontally by default, so we
   only need to compact the tabs below 768px.
   ───────────────────────────────────────────── */
@media (max-width: 768px) {
    /* AI panel is hidden on mobile — topbar reclaims full width */
    .section-topbar {
        width: 100%;
    }

    .topbar-tab {
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    /* Hide labels, keep icon + badge */
    .topbar-tab-label {
        display: none;
    }

    .wizard-nav-buttons {
        padding: var(--small-padding, 8px) 0;
    }

    .wizard-prev,
    .wizard-next {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
}


/* ─────────────────────────────────────────────
   Reduced motion
   ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .wizard-section.wizard-fade-in {
        animation: none;
    }

    .topbar-tab,
    .topbar-progress-badge {
        transition: none;
    }
}