/* =====================================================
   Health Institution Wizard — Component Styles
   Scoped to .hi-* classes; no global leakage.
   Last updated: 2026-07-09
===================================================== */

/* ── Screen-reader-only utility ─────────────────── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Wizard indicator ───────────────────────────── */
.hi-wizard {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 48px;
}

.hi-wizard__step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    min-width: 0; /* allow label max-width to shrink instead of forcing overflow */
}

.hi-wizard__circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    transition: background .3s, color .3s;
}

.hi-wizard__step.active .hi-wizard__circle,
.hi-wizard__step.completed .hi-wizard__circle {
    background: #2196F3;
    color: #fff;
}

/* #757575 on white = 4.60:1 — passes WCAG AA for normal text */
.hi-wizard__label {
    margin-top: 8px;
    font-size: 11px;
    color: #757575;
    text-align: center;
    max-width: 96px;
    word-break: break-word;
}

.hi-wizard__step.active .hi-wizard__label {
    color: #2196F3;
    font-weight: 600;
}

.hi-wizard__step.completed .hi-wizard__label {
    color: #1976D2;
}

.hi-wizard__line {
    flex: 1;
    height: 3px;
    background: #e0e0e0;
    margin: 0 4px;
    margin-bottom: 28px;
    transition: background .3s;
}

.hi-wizard__line.completed {
    background: #2196F3;
}

/* ── Form grid ──────────────────────────────────── */
.hi-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px 48px;
}

/* Utility: span both columns — replaces inline style="grid-column:1/-1" */
.hi-full-width {
    grid-column: 1 / -1;
}

/* ── Form groups ────────────────────────────────── */
.hi-form-group,
fieldset.hi-form-group {
    margin-bottom: 0;
    border: none;
    padding: 0;
    min-width: 0; /* prevents fieldset from overflowing grid cell */
}

.hi-form-group label,
fieldset.hi-form-group legend {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 13px;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    float: none; /* reset any inherited float */
    width: 100%;
}

.hi-form-group label .required,
fieldset.hi-form-group legend .required {
    color: #c62828;
    margin-left: 2px;
    font-size: 14px;
    line-height: 1;
}

/* ── Inputs & selects ───────────────────────────── */
.hi-form-group input[type="text"],
.hi-form-group input[type="number"],
.hi-form-group input[type="email"],
.hi-form-group select {
    width: 100%;
    min-height: 44px; /* WCAG 2.5.8 touch target minimum */
    padding: 10px 16px;
    border: none;
    border-bottom: 2px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 0;
    font-size: 15px;
    outline: none;
    transition: border-color .3s, box-shadow .2s;
}

.hi-form-group input[type="text"]:focus,
.hi-form-group input[type="number"]:focus,
.hi-form-group input[type="email"]:focus,
.hi-form-group select:focus {
    border-bottom-color: #2196F3;
}

/* Explicit keyboard focus ring (shown only via keyboard, not mouse) */
.hi-form-group input[type="text"]:focus-visible,
.hi-form-group input[type="number"]:focus-visible,
.hi-form-group input[type="email"]:focus-visible,
.hi-form-group select:focus-visible {
    border-bottom-color: #2196F3;
    box-shadow: 0 2px 0 0 #2196F3;
    outline: 2px solid transparent; /* keeps layout stable */
}

.hi-form-group select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.hi-form-group select:disabled {
    opacity: .55;
    cursor: not-allowed;
    background-color: #efefef;
}

.hi-form-group .hi-helper-text {
    font-size: 12px;
    color: #1565C0; /* #1565C0 on white = 7.1:1 — passes WCAG AAA */
    margin-top: 6px;
}

/* ── Radio group ────────────────────────────────── */
.hi-radio-group {
    display: flex;
    flex-direction: row !important;
    align-items: center;
    gap: 24px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.hi-radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    font-size: 15px;
    text-transform: none;
    margin-bottom: 0;
    cursor: pointer;
    min-height: 44px; /* touch target */
    letter-spacing: 0;
    width: auto; /* reset the full-width .hi-form-group label rule so options size to content */
}

/*
 * Visually hidden — NOT display:none.
 * Keeps radio in the a11y tree and focusable via keyboard.
 * position:absolute + opacity:0 achieves visual hiding
 * while preserving tab order and screen reader access.
 */
.hi-radio-group input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 22px;
    height: 22px;
    margin: 0;
    cursor: pointer;
}

.hi-radio-group .hi-radio-circle {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .2s, background .2s;
    flex-shrink: 0;
    pointer-events: none; /* clicks pass through to the real input */
}

