/*
 * Login / Create account modal (DEV-90). Scoped under .iauth so Bootstrap 3 / T3 rules cannot leak in.
 * Bootstrap sets html{font-size:10px}: use px. Logical properties only, so RTL mirrors from the page dir.
 * Phones get a bottom sheet, larger screens a centred card.
 */
.iauth {
    --ia-ink: #2F3A44;
    --ia-muted: #66717B;
    --ia-faint: #8A949C;
    --ia-green: #8DC53E;
    --ia-green-hover: #7FB833;
    --ia-green-text: #3B7414;
    --ia-green-soft: #EEF6E3;
    --ia-bg: #F5F7F5;
    --ia-line: #DCE2DC;
    --ia-error: #C2272D;
    --ia-error-soft: #FDF1F1;
    --ia-radius: 10px;
    --ia-font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --ia-ease: cubic-bezier(.2, .8, .2, 1);
    position: fixed;
    inset: 0;
    /* Above the header, the search panel (10000000) and the cookie notice (9999999). */
    z-index: 10000010;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    font-family: var(--ia-font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ia-ink);
    -webkit-font-smoothing: antialiased;
    text-align: start;
}
.iauth[hidden] { display: none; }
[dir="rtl"] .iauth, .rtl .iauth { --ia-font: IRANSans, Tahoma, sans-serif; }
.iauth *, .iauth *::before, .iauth *::after { box-sizing: border-box; }
.iauth [hidden] { display: none !important; }
html.iauth-lock, html.iauth-lock body { overflow: hidden; }

.iauth-overlay {
    position: absolute;
    inset: 0;
    background: rgba(24, 31, 37, .6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity .2s ease;
}
.iauth-dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 94vh;
    max-height: 94dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
    transform: translateY(40px);
    opacity: 0;
    transition: transform .26s var(--ia-ease), opacity .2s ease;
}
.iauth.is-open .iauth-overlay { opacity: 1; }
.iauth.is-open .iauth-dialog { transform: none; opacity: 1; }

@media (min-width: 576px) {
    .iauth { align-items: center; padding: 24px; }
    .iauth-dialog {
        max-width: 440px;
        max-height: calc(100vh - 48px);
        border-radius: 18px;
        box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
        transform: translateY(12px) scale(.98);
    }
}

/* ---------- head and tabs ---------- */
.iauth-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 0;
}
.iauth-logo { display: block; width: auto; height: 34px; max-width: 60%; }
.iauth-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--ia-bg);
    color: var(--ia-ink);
    cursor: pointer;
    transition: background .15s ease;
}
.iauth-x:hover { background: #E8ECE8; }

.iauth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin: 18px 20px 0;
    padding: 4px;
    border-radius: 12px;
    background: var(--ia-bg);
}
.iauth[data-current="otp"] .iauth-tabs,
.iauth[data-current="forgot"] .iauth-tabs,
.iauth[data-current="setpw"] .iauth-tabs,
.iauth[data-current="name"] .iauth-tabs,
.iauth[data-current="done"] .iauth-tabs { display: none; }
.iauth-tab {
    min-height: 40px;
    margin: 0;
    padding: 0 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ia-muted);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.iauth-tab:hover { color: var(--ia-ink); }
.iauth-tab[aria-selected="true"] {
    background: #fff;
    color: var(--ia-ink);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}

/* ---------- body ---------- */
.iauth-body { padding: 22px 20px 8px; }
@media (min-width: 576px) {
    .iauth-head { padding: 22px 28px 0; }
    .iauth-tabs { margin-inline: 28px; }
    .iauth-body { padding: 24px 28px 8px; }
}
.iauth-title {
    margin: 0 0 4px;
    padding: 0;
    color: var(--ia-ink);
    font-family: inherit;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -.2px;
}
.iauth-sub { margin: 0 0 20px; color: var(--ia-muted); font-size: 14px; line-height: 1.6; }

.iauth-alert {
    margin: 0 0 16px;
    padding: 11px 14px;
    border-radius: var(--ia-radius);
    background: var(--ia-error-soft);
    color: #8E1B20;
    font-size: 13.5px;
    line-height: 1.6;
}
.iauth-alert.is-info { background: var(--ia-green-soft); color: var(--ia-green-text); }

.iauth-form { margin: 0; }
.iauth-field { margin: 0 0 16px; }
.iauth-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.iauth-label-row .iauth-label { margin: 0; }
.iauth .iauth-label {
    display: block;
    max-width: none;
    margin: 0 0 6px;
    color: var(--ia-ink);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.4;
}
.iauth-opt { color: var(--ia-faint); font-weight: 400; }

