:root {
    --auth-bg-deep: #07111f;
    --auth-bg-mid: #0c2036;
    --auth-surface: rgba(13, 29, 48, 0.92);
    --auth-surface-soft: rgba(255, 255, 255, 0.045);
    --auth-border: rgba(148, 163, 184, 0.18);
    --auth-text: #f8fafc;
    --auth-muted: #aebdce;
    --auth-primary: #42a5f5;
    --auth-primary-strong: #1976d2;
    --auth-warning: #f59e0b;
    --auth-radius: 1.35rem;
}

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

html {
    min-width: 320px;
    min-height: 100%;
    background: var(--auth-bg-deep);
}

body.auth-page {
    min-height: 100vh;
    margin: 0;
    color: var(--auth-text);
    font-family: "Noto Sans Arabic", "Vazirmatn", Tahoma, "Segoe UI", Arial, sans-serif;
    background:
        radial-gradient(circle at 12% 12%, rgba(25, 118, 210, 0.24), transparent 34rem),
        radial-gradient(circle at 88% 82%, rgba(14, 165, 233, 0.14), transparent 32rem),
        linear-gradient(145deg, var(--auth-bg-deep), var(--auth-bg-mid));
}

body.auth-page::before {
    position: fixed;
    inset: 0;
    z-index: 0;
    content: "";
    pointer-events: none;
    opacity: 0.2;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, black, transparent 82%);
}

.auth-shell {
    position: relative;
    z-index: 1;
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: clamp(1rem, 4vw, 3.5rem);
}

.auth-container {
    width: 100%;
    max-width: 620px;
    padding: 0;
}

.auth-card {
    position: relative;
    overflow: hidden;
    color: var(--auth-text);
    border-radius: var(--auth-radius);
    background: var(--auth-surface);
    box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(18px);
}

