/* static/css/dhaara-controls.css
 *
 * Shared navigation controls for every DHAARA tool page (loaded by base.html).
 *
 *   .dh-seg     Segmented control - pick one of a few options (data source,
 *               extraction mode, tool). Works with Bootstrap tab/pill buttons
 *               (.nav-link), radio groups (.btn-check + .dh-seg-btn) and plain
 *               toggle buttons (.btn with .active).  .dh-seg-sm = compact.
 *               Optional two-line label:  <span class="dh-seg-text">Label
 *               <span class="dh-seg-meta">caption</span></span>
 *   .dh-tabs    Tab bar for result panels (Bootstrap .nav-link tabs) with a
 *               gradient indicator. Counters: <span class="badge">3</span>
 *
 * Palette: DHAARA ocean blue (#006994) deepened to #0b4a6f for the active
 * chip, cyan (#06b6d4) and indigo (#6366f1) from the hero gradient for the
 * tab indicator, on cool slate neutrals.
 */

:root {
    --dh-ink: #0f172a;
    --dh-text: #334155;
    --dh-muted: #64748b;
    --dh-line: #e2e8f0;
    --dh-track: #edf2f7;
    --dh-track-border: #dbe4ec;
    --dh-ocean: #006994;
    --dh-ocean-deep: #0b4a6f;
    --dh-cyan: #06b6d4;
    --dh-indigo: #6366f1;
    --dh-grad-active: linear-gradient(135deg, #0b4a6f 0%, #006994 48%, #0891b2 100%);
    --dh-grad-line: linear-gradient(90deg, #006994 0%, #06b6d4 55%, #6366f1 100%);
    --dh-glow: 0 6px 16px -6px rgba(0, 105, 148, 0.55), 0 2px 4px -2px rgba(11, 74, 111, 0.35);
    --dh-mono: ui-monospace, SFMono-Regular, 'Cascadia Mono', Consolas, 'Liberation Mono', monospace;
}

/* ══════════════════════════════════════════════════════════════════════
   Segmented control
   ══════════════════════════════════════════════════════════════════════ */
.dh-seg {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 4px;
    width: 100%;
    padding: 4px;
    margin-left: 0;
    list-style: none;
    background: var(--dh-track);
    border: 1px solid var(--dh-track-border);
    border-radius: 14px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
    overflow-x: auto;
    scrollbar-width: none;
}
.dh-seg::-webkit-scrollbar { display: none; }
.dh-seg > li,
.dh-seg > .nav-item {
    flex: 1 1 0;
    min-width: max-content;
    margin: 0 !important;
}

.dh-seg .nav-link,
.dh-seg .dh-seg-btn,
.dh-seg > .btn {
    flex: 1 1 0;
    width: 100%;
    min-width: max-content;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.55rem 0.9rem !important;
    border: 0 !important;
    border-radius: 10px !important;
    background: transparent;
    color: var(--dh-text) !important;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: 0.005em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.2s ease, transform 0.12s ease;
}
/* Bootstrap .btn-group overlaps its buttons by 1px - not inside a segmented control */
.dh-seg > .btn { margin: 0 !important; }

/* the site-wide .nav-link underline does not belong in a segmented control */
.dh-seg .nav-link::after { display: none !important; }

.dh-seg .nav-link i,
.dh-seg .dh-seg-btn i,
.dh-seg > .btn i {
    font-size: 0.95em;
    color: var(--dh-ocean);
    opacity: 0.85;
    transition: color 0.18s ease;
}

.dh-seg .nav-link:hover,
.dh-seg .dh-seg-btn:hover,
.dh-seg > .btn:hover {
    background: rgba(255, 255, 255, 0.75);
    color: var(--dh-ink) !important;
}
.dh-seg .nav-link:active,
.dh-seg .dh-seg-btn:active,
.dh-seg > .btn:active { transform: scale(0.98); }

.dh-seg .nav-link.active,
.dh-seg .btn-check:checked + .dh-seg-btn,
.dh-seg > .btn.active,
.dh-seg > .btn-check:checked + .btn {
    background: var(--dh-grad-active) !important;
    color: #fff !important;
    box-shadow: var(--dh-glow), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.dh-seg .nav-link.active i,
.dh-seg .btn-check:checked + .dh-seg-btn i,
.dh-seg > .btn.active i { color: #a5f3fc; opacity: 1; }

.dh-seg .nav-link:focus-visible,
.dh-seg .btn-check:focus-visible + .dh-seg-btn,
.dh-seg > .btn:focus-visible {
    outline: 2px solid var(--dh-cyan);
    outline-offset: 2px;
    box-shadow: none;
}
.dh-seg .btn-check:disabled + .dh-seg-btn { opacity: 0.45; cursor: not-allowed; }

/* Two-line label: name + technical caption */
.dh-seg-text {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 2px;
}
.dh-seg-meta {
    font-family: var(--dh-mono);
    font-size: 0.64rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--dh-muted);
    text-transform: none;
}
.dh-seg .nav-link.active .dh-seg-meta,
.dh-seg .btn-check:checked + .dh-seg-btn .dh-seg-meta,
.dh-seg > .btn.active .dh-seg-meta { color: rgba(236, 254, 255, 0.82); }

/* Stacked tiles: icon above label + caption (for narrow side panels) */
.dh-seg-stack .nav-link,
.dh-seg-stack .dh-seg-btn {
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.65rem 0.5rem !important;
    text-align: center;
    min-width: 0;
    white-space: normal;
}
.dh-seg-stack > li, .dh-seg-stack > .nav-item { min-width: 0; }
.dh-seg-stack .nav-link i,
.dh-seg-stack .dh-seg-btn i {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9px;
    font-size: 0.95rem;
    background: rgba(0, 105, 148, 0.09);
    transition: background-color 0.18s ease, color 0.18s ease;
}
.dh-seg-stack .nav-link.active i,
.dh-seg-stack .btn-check:checked + .dh-seg-btn i { background: rgba(255, 255, 255, 0.16); }
.dh-seg-stack .dh-seg-text { align-items: center; text-align: center; }

/* Auto-stack: side-by-side on wide screens, tiles on phones */
@media (max-width: 575.98px) {
    .dh-seg-autostack .nav-link,
    .dh-seg-autostack .dh-seg-btn {
        flex-direction: column;
        gap: 0.3rem;
        padding: 0.6rem 0.4rem !important;
        text-align: center;
        min-width: 0;
        white-space: normal;
    }
    .dh-seg-autostack > li, .dh-seg-autostack > .nav-item { min-width: 0; }
    .dh-seg-autostack .dh-seg-text { align-items: center; text-align: center; }
    .dh-seg-autostack .dh-seg-meta { font-size: 0.6rem; }
}

/* Compact variant */
.dh-seg-sm { padding: 3px; gap: 3px; border-radius: 11px; }
.dh-seg-sm .nav-link,
.dh-seg-sm .dh-seg-btn,
.dh-seg-sm > .btn {
    padding: 0.38rem 0.65rem !important;
    font-size: 0.78rem;
    border-radius: 8px !important;
    gap: 0.4rem;
}

/* Inline (content-width) variant for short switchers next to other controls */
.dh-seg-inline { display: inline-flex; width: auto; }
.dh-seg-inline > li, .dh-seg-inline .nav-link, .dh-seg-inline .dh-seg-btn { flex: 0 0 auto; }

/* ══════════════════════════════════════════════════════════════════════
   Tab bar
   ══════════════════════════════════════════════════════════════════════ */
.dh-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.15rem;
    padding-left: 0;
    margin-bottom: 1rem;
    list-style: none;
    border-bottom: 1px solid var(--dh-line) !important;
    overflow-x: auto;
    overflow-y: hidden;
    /* no scrollbar: on narrow screens the tabs are swiped, and the faded
       right edge shows that more tabs follow */
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
.dh-tabs::-webkit-scrollbar { display: none; }
.dh-tabs > li, .dh-tabs > .nav-item { flex: 0 0 auto; margin: 0 !important; }

.dh-tabs .nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0 !important;
    padding: 0.65rem 0.95rem 0.75rem !important;
    border: 0 !important;
    border-radius: 10px 10px 0 0 !important;
    background: transparent !important;
    color: var(--dh-muted) !important;
    font-size: 0.86rem;
    font-weight: 600;
    white-space: nowrap;
    transition: color 0.18s ease, background-color 0.18s ease;
}
.dh-tabs .nav-link i { opacity: 0.7; transition: opacity 0.18s ease, color 0.18s ease; }

/* gradient indicator (replaces the site-wide .nav-link underline) */
.dh-tabs .nav-link::after {
    content: '';
    position: absolute;
    left: 0.7rem;
    right: 0.7rem;
    bottom: 0;
    width: auto !important;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--dh-grad-line);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.25s ease;
}
.dh-tabs .nav-link:hover {
    color: var(--dh-ink) !important;
    background: rgba(0, 105, 148, 0.05) !important;
}
.dh-tabs .nav-link:hover::after { transform: scaleX(0.3); }
.dh-tabs .nav-link.active {
    color: var(--dh-ocean) !important;
    background: linear-gradient(180deg, rgba(6, 182, 212, 0) 40%, rgba(6, 182, 212, 0.07)) !important;
}
.dh-tabs .nav-link.active i { opacity: 1; color: var(--dh-ocean); }
.dh-tabs .nav-link.active::after { transform: scaleX(1); }
.dh-tabs .nav-link:focus-visible { outline: 2px solid var(--dh-cyan); outline-offset: -2px; box-shadow: none; }

/* counters inside tabs */
.dh-tabs .nav-link .badge {
    font-family: var(--dh-mono);
    font-size: 0.66rem;
    font-weight: 600;
    padding: 0.18rem 0.42rem;
    border-radius: 6px;
    background: #e2e8f0 !important;
    color: var(--dh-text) !important;
}
.dh-tabs .nav-link.active .badge {
    background: rgba(0, 105, 148, 0.12) !important;
    color: var(--dh-ocean) !important;
}

@media (prefers-reduced-motion: reduce) {
    .dh-seg .nav-link, .dh-seg .dh-seg-btn, .dh-seg > .btn,
    .dh-tabs .nav-link, .dh-tabs .nav-link::after { transition: none; }
}
