/* =============================================================================
   ABHA Card Form Styles
   Variables → Reset → Layout → Components → Sections → Utilities → Responsive
   ============================================================================= */

/* ── Variables ──────────────────────────────────────────────────────────────── */
.abha-wrapper {
    --abha-primary:       #1b3c74;
    --abha-secondary:     #152ce1;
    --abha-secondary-rgb: 21, 44, 225;
    --abha-accent:        #5669ec;
    --abha-surface:       #F0F2FF;
    --abha-border:        #d0d4f0;
    --abha-text:          #1e2130;
    --abha-text-muted:    #5e6384;
    --abha-success:       #16a34a;
    --abha-success-bg:    #dcfce7;
    --abha-error:         #dc2626;
    --abha-error-bg:      #fee2e2;
    --abha-radius:        10px;
    --abha-radius-sm:     6px;
    --abha-shadow:        0 1px 12px rgba(0, 0, 0, 0.08);
    --abha-transition:    0.2s ease;
}

/* ── Wrapper shell ──────────────────────────────────────────────────────────── */
.abha-wrapper {
    padding: 28px;
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--abha-shadow);
    font-family: inherit;
    color: var(--abha-text);
    max-width: 640px;
    margin: 0 auto;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.abha-header {
    text-align: center;
    margin-bottom: 24px;
}
.abha-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--abha-primary);
    line-height: 1.35;
    margin: 0;
}

/* ── Section visibility ─────────────────────────────────────────────────────── */
/* Sections use the `hidden` HTML attribute; JS removes/adds it */
.abha-section[hidden] { display: none; }
.abha-section { animation: fadeIn 0.25s ease both; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0);   }
}

/* ── Tab switcher ───────────────────────────────────────────────────────────── */
.tab-switcher {
    display: flex;
    gap: 6px;
    background: var(--abha-surface);
    border-radius: var(--abha-radius-sm);
    padding: 5px;
    margin-bottom: 24px;
}
.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: calc(var(--abha-radius-sm) - 2px);
    background: transparent;
    color: var(--abha-text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--abha-transition), color var(--abha-transition),
                box-shadow var(--abha-transition);
}
.tab-btn:hover  { color: var(--abha-primary); }
.tab-btn.active {
    background: #fff;
    color: var(--abha-secondary);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.12);
}
.tab-btn:focus-visible {
    outline: 2px solid rgba(var(--abha-secondary-rgb), 0.4);
    outline-offset: 2px;
}

/* Auth form visibility – toggled by JS via .active class */
.auth-form { display: none; }
.auth-form.active { display: block; }

/* ── Form fields ────────────────────────────────────────────────────────────── */
.form-field {
    margin-bottom: 18px;
}
.field-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--abha-primary);
    margin-bottom: 7px;
}
.required { color: var(--abha-error); margin-left: 2px; }

.input-field {
    display: block;
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--abha-border);
    border-radius: var(--abha-radius-sm);
    font-size: 0.9rem;
    color: var(--abha-text);
    background: #fff;
    transition: border-color var(--abha-transition), box-shadow var(--abha-transition);
    box-sizing: border-box;
    height: auto;
}
.input-field:focus {
    outline: none;
    border-color: var(--abha-secondary);
    box-shadow: 0 0 0 3px rgba(var(--abha-secondary-rgb), 0.15);
}
.input-field.is-error {
    border-color: var(--abha-error);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}
.input-field:disabled { background: var(--abha-surface); cursor: not-allowed; opacity: 0.7; }

textarea.input-field { resize: vertical; min-height: 80px; }

/* Checkbox field */
.checkbox-field {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 18px;
}
.checkbox-field input[type="checkbox"] {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: var(--abha-secondary);
    cursor: pointer;
}
.checkbox-field label {
    font-size: 0.82rem;
    color: var(--abha-text-muted);
    cursor: pointer;
    line-height: 1.5;
}

/* ── Form groups (multi-column) ─────────────────────────────────────────────── */
.form-group { display: flex; gap: 12px; }

