/* 1. Variables */
.auth-page {
    --motsa-navy: #071a3d;
    --motsa-navy-dark: #04122d;
    --motsa-blue: #173b8f;
    --motsa-blue-light: #2f65cf;
    --motsa-red: #e30620;
    --motsa-background: #f4f6f9;
    --motsa-surface: #ffffff;
    --motsa-border: #e3e8ef;
    --motsa-text: #172033;
    --motsa-muted: #697386;
    --motsa-success: #16805c;
    --auth-control-border: #cfd7e3;
    --auth-focus-ring: rgba(227, 6, 32, 0.13);
    --auth-panel-shadow: 0 18px 44px rgba(7, 26, 61, 0.1);
}

/* 2. Layout */
.auth-page,
.auth-page * {
    box-sizing: border-box;
}

.auth-page {
    display: grid;
    grid-template-columns: minmax(0, 43fr) minmax(0, 57fr);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    color: var(--motsa-text);
    background: var(--motsa-background);
    font-family: "Heebo", sans-serif;
}

/* 3. Authentication panel */
.auth-panel {
    position: relative;
    z-index: 0;
    min-width: 0;
    background:
        radial-gradient(circle at 12% 8%, rgba(47, 101, 207, 0.055), transparent 32%),
        var(--motsa-background);
}

.auth-panel__inner {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: min(100%, 690px);
    min-height: 100%;
    margin-inline: auto;
    padding: clamp(26px, 3.6vh, 48px) clamp(28px, 4vw, 74px) 24px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 22px;
    width: 100%;
}

.auth-brand__logo {
    display: block;
    width: clamp(190px, 17vw, 260px);
    height: auto;
    object-fit: contain;
}

.auth-brand__divider {
    width: 1px;
    height: 46px;
    background: #aeb8c7;
}

.auth-brand__edition {
    color: #46536a;
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.auth-panel__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding-block: clamp(18px, 3vh, 34px);
}

.auth-powered {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-top: clamp(18px, 2.6vh, 30px);
    color: var(--motsa-muted);
    font-size: 0.83rem;
    line-height: 1.2;
}

.auth-powered img {
    display: block;
    width: 160px;
    height: auto;
    object-fit: contain;
}

.auth-footer {
    color: var(--motsa-muted);
    font-size: 0.78rem;
    line-height: 1.4;
    text-align: center;
}

/* 4. Form */
.auth-card {
    width: min(100%, 470px);
    padding: clamp(28px, 3.7vh, 42px) clamp(26px, 3.2vw, 40px) 28px;
    background: var(--motsa-surface);
    border: 1px solid var(--motsa-border);
    border-radius: 15px;
    box-shadow: var(--auth-panel-shadow);
}

.auth-card__header {
    margin-bottom: 26px;
    text-align: center;
}

.auth-card__title {
    margin: 0 0 7px;
    color: var(--motsa-navy);
    font-size: clamp(1.55rem, 2.2vw, 1.85rem);
    font-weight: 700;
    line-height: 1.2;
}

.auth-card__description {
    margin: 0;
    color: var(--motsa-muted);
    font-size: 0.96rem;
    line-height: 1.45;
}

.auth-card--recovery .auth-card__description {
    max-width: 355px;
    margin-inline: auto;
}

.auth-card--reset {
    padding-top: clamp(25px, 3vh, 32px);
    padding-bottom: 23px;
}

.auth-card--reset .auth-card__header {
    margin-bottom: 21px;
}

.auth-card--reset .auth-card__description {
    max-width: 370px;
    margin-inline: auto;
}

.auth-form {
    display: grid;
    gap: 19px;
}

.auth-form--recovery {
    gap: 20px;
}

.auth-form--reset {
    gap: 15px;
}

.auth-form--reset .auth-back-link {
    margin-top: -3px;
}

.auth-form--reset .auth-security {
    margin-top: -3px;
}

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: -4px 0 2px;
    padding: 12px 14px;
    color: var(--motsa-success);
    font-size: 0.84rem;
    line-height: 1.4;
    background: rgba(22, 128, 92, 0.08);
    border: 1px solid rgba(22, 128, 92, 0.25);
    border-radius: 8px;
}