.hi-radio-group input[type="radio"]:checked + .hi-radio-circle {
    border-color: #2196F3;
    background: #2196F3;
}

.hi-radio-group input[type="radio"]:checked + .hi-radio-circle::after {
    content: '\2713';
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

/* Keyboard focus ring — appears only on keyboard navigation */
.hi-radio-group input[type="radio"]:focus-visible + .hi-radio-circle {
    outline: 2px solid #2196F3;
    outline-offset: 2px;
}

/*
 * Legacy global-rule guard.
 * The shared page wrapper reuses the `.findAcents`/`.onlineProcces` classes,
 * whose legacy mobile selector `.findAcents :nth-child(2) :nth-child(2)`
 * forces `flex-direction: column` onto the 2nd radio option ("Hayır"),
 * stacking its circle above the label. Restore the intended horizontal
 * layout with a module-scoped, higher-specificity override.
 */
.findAcents.onlineProcces .hi-radio-group label {
    flex-direction: row;
    align-items: center;
    width: auto;
}

/* ── Step panels ────────────────────────────────── */
.hi-step-panel {
    display: none;
}

.hi-step-panel.active {
    display: block;
}

/* ── Navigation button row ──────────────────────── */
.hi-btn-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    gap: 12px;
}

.hi-btn {
    padding: 12px 32px;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background .2s, box-shadow .15s;
    min-height: 44px;
}

.hi-btn--primary {
    background: #2196F3;
    color: #fff;
}

.hi-btn--primary:hover {
    background: #1976D2;
}

.hi-btn--outline {
    background: transparent;
    border: 2px solid #2196F3;
    color: #2196F3;
}

.hi-btn--outline:hover {
    background: #E3F2FD;
}

.hi-btn--submit {
    background: #4CAF50;
    color: #fff;
}

.hi-btn--submit:hover {
    background: #388E3C;
}

/* Focus rings for keyboard navigation */
.hi-btn:focus-visible {
    outline: 3px solid #2196F3;
    outline-offset: 2px;
}

.hi-btn--submit:focus-visible {
    outline-color: #388E3C;
}

/* Disabled — still in tab order so keyboard users can discover them */
.hi-btn--disabled,
.hi-btn:disabled {
    opacity: .45;
    pointer-events: none;
    cursor: default;
}

/* ── File upload group ──────────────────────────── */
.hi-file-group {
    margin-bottom: 16px;
}

.hi-file-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 13px;
    color: #333;
    text-transform: uppercase;
}

.hi-file-group input[type="file"] {
    font-size: 14px;
    max-width: 100%;
}

/* ── Hidden utility ─────────────────────────────── */
.hi-field--hidden {
    display: none !important;
}

/* ── Identity type tab bar (Step 2) ─────────────── */
.hi-tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.hi-tab-item {
    padding: 8px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    color: #757575;
    transition: border-color .2s, color .2s;
    background: #fff;
    min-height: 44px;
}

.hi-tab-item:hover {
    border-color: #90CAF9;
    color: #1976D2;
}

.hi-tab-item.active {
    border-color: #2196F3;
    color: #2196F3;
    background: #E3F2FD;
}

.hi-tab-item.hi-field--hidden {
    display: none !important;
}

.hi-tab-item:focus-visible {
    outline: 2px solid #2196F3;
    outline-offset: 2px;
}

/* ── Identity validation states ─────────────────── */
/* #E65100 on white = 4.56:1 — passes WCAG AA */
.hi-identity-loading {
    font-size: 13px;
    color: #E65100;
    font-style: italic;
    margin-top: 6px;
}

.hi-identity-result {
    font-size: 13px;
    color: #2E7D32;
    font-weight: 600;
    margin-top: 6px;
}

/* ── Error message ──────────────────────────────── */
.hi-error-msg {
    color: #b71c1c;
    font-size: 13px;
    margin: 8px 0;
    padding: 10px 14px;
    background: #FFEBEE;
    border-left: 4px solid #c62828;
    border-radius: 2px;
}

/* ── NiceSelect overflow cap (scoped to module) ─── */
.hi-form-group .nice-select .list {
    max-height: 220px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ── Tax office typeahead ───────────────────────── */
.hi-taxoffice-wrapper {
    position: relative;
}

.hi-taxoffice-results {
    position: absolute;
    z-index: 100;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-top: none;
    max-height: 220px;
    overflow-y: auto;
    width: 100%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, .08);
}

.hi-taxoffice-item {
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
}

.hi-taxoffice-item:hover,
.hi-taxoffice-item:focus {
    background: #E3F2FD;
    outline: none;
}

