:root {
    --auth-bg-light: #f8fafc;
    --auth-bg-dark: #0f172a;
    --auth-card-light: rgba(255, 255, 255, 0.96);
    --auth-card-dark: rgba(30, 41, 59, 0.96);
    --auth-border-light: #e2e8f0;
    --auth-border-dark: #334155;
    --auth-text-light: #0f172a;
    --auth-text-dark: #f8fafc;
    --auth-muted-light: #64748b;
    --auth-muted-dark: #94a3b8;
    --auth-primary: #6366f1;
    --auth-primary-hover: #4f46e5;
    --auth-success: #059669;
    --auth-danger: #dc2626;
    --auth-warning: #d97706;
    --auth-shadow: 0 24px 80px rgba(15, 23, 42, 0.16);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body.auth-body {
    margin: 0;
    font-family: Tajawal, sans-serif;
    color: var(--auth-text-light);
    background:
        radial-gradient(circle at top right, rgba(99, 102, 241, 0.16), transparent 28%),
        radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.12), transparent 24%),
        linear-gradient(180deg, #ffffff 0%, var(--auth-bg-light) 100%);
}

html.dark body.auth-body {
    color: var(--auth-text-dark);
    background:
        radial-gradient(circle at top right, rgba(99, 102, 241, 0.24), transparent 30%),
        radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.16), transparent 26%),
        linear-gradient(180deg, #020617 0%, var(--auth-bg-dark) 100%);
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.auth-shell {
    width: 100%;
    max-width: 460px;
    animation: auth-fade-up 0.45s ease-out;
}

.auth-card {
    background: var(--auth-card-light);
    border: 1px solid var(--auth-border-light);
    border-radius: 32px;
    box-shadow: var(--auth-shadow);
    backdrop-filter: blur(12px);
    padding: 32px 24px;
}

html.dark .auth-card {
    background: var(--auth-card-dark);
    border-color: var(--auth-border-dark);
}

.auth-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    margin-bottom: 28px;
}

.auth-logo-wrap {
    width: 84px;
    height: 84px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 26px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.16), rgba(99, 102, 241, 0.08));
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.12);
}

.auth-logo-wrap img,
.auth-logo-wrap span {
    width: 48px;
    height: 48px;
    display: block;
}

.auth-title {
    margin: 0;
    font-size: clamp(1.9rem, 4vw, 2.3rem);
    font-weight: 800;
    line-height: 1.2;
}

.auth-subtitle {
    margin: 0;
    color: var(--auth-muted-light);
    font-size: 0.98rem;
    line-height: 1.7;
}

html.dark .auth-subtitle {
    color: var(--auth-muted-dark);
}

.auth-alert {
    margin-bottom: 20px;
    padding: 14px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.6;
}

.auth-alert.error {
    background: rgba(220, 38, 38, 0.08);
    color: var(--auth-danger);
    border: 1px solid rgba(220, 38, 38, 0.18);
}

.auth-alert.success {
    background: rgba(5, 150, 105, 0.1);
    color: var(--auth-success);
    border: 1px solid rgba(5, 150, 105, 0.18);
}

.auth-alert.hidden {
    display: none;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-label {
    font-size: 0.92rem;
    font-weight: 700;
    color: #475569;
}

html.dark .auth-label {
    color: #cbd5e1;
}

.auth-input-wrap {
    position: relative;
}

.auth-input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: #94a3b8;
    pointer-events: none;
}

.auth-input {
    width: 100%;
    min-height: 56px;
    border: 1px solid var(--auth-border-light);
    border-radius: 20px;
    background: rgba(248, 250, 252, 0.92);
    color: var(--auth-text-light);
    padding: 16px 18px 16px 48px;
    font: inherit;
    line-height: 1.4;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.auth-input[type="text"],
.auth-input[type="email"],
.auth-input[type="password"],
.auth-input[type="tel"] {
    direction: rtl;
}

.auth-input.code {
    direction: ltr;
    text-align: center;
    letter-spacing: 0.45em;
    font-size: 1.85rem;
    font-weight: 800;
    padding-left: 18px;
}

html.dark .auth-input {
    background: rgba(15, 23, 42, 0.55);
    color: var(--auth-text-dark);
    border-color: var(--auth-border-dark);
}

.auth-input:focus {
    outline: none;
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
}

.auth-helper {
    margin: 0;
    color: var(--auth-muted-light);
    font-size: 0.82rem;
    line-height: 1.8;
    text-align: center;
}

html.dark .auth-helper {
    color: var(--auth-muted-dark);
}

.auth-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.auth-link {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 700;
}

.auth-link:hover {
    text-decoration: underline;
}

.auth-captcha-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.auth-captcha-box {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--auth-border-light);
    background: rgba(248, 250, 252, 0.92);
    border-radius: 18px;
    padding: 8px 10px;
}

html.dark .auth-captcha-box {
    border-color: var(--auth-border-dark);
    background: rgba(15, 23, 42, 0.55);
}

.auth-captcha-image {
    min-width: 120px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow: hidden;
}

.auth-icon-button {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.auth-icon-button:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--auth-primary);
}

.auth-icon-button:active {
    transform: rotate(180deg);
}

.auth-button,
.auth-secondary-button,
.auth-theme-toggle,
.auth-home-link {
    font: inherit;
}

.auth-button {
    width: 100%;
    min-height: 58px;
    border: 0;
    border-radius: 22px;
    background: linear-gradient(135deg, var(--auth-primary), var(--auth-primary-hover));
    color: #fff;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 18px 35px rgba(79, 70, 229, 0.22);
    transition: transform 0.2s ease, filter 0.2s ease;
}

.auth-button:hover {
    transform: translateY(-1px);
    filter: brightness(1.04);
}

.auth-button.secondary-success {
    background: linear-gradient(135deg, #059669, #10b981);
    box-shadow: 0 18px 35px rgba(5, 150, 105, 0.22);
}

.auth-secondary-action {
    display: block;
    margin-top: 4px;
    color: var(--auth-muted-light);
    text-decoration: none;
    text-align: center;
    font-size: 0.92rem;
    font-weight: 700;
}

html.dark .auth-secondary-action {
    color: var(--auth-muted-dark);
}

.auth-secondary-action:hover {
    color: var(--auth-primary);
}

.auth-divider {
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid rgba(148, 163, 184, 0.18);
    text-align: center;
}

.auth-divider p {
    margin: 0 0 10px;
    color: var(--auth-muted-light);
    font-weight: 700;
}

html.dark .auth-divider p {
    color: var(--auth-muted-dark);
}

.auth-meta {
    margin-top: 20px;
    text-align: center;
}

.auth-powered {
    margin: 0 0 16px;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}

.auth-home-link,
.auth-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(255, 255, 255, 0.82);
    color: #475569;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 700;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

html.dark .auth-home-link,
html.dark .auth-theme-toggle {
    background: rgba(30, 41, 59, 0.82);
    color: #cbd5e1;
    border-color: rgba(71, 85, 105, 0.7);
}

.auth-home-link:hover,
.auth-theme-toggle:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.22);
}

.auth-theme-row {
    margin-top: 18px;
    display: flex;
    justify-content: center;
}

.auth-center-note {
    text-align: center;
    margin-bottom: 8px;
}

@keyframes auth-fade-up {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 640px) {
    .auth-card {
        border-radius: 26px;
        padding: 24px 18px;
    }

    .auth-captcha-row {
        grid-template-columns: 1fr;
    }

    .auth-captcha-box {
        justify-content: space-between;
    }

    .auth-input.code {
        font-size: 1.5rem;
        letter-spacing: 0.28em;
    }
}
