/* صفحات الحساب */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    min-height: 100%;
}

body.auth-flow-page {
    min-height: 100vh;
    background: linear-gradient(
        180deg,
        var(--primary-light),
        var(--background)
    );
    color: var(--text-primary);
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8, 32px) var(--space-5, 20px);
}

.auth-card {
    width: 100%;
    padding: var(--space-7, 28px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 16px);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.auth-card-narrow {
    max-width: 500px;
}

.auth-card-wide {
    max-width: 720px;
}

/* الشعار والأدوات */
.auth-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3, 12px);
    margin-block-end: var(--space-5, 20px);
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    text-decoration: none;
}

.auth-logo-horizontal img {
    display: block;
    inline-size: min(180px, 44vw);
    block-size: auto;
    max-block-size: 60px;
    object-fit: contain;
}

.auth-top-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2, 8px);
    flex-shrink: 0;
}

.auth-language-switch button {
    min-block-size: 34px;
    padding-inline: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill, 999px);
    background: var(--surface-soft);
    color: var(--text-secondary);
    font: inherit;
    font-size: var(--text-label);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
}

.auth-language-switch button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.auth-theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill, 999px);
    background: var(--surface-soft);
}

.auth-theme-switch button {
    inline-size: 30px;
    block-size: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.auth-theme-switch button:hover,
.auth-theme-switch button.is-active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.auth-theme-switch svg {
    inline-size: 16px;
    block-size: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* التقدم */
.auth-progress {
    margin-block-end: var(--space-5, 20px);
}

.auth-progress > span {
    display: block;
    margin-block-end: var(--space-2, 8px);
    color: var(--text-muted);
    font-size: var(--text-caption);
}

.auth-progress-track {
    block-size: 5px;
    overflow: hidden;
    border-radius: var(--radius-pill, 999px);
    background: var(--surface-soft);
}

.auth-progress-track i {
    display: block;
    block-size: 100%;
    border-radius: inherit;
    background: var(--primary);
}

/* العنوان */
.auth-heading {
    margin-block-end: var(--space-5, 20px);
    text-align: start;
}

.auth-heading h1 {
    color: var(--text-primary);
    font-size: var(--text-page-title);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-heading);
}

.auth-heading p {
    margin-block-start: var(--space-2, 8px);
    color: var(--text-muted);
    font-size: var(--text-body);
    line-height: var(--line-height-normal);
}

.verification-email {
    display: inline-block;
    margin-block-start: var(--space-1, 4px);
    color: var(--primary);
    font-size: var(--text-body);
    font-weight: var(--font-weight-semibold);
    direction: ltr;
    unicode-bidi: isolate;
}

/* الرسائل */
.auth-errors,
.auth-success,
.auth-privacy-note {
    margin-block-end: var(--space-4, 16px);
    padding: 11px 13px;
    border-radius: var(--radius-md, 10px);
    font-size: var(--text-label);
    line-height: var(--line-height-normal);
}

.auth-errors {
    border: 1px solid var(--danger);
    background: var(--danger-light);
    color: var(--danger);
}

.auth-success {
    border: 1px solid var(--primary-light-hover);
    background: var(--success-light);
    color: var(--primary);
}

.auth-privacy-note {
    border: 1px solid var(--border);
    background: var(--surface-soft);
    color: var(--text-secondary);
}

.auth-errors p + p {
    margin-block-start: var(--space-1, 4px);
}

/* النموذج */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4, 16px);
}

.auth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4, 16px);
}