/* ── File upload list (Step 5) ──────────────────── */
.hi-file-list {
    margin-bottom: 32px;
}

.hi-file-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 12px;
    flex-wrap: wrap; /* allows reflow on narrow viewports */
}

.hi-file-item__label {
    flex: 1 1 180px;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    min-width: 140px;
}

.hi-file-item__required {
    font-size: 12px;
    color: #c62828;
    margin-left: 4px;
}

.hi-file-item__input {
    flex: 2 1 200px;
    min-width: 140px;
}

.hi-file-item__input input[type="file"] {
    max-width: 100%;
}

.hi-file-item__status {
    flex: 0 0 auto;
    min-width: 80px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
}

/* #2E7D32 on white = 5.1:1 — passes WCAG AA */
.hi-file-item__status--ok {
    color: #2E7D32;
}

.hi-file-item__status--error {
    color: #b71c1c;
}

/* #757575 on white = 4.6:1 — passes WCAG AA */
.hi-file-item__status--pending {
    color: #757575;
}

/* Step heading utility (replaces inline style on <h3>) */
.hi-step-heading {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 24px;
    color: #333;
}

/* ── Step descriptive note (below heading) ──────── */
.hi-step-note {
    font-size: 14px;
    color: #555;
    margin-top: -12px; /* tighten space after heading */
    margin-bottom: 24px;
    line-height: 1.5;
}

/* ── Review summary container ───────────────────── */
.hi-review-summary {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 24px;
    margin-bottom: 24px;
}

/* ── Review summary list (dt/dd pairs) ──────────── */
.hi-review-list {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 12px 16px;
    margin: 0;
}

.hi-review-list dt {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #757575;
    padding-top: 2px;
}

.hi-review-list dd {
    font-size: 15px;
    color: #333;
    margin: 0;
    word-break: break-word;
}

/* ── Success / confirmation panel ───────────────── */
.hi-success-panel {
    text-align: center;
    padding: 48px 24px;
}

.hi-success-panel__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #E8F5E9;
    color: #2E7D32;
    font-size: 36px;
    margin: 0 auto 16px;
}

.hi-success-panel__title {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin-bottom: 12px;
}

.hi-success-panel__skrs {
    font-size: 16px;
    color: #2196F3;
    font-weight: 600;
    margin-bottom: 24px;
}

.hi-kvkk-approval {
    font-size: 13px;
    line-height: 1.5;
}

.hi-kvkk-text {
    margin-bottom: 10px;
}

.hi-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.hi-checkbox .required {
    color: #dc3545 !important;
    font-weight: 700;
    margin-right: 4px;
}

/* ── Button spinner ─────────────────────────────── */
.hi-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: hiSpin .7s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes hiSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Responsive: Tablet (768–1024 px) ──────────── */
@media (max-width: 1024px) {
    .hi-form-grid {
        gap: 20px 32px;
    }

    .hi-wizard__label {
        font-size: 10px;
        max-width: 80px;
    }
}

/* ── Responsive: Mobile (≤767 px) ──────────────── */
@media (max-width: 767px) {
    .hi-form-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* Full-width spans collapse naturally to single column */
    .hi-full-width {
        grid-column: auto;
    }

    .hi-wizard {
        margin-bottom: 32px;
    }

    .hi-wizard__circle {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .hi-wizard__label {
        font-size: 9px;
        max-width: 52px;
    }

    .hi-wizard__line {
        margin-bottom: 22px;
        margin-left: 2px;
        margin-right: 2px;
    }

    /* Stack buttons vertically, primary action on top */
    .hi-btn-row {
        flex-direction: column-reverse;
        align-items: stretch;
        margin-top: 24px;
        gap: 10px;
    }

    /*
     * Step 1 row also holds the KVKK consent block (not just Geri/İleri).
     * Keep natural order so the consent text/checkbox stays above the
     * "İleri" button instead of being pushed below it by column-reverse.
     */
    #step-1 .hi-btn-row {
        flex-direction: column;
    }

    .hi-btn {
        width: 100%;
        text-align: center;
    }

    /* Hide placeholder <span> that keeps spacing on desktop */
    .hi-btn-row > span:empty {
        display: none;
    }

    /* Review list collapses to single column */
    .hi-review-list {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .hi-review-list dd {
        margin-bottom: 12px;
    }

    /* File rows stack vertically */
    .hi-file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .hi-file-item__label,
    .hi-file-item__input {
        flex: none;
        width: 100%;
        min-width: auto;
    }

    .hi-file-item__status {
        text-align: left;
        min-width: auto;
    }
}