.name-group > *,
.dob-group > *,
.state-district-group > .field-wrap { flex: 1; }

.state-district-group { align-items: flex-end; }
.state-district-group .field-wrap { display: flex; flex-direction: column; }

/* ── Gender options ─────────────────────────────────────────────────────────── */
.gender-group { flex-wrap: wrap; gap: 10px; }

.gender-option {
    display: flex;
    align-items: center;
    gap: 0;
    cursor: pointer;
}
.gender-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.gender-option span {
    display: inline-block;
    padding: 9px 22px;
    border: 2px solid var(--abha-border);
    border-radius: 99px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--abha-secondary);
    background: var(--abha-surface);
    transition: all var(--abha-transition);
    cursor: pointer;
}
.gender-option:hover span {
    border-color: var(--abha-accent);
    background: #e7ebfe;
}
.gender-option input[type="radio"]:checked + span {
    background: var(--abha-secondary);
    color: #fff;
    border-color: var(--abha-secondary);
    box-shadow: 0 2px 8px rgba(var(--abha-secondary-rgb), 0.35);
}
.gender-option input[type="radio"]:focus-visible + span {
    outline: 2px solid var(--abha-secondary);
    outline-offset: 3px;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.form-actions {
    display: flex;
    justify-content: center;
    margin-top: 22px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 36px;
    border: none;
    border-radius: var(--abha-radius-sm);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--abha-transition), transform var(--abha-transition),
                box-shadow var(--abha-transition);
    line-height: 1;
}
.btn:focus-visible {
    outline: 2px solid rgba(var(--abha-secondary-rgb), 0.5);
    outline-offset: 3px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--abha-secondary);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--abha-accent);
    box-shadow: 0 4px 12px rgba(var(--abha-secondary-rgb), 0.35);
}

.btn-outline {
    background: transparent;
    color: var(--abha-secondary);
    border: 2px solid var(--abha-secondary);
}
.btn-outline:hover:not(:disabled) {
    background: var(--abha-surface);
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--abha-secondary);
    font-size: 0.825rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--abha-transition), opacity var(--abha-transition);
}
.btn-link:disabled { opacity: 0.45; cursor: not-allowed; text-decoration: none; }
.btn-link:hover:not(:disabled) { color: var(--abha-accent); }

/* ── OTP row ────────────────────────────────────────────────────────────────── */
.otp-input-group {
    display: flex;
    align-items: center;
    gap: 12px;
}
.otp-input-group .input-field { flex: 1; letter-spacing: 0.25em; font-weight: 600; }
.otp-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    align-items: flex-start;
}

/* Mobile hint ─────────────────────────────────────────────────────────────── */
.field-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 8px;
    padding: 9px 12px;
    border: 1px solid var(--abha-border);
    border-radius: var(--abha-radius-sm);
    background: var(--abha-surface);
    font-size: 0.8rem;
    color: var(--abha-text-muted);
    line-height: 1.45;
}
.icon-info {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--abha-secondary);
}

/* ── Choose ABHA section ────────────────────────────────────────────────────── */
.choose-abha-section .section-header { margin-bottom: 16px; }
.choose-abha-section .section-header h3 { margin-bottom: 4px; }
.choose-abha-section .founded-address { color: var(--abha-text-muted); font-size: 0.875rem; }

.abha-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 4px;
}
/* Items injected by JS */
.abha-list .abha-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--abha-surface);
    border: 1.5px solid var(--abha-border);
    border-radius: var(--abha-radius-sm);
    padding: 10px 14px;
    font-size: 0.875rem;
    font-weight: 600;
    width: calc(50% - 5px);
    cursor: pointer;
    transition: border-color var(--abha-transition), background var(--abha-transition);
}
.abha-list .abha-item:hover,
.abha-list .abha-item.selected {
    border-color: var(--abha-secondary);
    background: #e7ebfe;
}
.abha-list .phr-dropdown { width: 100%; }

/* ── Suggestion section ─────────────────────────────────────────────────────── */
.suggestion-section .section-header { margin-bottom: 20px; }