.auth-field {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.auth-field label {
    color: var(--text-primary);
    font-size: var(--text-body);
    font-weight: var(--font-weight-semibold);
}

.required-star {
    margin-inline-start: 3px;
    color: var(--danger);
    font-weight: var(--font-weight-bold);
}

.auth-field input,
.auth-select-wrap select {
    inline-size: 100%;
    block-size: var(--input-height, 44px);
    min-block-size: var(--input-height, 44px);
    padding-block: 0;
    padding-inline: var(--input-padding-inline, 12px);
    border: 1px solid var(--input-border);
    border-radius: var(--input-radius, 9px);
    background: var(--input-background);
    color: var(--input-text);
    font: inherit;
    font-size: var(--text-body);
    line-height: normal;
    outline: none;
    transition:
        border-color var(--transition-fast, .15s) ease,
        box-shadow var(--transition-fast, .15s) ease,
        background var(--transition-fast, .15s) ease;
}

.auth-field input:hover,
.auth-select-wrap select:hover {
    border-color: var(--border-strong);
}

.auth-field input:focus,
.auth-select-wrap select:focus {
    border-color: var(--input-border-focus, var(--primary));
    box-shadow: var(--focus-ring);
}

.auth-field input::placeholder {
    color: var(--input-placeholder);
}

.auth-field small {
    display: block;
    color: var(--text-muted);
    font-size: var(--text-label);
    line-height: var(--line-height-normal);
}

/* القوائم */
.auth-select-wrap {
    position: relative;
    width: 100%;
}

.auth-select-wrap select {
    appearance: none;
    -webkit-appearance: none;
    padding-inline-end: 40px;
    cursor: pointer;
}

.auth-select-wrap::after {
    content: '';
    position: absolute;
    inset-inline-end: 15px;
    inset-block-start: 50%;
    inline-size: 7px;
    block-size: 7px;
    border-inline-end: 2px solid var(--text-muted);
    border-block-end: 2px solid var(--text-muted);
    transform: translateY(-65%) rotate(45deg);
    pointer-events: none;
}

.auth-select-wrap:has(select:disabled) {
    opacity: var(--disabled-opacity, .58);
}

.auth-select-wrap select:disabled {
    cursor: not-allowed;
}

/* الوضع الداكن */
html[data-theme="dark"] .auth-field input,
html[data-theme="dark"] .auth-select-wrap select {
    border-color: var(--border-strong);
    background: var(--background);
}

html[data-theme="dark"] .auth-field input:focus,
html[data-theme="dark"] .auth-select-wrap select:focus {
    background: var(--surface-soft);
}

html[data-theme="dark"] .auth-field input:-webkit-autofill {
    -webkit-text-fill-color: var(--input-text);
    box-shadow: 0 0 0 1000px var(--background) inset;
}

/* التحقق */
.verification-code {
    direction: ltr;
    text-align: center;
    letter-spacing: .42em;
    font-size: var(--text-xl) !important;
    font-weight: var(--font-weight-bold);
}

.verification-spam-note {
    margin-block-start: var(--space-1, 4px);
}

.verification-spam-note strong {
    color: var(--text-primary);
    font-weight: var(--font-weight-bold);
}

.username-status {
    min-block-size: 1.4em;
}

.username-status.is-available {
    color: var(--success);
}

.username-status.is-taken,
.username-status.is-invalid {
    color: var(--danger);
}

.username-status.is-checking {
    color: var(--text-muted);
}

/* الشروط */
.auth-terms {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2, 8px);
    color: var(--text-secondary);
    font-size: var(--text-label);
    line-height: var(--line-height-normal);
    cursor: pointer;
}

.auth-terms input {
    margin-block-start: 4px;
    accent-color: var(--primary);
}

.auth-terms a {
    color: var(--primary);
    text-decoration: none;
}

.auth-terms a:hover {
    text-decoration: underline;
}

/* الأزرار */
.auth-submit {
    inline-size: 100%;
    block-size: var(--input-height, 44px);
    min-block-size: var(--input-height, 44px);
    border: 1px solid var(--primary);
    border-radius: var(--input-radius, 9px);
    background: var(--primary);
    color: var(--text-on-primary);
    font: inherit;
    font-size: var(--text-body);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition:
        background var(--transition-fast, .15s) ease,
        border-color var(--transition-fast, .15s) ease,
        transform var(--transition-fast, .15s) ease;
}

.auth-submit:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.auth-submit:active {
    transform: translateY(1px);
}

.auth-submit:disabled {
    opacity: var(--disabled-opacity, .58);
    cursor: wait;
}

.auth-login,
.resend-code {
    margin-block-start: var(--space-5, 20px);
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-label);
}

.auth-login a,
.resend-code a {
    margin-inline-start: 4px;
    color: var(--primary);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
}

.auth-login a:hover,
.resend-code a:hover {
    text-decoration: underline;
}

.verification-resend {
    min-block-size: 24px;
}

.verification-resend strong {
    margin-inline-start: 4px;
    color: var(--primary);
    font-weight: var(--font-weight-bold);
    font-variant-numeric: tabular-nums;
}

.verification-resend [hidden] {
    display: none !important;
}

.password-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3, 12px);
}

.password-label a {
    color: var(--primary);
    font-size: var(--text-label);
    font-weight: var(--font-weight-medium);
    text-decoration: none;
}

/* الجوال */

/* إكمال الحساب: حقل واحد في كل صف */
#completeProfileForm .auth-complete-grid {
    grid-template-columns: minmax(0, 1fr);
}

/* حقول الموقع: السهم داخل الحقل بعيدًا عن زر البحث */
#completeProfileForm .auth-select-wrap:has(.alamna-location-control)::after {
    display: none;
}

#completeProfileForm .auth-select-wrap .alamna-location-control {
    gap: var(--space-3, 12px);
}

#completeProfileForm .auth-select-wrap .alamna-location-control > select {
    grid-column: 1;
    grid-row: 1;
    appearance: none;
    -webkit-appearance: none;
    padding-inline-end: 40px;
    min-inline-size: 0;
}

#completeProfileForm .auth-select-wrap .alamna-location-control > .alamna-location-search-btn {
    grid-column: 2;
    grid-row: 1;
    justify-content: center;
    text-align: center;
}

#completeProfileForm .auth-select-wrap .alamna-location-control > .alamna-location-search-btn > :is(svg, i) {
    display: none;
}