.auth-card__accent {
    height: 4px;
    background: linear-gradient(90deg, #38bdf8, #2563eb, #8b5cf6);
}

[dir="rtl"] .auth-card__accent {
    background: linear-gradient(270deg, #38bdf8, #2563eb, #8b5cf6);
}

.auth-card__accent--warning {
    background: linear-gradient(90deg, #fbbf24, #f97316, #ef4444);
}

[dir="rtl"] .auth-card__accent--warning {
    background: linear-gradient(270deg, #fbbf24, #f97316, #ef4444);
}

.auth-card .card-body {
    padding: clamp(1.35rem, 4vw, 2.5rem);
}

.auth-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.auth-brand {
    display: grid;
    width: 3.5rem;
    height: 3.5rem;
    flex: 0 0 3.5rem;
    place-items: center;
    color: #dbeafe;
    border: 1px solid rgba(96, 165, 250, 0.35);
    border-radius: 1rem;
    background: linear-gradient(145deg, rgba(37, 99, 235, 0.35), rgba(14, 165, 233, 0.12));
}

.auth-brand .material-icons-outlined {
    font-size: 1.75rem;
}

.auth-eyebrow {
    color: #7dd3fc;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.auth-title {
    color: var(--auth-text);
    font-size: clamp(1.65rem, 5vw, 2.15rem);
    font-weight: 750;
    line-height: 1.25;
}

.auth-subtitle,
.form-hint,
.session-card__text {
    color: var(--auth-muted);
    font-size: 0.94rem;
    line-height: 1.75;
}

.auth-messages {
    display: grid;
    gap: 0.65rem;
    margin-top: 1.35rem;
}

.auth-messages .alert {
    padding: 0.8rem 1rem;
    border-radius: 0.85rem;
    font-size: 0.9rem;
}

.session-card {
    margin-top: 1.5rem;
    padding: 1.1rem;
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 1rem;
    background: linear-gradient(145deg, rgba(14, 165, 233, 0.1), rgba(37, 99, 235, 0.055));
}

.session-card__heading {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
}

.session-card__icon {
    margin-top: 0.05rem;
    color: #67e8f9;
    font-size: 1.55rem;
}

.session-card__title,
.form-title {
    color: var(--auth-text);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.5;
}

.session-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.session-meta__item {
    min-width: 0;
    padding: 0.75rem;
    border: 1px solid var(--auth-border);
    border-radius: 0.8rem;
    background: rgba(2, 6, 23, 0.22);
}

.session-meta dt {
    margin-bottom: 0.45rem;
    color: var(--auth-muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.auth-badge {
    max-width: 100%;
    overflow: hidden;
    padding: 0.48rem 0.65rem;
    text-overflow: ellipsis;
    font-size: 0.78rem;
    font-weight: 650;
    vertical-align: middle;
}

.auth-badge--user {
    color: #dbeafe;
    background: rgba(37, 99, 235, 0.3);
}

.auth-badge--role {
    color: #cffafe;
    background: rgba(8, 145, 178, 0.3);
}

.auth-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.auth-button {
    display: inline-flex;
    min-height: 2.85rem;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    border-radius: 0.8rem;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.35;
}

.auth-button .material-icons-outlined {
    flex: 0 0 auto;
    font-size: 1.2rem;
}

.auth-button.btn-primary {
    border-color: var(--auth-primary-strong);
    background: linear-gradient(135deg, var(--auth-primary), var(--auth-primary-strong));
    box-shadow: 0 0.6rem 1.4rem rgba(25, 118, 210, 0.22);
}

.auth-button.btn-primary:hover,
.auth-button.btn-primary:focus-visible {
    border-color: #64b5f6;
    background: linear-gradient(135deg, #64b5f6, #1e88e5);
}

.auth-button.btn-outline-light {
    color: #dce8f5;
    border-color: rgba(203, 213, 225, 0.34);
    background: rgba(255, 255, 255, 0.025);
}

.auth-button.btn-outline-light:hover,
.auth-button.btn-outline-light:focus-visible {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.09);
}

.login-form-section {
    margin-top: 1.65rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--auth-border);
}

.form-heading {
    margin-bottom: 1rem;
}

.auth-form {
    display: grid;
    gap: 1rem;
}

.auth-form .form-label {
    margin-bottom: 0.45rem;
    color: #dbe7f3;
    font-size: 0.83rem;
    font-weight: 650;
}

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

.auth-input-group > .material-icons-outlined {
    position: absolute;
    top: 50%;
    inset-inline-start: 0.9rem;
    z-index: 2;
    color: #8fa6bc;
    font-size: 1.25rem;
    transform: translateY(-50%);
    pointer-events: none;
}

.auth-input-group .form-control {
    min-height: 3.1rem;
    padding-inline: 3rem 1rem;
    color: var(--auth-text);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 0.85rem;
    background: rgba(2, 6, 23, 0.36);
    font-size: 0.92rem;
    text-align: start;
}

.auth-input-group .form-control::placeholder {
    color: #71869b;
    opacity: 1;
}

.auth-input-group .form-control:focus {
    color: var(--auth-text);
    border-color: rgba(66, 165, 245, 0.82);
    background: rgba(2, 6, 23, 0.52);
    box-shadow: 0 0 0 0.22rem rgba(66, 165, 245, 0.13);
}

.auth-submit {
    width: 100%;
    margin-top: 0.25rem;
}

.access-denied-card {
    max-width: 580px;
    margin-inline: auto;
}

.denied-icon {
    position: relative;
    display: inline-grid;
    width: 6rem;
    height: 6rem;
    margin-bottom: 1.1rem;
    place-items: center;
    color: #fed7aa;
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.18), rgba(249, 115, 22, 0.055));
}

.denied-icon__shield {
    font-size: 4rem;
}

.denied-icon__lock {
    position: absolute;
    top: 50%;
    left: 50%;
    color: #172033;
    font-size: 1.55rem;
    transform: translate(-50%, -47%);
}

.denied-code {
    color: #fbbf24;
    font-size: 0.84rem;
}

.denied-message {
    max-width: 29rem;
    margin-inline: auto;
    font-size: 1rem;
}

.denied-detail {
    max-width: 30rem;
    margin-top: 0.75rem;
    margin-inline: auto;
    color: #7f93a9;
    font-size: 0.8rem;
    line-height: 1.6;
}

.denied-actions {
    max-width: 28rem;
    margin-top: 1.75rem;
    margin-inline: auto;
}

[dir="ltr"] body.auth-page {
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

[dir="ltr"] .auth-eyebrow {
    letter-spacing: 0.16em;
}

@media (max-width: 575.98px) {
    .auth-shell {
        align-items: start;
        padding: 0.75rem;
    }

    .auth-card {
        margin-block: 0.75rem;
        border-radius: 1.05rem;
    }

    .auth-card .card-body {
        padding: 1.25rem;
    }

    .auth-header {
        align-items: flex-start;
    }

    .auth-brand {
        width: 3rem;
        height: 3rem;
        flex-basis: 3rem;
        border-radius: 0.85rem;
    }

    .session-meta,
    .auth-actions {
        grid-template-columns: 1fr;
    }

    .auth-button {
        width: 100%;
    }

    .denied-icon {
        width: 5rem;
        height: 5rem;
    }

    .denied-icon__shield {
        font-size: 3.35rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

/* Legacy Login presentation */
body.login-page {
    width: 100%;
    min-height: 100vh;
    color: #fff;
    font-family: Tahoma, "Segoe UI", Arial, sans-serif;
    background: #092756;
    background:
        radial-gradient(ellipse at 0% 100%, rgba(104, 128, 138, 0.4) 10%, rgba(138, 114, 76, 0) 40%),
        linear-gradient(to bottom, rgba(57, 173, 219, 0.25) 0%, rgba(42, 60, 87, 0.4) 100%),
        linear-gradient(135deg, #670d10 0%, #092756 100%);
}

body.login-page::before {
    content: none;
}

.login-page .auth-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1rem;
}

.login-page .auth-container {
    width: 300px;
    max-width: 100%;
}

.login {
    width: 300px;
    max-width: 100%;
}

.login h1 {
    margin: 0 0 1.25rem;
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-align: center;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.login input:not([type="hidden"]) {
    width: 100%;
    margin-bottom: 10px;
    padding: 10px;
    color: #fff;
    border: 1px solid rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    outline: none;
    background: rgba(0, 0, 0, 0.3);
    box-shadow: inset 0 -5px 45px rgba(100, 100, 100, 0.2), 0 1px 1px rgba(255, 255, 255, 0.2);
    font-size: 13px;
    text-align: start;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.5s ease;
}

.login input:not([type="hidden"])::placeholder {
    color: rgba(255, 255, 255, 0.72);
}

.login input:not([type="hidden"]):focus {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: inset 0 -5px 45px rgba(100, 100, 100, 0.4), 0 1px 1px rgba(255, 255, 255, 0.2);
}

.login .btn {
    display: inline-block;
    margin-bottom: 0;
    padding: 4px 10px;
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 4px;
    background-color: #f5f5f5;
    background-image: linear-gradient(to bottom, #fff, #e6e6e6);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
    font-size: 13px;
    line-height: 18px;
    text-align: center;
    text-decoration: none;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
    vertical-align: middle;
    cursor: pointer;
}

.login .btn-large {
    padding: 9px 14px;
    border-radius: 5px;
    font-size: 15px;
    line-height: normal;
}

.login .btn-block {
    display: block;
    width: 100%;
}

.login .btn-primary,
.login .btn-primary:hover,
.login .btn-primary:focus {
    color: #fff;
    border-color: #3762bc;
    background-color: #4a77d4;
    background-image: linear-gradient(to bottom, #6eb6de, #4a77d4);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.5);
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.4);
}

.login .btn-secondary,
.login .btn-secondary:hover,
.login .btn-secondary:focus {
    color: #333;
    border-color: #d6d6d6;
    background-color: #e6e6e6;
    background-image: linear-gradient(to bottom, #fff, #e6e6e6);
}

.login ul.messages {
    margin: 15px 0;
    padding: 0;
    list-style: none;
}

.login ul.messages li {
    margin-bottom: 10px;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-align: start;
}

.login ul.messages li.success {
    color: #1a7f37;
    border: 1px solid #1a7f37;
    background-color: #e6ffed;
}

.login ul.messages li.error {
    color: #c00;
    border: 1px solid #c00;
    background-color: #ffe6e6;
}

.login ul.messages li.warning {
    color: #960;
    border: 1px solid #960;
    background-color: #fff7e6;
}

.login ul.messages li.info {
    color: #004085;
    border: 1px solid #004085;
    background-color: #e6f0ff;
}

.login-session {
    margin-bottom: 15px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.22);
}

.login-session h2 {
    margin: 0 0 10px;
    color: #fff;
    font-size: 14px;
    text-align: center;
}

.login-session-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: 10px;
}

.login-badge {
    overflow: hidden;
    max-width: 100%;
    padding: 5px 8px;
    color: #fff;
    background: rgba(74, 119, 212, 0.72);
    text-overflow: ellipsis;
}

.login-session .btn + .btn {
    margin-top: 8px;
}

[dir="ltr"] body.login-page {
    font-family: "Open Sans", "Segoe UI", Arial, sans-serif;
}

@media (max-width: 360px) {
    .login-page .auth-shell {
        padding: 0.75rem;
    }
}