.iauth-control { position: relative; }
.iauth-ico {
    position: absolute;
    inset-inline-start: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ia-faint);
    pointer-events: none;
}
.iauth .iauth-input {
    display: block;
    width: 100%;
    height: 48px;
    margin: 0;
    padding: 0 14px;
    padding-inline-start: 44px;
    border: 1px solid var(--ia-line);
    border-radius: var(--ia-radius);
    background: var(--ia-bg);
    box-shadow: none;
    color: var(--ia-ink);
    font: inherit;
    font-size: 15px;
    line-height: normal;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
    -webkit-appearance: none;
    appearance: none;
}
.iauth .is-plain .iauth-input { padding-inline-start: 14px; }
.iauth .iauth-input::placeholder { color: #A4ACB3; opacity: 1; }
.iauth .iauth-input:hover { border-color: #C7CFC7; }
.iauth .iauth-input:focus {
    outline: none;
    border-color: var(--ia-green);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(141, 197, 62, .25);
}
.iauth .iauth-control:focus-within .iauth-ico { color: var(--ia-green-text); }
.iauth .has-eye .iauth-input { padding-inline-end: 48px; }
.iauth .has-send .iauth-input { padding-inline-end: 132px; }
.iauth .iauth-code { font-size: 20px; font-weight: 600; letter-spacing: .35em; }

.iauth-eye {
    position: absolute;
    inset-inline-end: 4px;
    top: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ia-muted);
    transform: translateY(-50%);
    cursor: pointer;
}
.iauth-eye:hover { color: var(--ia-ink); }
.iauth-eye .iauth-eye-off, .iauth-eye.is-on .iauth-eye-on { display: none; }
.iauth-eye.is-on .iauth-eye-off { display: block; }

.iauth-send {
    position: absolute;
    inset-inline-end: 6px;
    top: 50%;
    min-width: 112px;
    height: 36px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid var(--ia-line);
    border-radius: 8px;
    background: #fff;
    color: var(--ia-green-text);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transform: translateY(-50%);
    cursor: pointer;
}
.iauth-send:hover:not(:disabled) { border-color: var(--ia-green); }
.iauth-send:disabled { color: var(--ia-muted); cursor: default; }

.iauth-field.is-invalid .iauth-input { border-color: var(--ia-error); background: var(--ia-error-soft); }
.iauth-field.is-invalid .iauth-input:focus { box-shadow: 0 0 0 3px rgba(194, 39, 45, .15); }
.iauth-err { margin: 6px 0 0; color: var(--ia-error); font-size: 12.5px; line-height: 1.5; }
.iauth-hint { margin: 6px 0 0; color: var(--ia-muted); font-size: 12.5px; line-height: 1.5; }
.iauth-hint:empty, .iauth-field.is-invalid .iauth-hint:not([data-iauth-sent]) { display: none; }
.iauth-sent { margin: -6px 0 16px; color: var(--ia-muted); font-size: 13.5px; }
.iauth-sent span { overflow-wrap: anywhere; }

.iauth .iauth-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    color: var(--ia-muted);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.6;
    cursor: pointer;
}
.iauth .iauth-check input {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: var(--ia-green);
    cursor: pointer;
}
.iauth-field.is-invalid .iauth-check { color: var(--ia-error); }
.iauth .iauth-check a, .iauth .iauth-check a:visited, .iauth .iauth-check a:focus,
.iauth .iauth-foot a, .iauth .iauth-foot a:visited, .iauth .iauth-foot a:focus { color: var(--ia-ink); text-decoration: underline; text-underline-offset: 2px; }
.iauth .iauth-check a:hover, .iauth .iauth-foot a:hover { color: var(--ia-green-text); }

.iauth-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- buttons ---------- */
.iauth-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--ia-radius);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.iauth-btn + .iauth-btn { margin-top: 10px; }
.iauth-btn:focus-visible, .iauth-tab:focus-visible, .iauth-x:focus-visible, .iauth-link:focus-visible,
.iauth-eye:focus-visible, .iauth-send:focus-visible, .iauth-back:focus-visible {
    outline: 3px solid rgba(141, 197, 62, .55);
    outline-offset: 2px;
}
.iauth-btn-primary { background: var(--ia-green); color: var(--ia-ink); }
.iauth-btn-primary:hover:not(:disabled) { background: var(--ia-green-hover); }
.iauth-btn-secondary { border-color: #CDD5CD; background: #fff; color: var(--ia-ink); font-weight: 600; }
.iauth-btn-secondary:hover { border-color: var(--ia-green); background: var(--ia-bg); }
.iauth-btn-ghost { min-height: 44px; background: transparent; color: var(--ia-muted); font-size: 14px; font-weight: 600; }
.iauth-btn-ghost:hover:not(:disabled) { color: var(--ia-ink); background: var(--ia-bg); }
.iauth-btn:disabled { cursor: default; }
.iauth-btn-ghost:disabled { color: var(--ia-faint); }
.iauth-btn.is-busy { color: transparent !important; }
.iauth-btn.is-busy::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(47, 58, 68, .25);
    border-top-color: var(--ia-ink);
    border-radius: 50%;
    animation: iauth-spin .7s linear infinite;
}
@keyframes iauth-spin { to { transform: rotate(360deg); } }

.iauth-link {
    display: inline;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ia-green-text);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}
.iauth-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.iauth-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 14px;
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--ia-muted);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}
.iauth-back:hover { color: var(--ia-ink); }
[dir="rtl"] .iauth-flip, .rtl .iauth-flip { transform: scaleX(-1); }

.iauth-or {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--ia-faint);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.iauth-or::before, .iauth-or::after { content: ""; flex: 1; height: 1px; background: var(--ia-line); }
.iauth-switch { margin: 18px 0 6px; color: var(--ia-muted); font-size: 14px; text-align: center; }
.iauth-switch .iauth-link { font-size: 14px; }

.iauth-foot {
    margin: 0;
    padding: 14px 20px 20px;
    color: var(--ia-muted);
    font-size: 12px;
    line-height: 1.6;
    text-align: center;
}
.iauth[data-current="register"] .iauth-foot,
.iauth[data-current="name"] .iauth-foot,
.iauth[data-current="done"] .iauth-foot { display: none; }

.iauth-done { padding: 18px 0 26px; text-align: center; }
.iauth-done svg { display: block; margin: 0 auto 14px; color: var(--ia-green); }

@media (prefers-reduced-motion: reduce) {
    .iauth-overlay, .iauth-dialog { transition: none; }
}