#completeProfileForm .auth-select-wrap .alamna-location-control > .alamna-location-search-btn > span {
    text-align: center;
}

#completeProfileForm .auth-select-wrap .alamna-location-control::after {
    content: '';
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
    align-self: center;
    inline-size: 7px;
    block-size: 7px;
    margin-inline-end: 18px;
    border-inline-end: 2px solid var(--text-muted);
    border-block-end: 2px solid var(--text-muted);
    transform: translateY(-2px) rotate(45deg);
    pointer-events: none;
    z-index: 1;
}

/* البحث عن المستكشف الداعي */
#completeProfileForm .auth-inviter-picker {
    position: relative;
}

#completeProfileForm .auth-inviter-results {
    position: absolute;
    z-index: 20;
    inset-block-start: calc(100% + 4px);
    inset-inline: 0;
    max-block-size: 230px;
    overflow-y: auto;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--input-radius, 9px);
    box-shadow: var(--shadow-md);
}

#completeProfileForm .auth-inviter-results[hidden] {
    display: none;
}

#completeProfileForm .auth-inviter-option {
    display: block;
    inline-size: 100%;
    padding: 11px 12px;
    background: transparent;
    border: 0;
    border-radius: var(--input-radius, 9px);
    color: var(--text-primary);
    font: inherit;
    text-align: start;
    direction: ltr;
    cursor: pointer;
}

#completeProfileForm .auth-inviter-option:hover,
#completeProfileForm .auth-inviter-option[aria-selected="true"] {
    background: var(--primary-light);
    color: var(--primary);
}

#completeProfileForm .auth-inviter-status:empty {
    display: none;
}

@media (max-width: 700px) {
    /* إظهار نص بحث داخل خطوة إكمال الحساب على الجوال */
    #completeProfileForm .auth-select-wrap .alamna-location-control {
        grid-template-columns: minmax(0, 1fr) 78px;
        gap: var(--space-3, 12px);
    }

    #completeProfileForm .auth-select-wrap .alamna-location-control > .alamna-location-search-btn {
        inline-size: 78px;
        min-inline-size: 78px;
        padding-inline: 8px;
        justify-content: center;
    }

    #completeProfileForm .auth-select-wrap .alamna-location-control > .alamna-location-search-btn > span {
        display: inline;
        text-align: center;
    }

    .auth-page {
        align-items: flex-start;
        padding:
            max(14px, env(safe-area-inset-top))
            12px
            max(30px, env(safe-area-inset-bottom));
    }

    .auth-card {
        width: min(100%, 390px);
        margin-inline: auto;
        padding: 18px 15px;
        border-radius: var(--radius-lg, 16px);
    }

    .auth-card-narrow {
        max-width: 390px;
    }

    .auth-card-wide {
        max-width: 390px;
    }

    .auth-topline {
        gap: var(--space-2, 8px);
        margin-block-end: var(--space-4, 16px);
    }

    .auth-logo-horizontal img {
        inline-size: min(148px, 39vw);
        max-block-size: 52px;
    }

    .auth-top-actions {
        gap: 5px;
    }

    .auth-theme-switch {
        padding: 2px;
    }

    .auth-theme-switch button {
        inline-size: 27px;
        block-size: 27px;
    }

    .auth-theme-switch svg {
        inline-size: 14px;
        block-size: 14px;
    }

    .auth-language-switch button {
        min-block-size: 31px;
        padding-inline: 9px;
    }

    .auth-progress {
        margin-block-end: var(--space-3, 12px);
    }

    .auth-heading {
        margin-block-end: var(--space-3, 12px);
    }

    .auth-heading h1 {
        font-size: var(--font-size-xl);
    }

    .auth-form,
    .auth-grid {
        gap: var(--space-3, 12px);
    }

    .auth-card-narrow .auth-grid {
        grid-template-columns: 1fr;
    }

    .auth-card-wide .auth-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .auth-card-wide .auth-field-wide-mobile {
        grid-column: 1 / -1;
    }

    .auth-field {
        gap: 5px;
    }

    .auth-field input,
    .auth-select-wrap select,
    .auth-submit {
        block-size: 46px;
        min-block-size: 46px;
        font-size: var(--font-size-md);
    }

    .auth-privacy-note,
    .auth-errors,
    .auth-success {
        margin-block-end: var(--space-3, 12px);
        padding: 10px 12px;
    }

    .auth-login,
    .resend-code {
        margin-block-start: var(--space-4, 16px);
    }
}

@media (max-width: 360px) {
    .auth-card-wide .auth-grid {
        grid-template-columns: 1fr;
    }

    .auth-card-wide .auth-field-wide-mobile {
        grid-column: auto;
    }

    .auth-logo-horizontal img {
        inline-size: min(128px, 38vw);
    }
}

/* علِّمنا R19.1 — استعادة كلمة المرور */
.auth-submit-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-decoration: none;
    box-sizing: border-box;
}
.auth-submit-link:hover {
    text-decoration: none;
}