.suggestion-list-wrap.no-data {
    opacity: 0.45;
    pointer-events: none;
}
.suggestion-list-wrap:not(.no-data) { opacity: 1; pointer-events: auto; }

.suggestion-list {
    padding: 10px;
    border: 1.5px solid var(--abha-border);
    border-radius: var(--abha-radius-sm);
    margin-bottom: 16px;
    min-height: 48px;
    color: var(--abha-text-muted);
    font-size: 0.875rem;
}
.suggestion-item {
    padding: 9px 12px;
    border-radius: calc(var(--abha-radius-sm) - 2px);
    background: var(--abha-surface);
    cursor: pointer;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background var(--abha-transition), color var(--abha-transition);
}
.suggestion-item:last-child { margin-bottom: 0; }
.suggestion-item:hover { background: #dce0fb; }
.suggestion-item.selected-address {
    background: var(--abha-secondary);
    color: #fff;
}

/* ── Separator ──────────────────────────────────────────────────────────────── */
.separator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
}
.separator::before,
.separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--abha-border);
}
.separator span {
    font-size: 0.8rem;
    color: var(--abha-text-muted);
    font-weight: 600;
    white-space: nowrap;
}

/* ── Section header ─────────────────────────────────────────────────────────── */
.section-header { margin-bottom: 22px; }
.section-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--abha-primary);
    margin: 0 0 4px;
}
.section-header p {
    color: var(--abha-text-muted);
    font-size: 0.875rem;
    margin: 0;
}

/* ── Response message ───────────────────────────────────────────────────────── */
#response-message {
    margin-top: 16px;
    padding: 10px 16px;
    border-radius: var(--abha-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    /* shown/hidden via JS removing `hidden` attribute */
}
#response-message[hidden] { display: none; }
#response-message.is-success {
    color: var(--abha-success);
    background: var(--abha-success-bg);
    border-left: 4px solid var(--abha-success);
}
#response-message.is-error {
    color: var(--abha-error);
    background: var(--abha-error-bg);
    border-left: 4px solid var(--abha-error);
}

.inline-error {
    display: block;
    margin-top: 4px;
    font-size: 0.775rem;
    color: var(--abha-error);
}

/* ── Loading spinner ────────────────────────────────────────────────────────── */
#loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
}
#loading-spinner[hidden] { display: none; }
.spinner-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--abha-secondary);
    animation: bounce 1s infinite ease-in-out;
}
.spinner-dot:nth-child(2) { animation-delay: 0.15s; }
.spinner-dot:nth-child(3) { animation-delay: 0.3s;  }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40%           { transform: scale(1);   opacity: 1;   }
}

/* ── Image preview (ABHA card result) ──────────────────────────────────────── */
.image-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    border: 1.5px solid var(--abha-border);
    border-radius: var(--abha-radius);
    padding: 20px;
    background: var(--abha-surface);
}
.image-preview img {
    max-width: 100%;
    border-radius: var(--abha-radius-sm);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Modal */
.abha-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}
.abha-modal-overlay[hidden] { display: none; }
.abha-modal-box {
    background: #fff;
    border-radius: var(--abha-radius);
    padding: 24px;
    max-width: 600px;
    width: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: slideUp 0.25s ease;
}
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.abha-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--abha-text-muted);
    line-height: 1;
    transition: color var(--abha-transition);
}
.abha-modal-close:hover { color: var(--abha-error); }
.abha-modal-box img { max-width: 100%; border-radius: var(--abha-radius-sm); }

/* ── Utilities ──────────────────────────────────────────────────────────────── */
.text-center { text-align: center; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 560px) {
    .abha-wrapper { padding: 18px; }

    .tab-switcher { flex-direction: column; }
    .tab-btn { flex: none; }

    .name-group,
    .dob-group,
    .state-district-group { flex-direction: column; }

    .abha-list .abha-item { width: 100%; }

    .otp-input-group { flex-direction: column; align-items: stretch; }
    .otp-actions { flex-direction: row; gap: 16px; }

    .btn { width: 100%; justify-content: center; }
}