.auth-alert svg {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-field {
    display: grid;
    gap: 7px;
}

.auth-field__label {
    margin: 0;
    color: var(--motsa-text);
    font-size: 0.9rem;
    font-weight: 600;
}

.auth-field__control {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 49px;
    overflow: hidden;
    background: var(--motsa-surface);
    border: 1px solid var(--auth-control-border);
    border-radius: 7px;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.auth-field__control:focus-within {
    border-color: var(--motsa-red);
    box-shadow: 0 0 0 3px var(--auth-focus-ring);
}

.auth-field__control.is-invalid {
    border-color: var(--motsa-red);
}

.auth-field__icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin-left: 15px;
    color: var(--motsa-navy);
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-field__input {
    width: 100%;
    min-width: 0;
    min-height: 47px;
    padding: 10px 15px;
    color: var(--motsa-text);
    font: inherit;
    font-size: 0.94rem;
    line-height: 1.4;
    background: transparent;
    border: 0;
    outline: 0;
}

.auth-field__control--password .auth-field__input {
    padding-right: 4px;
}

.auth-field__input:-webkit-autofill,
.auth-field__input:-webkit-autofill:hover,
.auth-field__input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--motsa-text);
    box-shadow: 0 0 0 1000px var(--motsa-surface) inset;
    transition: background-color 9999s ease-out;
}

.auth-password-toggle {
    display: grid;
    flex: 0 0 44px;
    place-items: center;
    width: 44px;
    min-height: 47px;
    padding: 0;
    color: var(--motsa-navy);
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.auth-password-toggle__icon {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-password-toggle__icon[hidden] {
    display: none;
}

.auth-field__error {
    margin: 0;
    color: var(--motsa-red);
    font-size: 0.8rem;
    line-height: 1.35;
}

.auth-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 25px;
}

.auth-check {
    display: flex;
    align-items: center;
    gap: 9px;
}

.auth-check__input {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--motsa-navy);
    cursor: pointer;
}

.auth-check__label,
.auth-recovery {
    color: var(--motsa-muted);
    font-size: 0.88rem;
    line-height: 1.35;
}

.auth-check__label {
    cursor: pointer;
}

.auth-recovery {
    color: var(--motsa-blue);
    font-weight: 500;
    text-decoration: none;
}

.auth-back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    margin-top: -5px;
    color: var(--motsa-blue);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
}

.auth-back-link svg {
    width: 19px;
    height: 19px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 160ms ease;
}

.auth-submit {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    width: 100%;
    min-height: 49px;
    margin-top: 3px;
    padding: 11px 17px 10px 22px;
    overflow: hidden;
    color: #ffffff;
    font: inherit;
    font-size: 0.97rem;
    font-weight: 600;
    line-height: 1.3;
    background: linear-gradient(115deg, var(--motsa-navy-dark), var(--motsa-navy));
    border: 0;
    border-bottom: 2px solid var(--motsa-red);
    border-radius: 7px;
    box-shadow: 0 8px 18px rgba(7, 26, 61, 0.18);
    cursor: pointer;
    transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.auth-submit__label {
    grid-column: 1 / -1;
    grid-row: 1;
    justify-self: center;
}

.auth-submit__arrow {
    grid-column: 2;
    grid-row: 1;
    width: 21px;
    height: 21px;
    color: var(--motsa-red);
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-submit__spinner {
    display: none;
    grid-column: 2;
    grid-row: 1;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: auth-spin 700ms linear infinite;
}

.auth-submit.is-loading .auth-submit__arrow {
    display: none;
}

.auth-submit.is-loading .auth-submit__spinner {
    display: block;
}

.auth-submit:disabled {
    cursor: wait;
    opacity: 0.82;
}

.auth-security {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 2px;
    color: var(--motsa-muted);
    font-size: 0.88rem;
}

.auth-security svg {
    width: 21px;
    height: 21px;
    color: #8794aa;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* 5. Corporate panel */
.auth-hero {
    position: relative;
    z-index: 1;
    min-width: 0;
    min-height: 100%;
    margin-left: max(-120px, -7.2vw);
    overflow: hidden;
    isolation: isolate;
    color: #ffffff;
    background: var(--motsa-navy-dark);
    clip-path: polygon(18% 0, 100% 0, 100% 100%, 0 100%);
}

.auth-hero__image,
.auth-hero__overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.auth-hero__image {
    z-index: -3;
    top: clamp(68px, 9vh, 86px);
    height: calc(100% - 42px);
    object-fit: cover;
    object-position: 68% center;
}

.auth-hero__overlay {
    z-index: -2;
    background:
        radial-gradient(ellipse 68% 37% at 27% 12%, rgba(4, 18, 45, 0.98) 0%, rgba(4, 18, 45, 0.9) 46%, rgba(4, 18, 45, 0.5) 73%, transparent 100%),
        linear-gradient(90deg, rgba(4, 18, 45, 0.55) 0%, rgba(4, 18, 45, 0.2) 39%, transparent 68%),
        linear-gradient(180deg, rgba(4, 18, 45, 0.08), rgba(4, 18, 45, 0.16));
}

.auth-hero__content {
    position: absolute;
    z-index: 1;
    top: clamp(72px, 9vh, 104px);
    right: clamp(36px, 4vw, 72px);
    width: min(45vw, 760px);
    padding: 0;
}

.auth-hero__title {
    margin: 0 0 15px;
    color: #ffffff;
    font-size: clamp(2.15rem, 3.35vw, 3.4rem);
    font-weight: 700;
    line-height: 1.04;
    letter-spacing: -0.025em;
    text-wrap: balance;
    text-shadow: 0 3px 16px rgba(0, 0, 0, 0.24);
}

.auth-hero__description {
    margin: 0;
    color: rgba(255, 255, 255, 0.92);
    font-size: clamp(1rem, 1.55vw, 1.32rem);
    line-height: 1.42;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.26);
}

/* 6. Decorative components */
.auth-brand-stripe {
    position: absolute;
    z-index: 2;
    inset: 0;
    background: var(--motsa-blue);
    clip-path: polygon(18% 0, calc(18% + 28px) 0, 28px 100%, 0 100%);
    pointer-events: none;
}

.auth-brand-stripe::after {
    position: absolute;
    inset: 0;
    background: var(--motsa-red);
    clip-path: polygon(
        calc(16.56% + 11px) 8%,
        calc(16.56% + 15px) 8%,
        calc(0.72% + 15px) 96%,
        calc(0.72% + 11px) 96%
    );
    content: "";
}

/* 7. States */
.auth-password-toggle:hover,
.auth-password-toggle:active {
    color: var(--motsa-blue-light);
    background: rgba(47, 101, 207, 0.07);
}

.auth-recovery:hover {
    color: var(--motsa-blue-light);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.auth-back-link:hover {
    color: var(--motsa-blue-light);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.auth-back-link:hover svg {
    transform: translateX(-2px);
}

.auth-submit:hover:not(:disabled) {
    background: linear-gradient(115deg, #061733, var(--motsa-blue));
    box-shadow: 0 10px 22px rgba(7, 26, 61, 0.26);
    transform: translateY(-1px);
}

.auth-submit:active:not(:disabled) {
    box-shadow: 0 5px 12px rgba(7, 26, 61, 0.2);
    transform: translateY(0);
}

/* 8. Accessibility */
.auth-page .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.auth-password-toggle:focus-visible,
.auth-check__input:focus-visible,
.auth-recovery:focus-visible,
.auth-back-link:focus-visible,
.auth-submit:focus-visible {
    outline: 3px solid var(--motsa-red);
    outline-offset: 3px;
}

@keyframes auth-spin {
    to { transform: rotate(360deg); }
}

/* 9. Responsive */
@media (max-width: 1199.98px) {
    .auth-page {
        grid-template-columns: minmax(0, 48fr) minmax(0, 52fr);
    }

    .auth-panel__inner {
        padding-inline: 38px;
    }

    .auth-brand__logo {
        width: 210px;
    }

    .auth-hero__image {
        object-position: 60% center;
    }

    .auth-hero__content {
        top: 62px;
        right: 32px;
        width: 43vw;
        padding: 0;
    }

    .auth-hero {
        margin-left: -48px;
        clip-path: polygon(14% 0, 100% 0, 100% 100%, 0 100%);
    }

    .auth-brand-stripe {
        clip-path: polygon(14% 0, calc(14% + 22px) 0, 22px 100%, 0 100%);
    }

    .auth-brand-stripe::after {
        clip-path: polygon(
            calc(12.88% + 9px) 8%,
            calc(12.88% + 13px) 8%,
            calc(0.56% + 13px) 96%,
            calc(0.56% + 9px) 96%
        );
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .auth-page {
        grid-template-columns: minmax(0, 62fr) minmax(0, 38fr);
    }

    .auth-panel__inner {
        padding-inline: 32px;
    }

    .auth-brand__logo {
        width: 190px;
    }

    .auth-brand__divider {
        height: 38px;
    }

    .auth-hero__image {
        top: clamp(58px, 8vh, 72px);
        height: calc(100% - 34px);
        object-position: 56% center;
    }

    .auth-hero__content {
        top: 82px;
        right: 18px;
        width: min(29vw, 290px);
        padding: 0;
    }

    .auth-hero {
        margin-left: -28px;
        clip-path: polygon(12% 0, 100% 0, 100% 100%, 0 100%);
    }

    .auth-brand-stripe {
        clip-path: polygon(12% 0, calc(12% + 18px) 0, 18px 100%, 0 100%);
    }

    .auth-brand-stripe::after {
        clip-path: polygon(
            calc(11.04% + 7px) 8%,
            calc(11.04% + 10px) 8%,
            calc(0.48% + 10px) 96%,
            calc(0.48% + 7px) 96%
        );
    }

    .auth-hero__title {
        font-size: 2.15rem;
    }

    .auth-hero__description {
        font-size: 1rem;
    }

}

@media (max-width: 767.98px) {
    .auth-page {
        display: block;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .auth-panel {
        min-height: 100vh;
        min-height: 100dvh;
    }

    .auth-panel__inner {
        display: flex;
        flex-direction: column;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        padding: 24px clamp(16px, 5vw, 24px) 20px;
    }

    .auth-brand {
        justify-content: center;
        gap: 15px;
    }

    .auth-brand__logo {
        width: min(48vw, 205px);
    }

    .auth-brand__divider {
        height: 34px;
    }

    .auth-brand__edition {
        font-size: 0.8rem;
    }

    .auth-panel__content {
        flex: 1 0 auto;
        justify-content: center;
        padding-block: 24px;
    }

    .auth-card {
        width: min(100%, 470px);
        padding: 27px 20px 24px;
        border-radius: 13px;
    }

    .auth-card--reset {
        padding-top: 25px;
    }

    .auth-card__header {
        margin-bottom: 22px;
    }

    .auth-powered {
        margin-top: 21px;
    }

    .auth-footer {
        flex: 0 0 auto;
    }

    .auth-hero {
        display: none;
    }
}

@media (max-width: 399.98px) {
    .auth-options {
        align-items: flex-start;
        flex-direction: column;
        gap: 11px;
    }

    .auth-powered img {
        width: 145px;
    }
}

@media (min-width: 768px) and (max-height: 800px) {
    .auth-panel__inner {
        padding-top: 20px;
        padding-bottom: 15px;
    }

    .auth-brand__logo {
        width: 180px;
    }

    .auth-brand__divider {
        height: 35px;
    }

    .auth-panel__content {
        padding-block: 12px;
    }

    .auth-card {
        padding-top: 24px;
        padding-bottom: 20px;
    }

    .auth-card__header {
        margin-bottom: 18px;
    }

    .auth-form {
        gap: 13px;
    }

    .auth-card--reset {
        padding-top: 19px;
        padding-bottom: 16px;
    }

    .auth-card--reset .auth-card__header {
        margin-bottom: 14px;
    }

    .auth-form--reset {
        gap: 10px;
    }

    .auth-form--reset .auth-field {
        gap: 4px;
    }

    .auth-powered {
        margin-top: 12px;
    }

    .auth-powered img {
        width: 135px;
    }

    .auth-hero__content {
        top: 48px;
    }

}

/* 10. Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .auth-field__control,
    .auth-submit {
        transition: none;
    }

    .auth-submit:hover:not(:disabled) {
        transform: none;
    }

    .auth-back-link svg {
        transition: none;
    }

    .auth-back-link:hover svg {
        transform: none;
    }

    .auth-submit__spinner {
        animation-duration: 1.4s;
    }
}
