@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&family=Tajawal:wght@500;600;700;800&display=swap");

:root {
    --navy: #0A1D38;
    --gold: #C29447;
    --gold-dark: #B1843D;
    --white: #FFFFFF;
    --input-bg: #F7F9FB;
    --border: #E0E3E5;
    --text: #00030C;
    --muted: #44474D;
    --placeholder: #C5C6CE;
    --success: #16803C;
    --danger: #C81E1E;
}

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

html {
    direction: rtl;
    min-height: 100%;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    direction: rtl;
    background: #F8FAFC;
    color: var(--text);
    font-family: "Cairo", sans-serif;
    line-height: 1.5;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

/* =========================================================
   HOME
   ========================================================= */

.home-button {
    position: fixed;
    top: 24px;
    left: 24px;
    z-index: 20;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--navy);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 50%;
    box-shadow: 0 6px 18px rgba(10, 29, 56, 0.08);
    text-decoration: none;
    transition: 180ms ease;
}

.home-button svg {
    width: 20px;
    height: 20px;
}

.home-button:hover {
    color: var(--gold);
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(10, 29, 56, 0.12);
}

/* =========================================================
   PAGE / CARD
   ========================================================= */

.auth-page {
    width: 100%;
    min-height: 100vh;
    padding: 80px 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    box-sizing: border-box;
    width: 840px;
    max-width: 840px;
    height: 547px;
    min-height: 540px;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    padding: 0;
    isolation: isolate;
    overflow: hidden;
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 10px 30px rgba(10, 29, 56, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 24px;
}

/* LOGIN: navy left, white right.
   SIGNUP: white left, navy right. */
.auth-card.signup-mode {
    direction: ltr;
    height: 626px;
    min-height: 626px;
}

.auth-card:not(.signup-mode) {
    direction: ltr;
}

/* =========================================================
   BRANDING PANEL
   ========================================================= */

.branding-panel {
    direction: rtl;
    order: 0;
    position: relative;
    width: 50%;
    height: 100%;
    flex: 1 1 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    isolation: isolate;
    overflow: hidden;
    background: var(--navy);
    color: var(--white);
}

.auth-card:not(.signup-mode) .branding-panel {
    order: 0;
}

.auth-card.signup-mode .branding-panel {
    order: 1;
}

.branding-content {
    width: 315.7px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
}

.branding-logo-wrap {
    width: 114px;
    height: 113px;
    padding-bottom: 32px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.branding-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    display: block;
}

.branding-panel h2 {
    width: 100%;
    margin: 0;
    padding: 0 0 16px;
    color: #FFFFFF;
    font-family: "Tajawal", sans-serif;
    font-size: 30px;
    line-height: 36px;
    font-weight: 700;
    text-align: center;
}

.branding-panel p {
    width: 100%;
    max-width: 285px;
    min-height: 52px;
    margin: 0 0 32px;
    color: rgba(182, 199, 234, 0.8);
    font-family: "Cairo", sans-serif;
    font-size: 16px;
    line-height: 26px;
    font-weight: 400;
    text-align: center;
}

.switch-button {
    box-sizing: border-box;
    width: 181px;
    height: 52px;
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--gold);
    border-radius: 9999px;
    background: transparent;
    color: var(--gold);
    box-shadow: 0 0 15px rgba(194, 148, 71, 0.1);
    font-size: 16px;
    line-height: 24px;
    font-weight: 400;
    transition: 180ms ease;
}

.switch-button:hover {
    background: rgba(194, 148, 71, 0.08);
    transform: translateY(-1px);
}

.branding-glow {
    position: absolute;
    width: 256px;
    height: 256px;
    right: 81.5px;
    top: 473px;
    background: #C29447;
    mix-blend-mode: screen;
    opacity: 0.3;
    filter: blur(40px);
    border-radius: 9999px;
    z-index: 1;
    pointer-events: none;
}

/* =========================================================
   FORM PANEL
   ========================================================= */

.form-panel {
    direction: rtl;
    order: 1;
    position: relative;
    width: 50%;
    height: 100%;
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    padding: 40px;
    background: #FFFFFF;
    overflow: hidden;
}

.auth-card.signup-mode .form-panel {
    order: 0;
}

.auth-heading {
    width: 100%;
    padding-bottom: 32px;
}

.auth-heading h1 {
    margin: 0 0 8px;
    color: var(--navy);
    font-family: "Tajawal", sans-serif;
    font-size: 26px;
    line-height: 33px;
    font-weight: 700;
    text-align: right;
}

.auth-heading p {
    margin: 0;
    color: var(--muted);
    font-family: "Cairo", sans-serif;
    font-size: 14px;
    line-height: 24px;
    font-weight: 400;
    text-align: right;
}

.form-panel::before {
    content: "";
    position: absolute;
    width: 128px;
    height: 128px;
    right: 0;
    top: 0;
    background: radial-gradient(
        70.71% 70.71% at 50% 50%,
        rgba(10, 29, 56, 0.05) 0%,
        rgba(10, 29, 56, 0) 70%
    );
    border-radius: 0 0 0 9999px;
    pointer-events: none;
}

/* =========================================================
   FORMS
   ========================================================= */

.auth-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: relative;
    z-index: 2;
}

.auth-form[hidden] {
    display: none !important;
}

.field {
    width: 100%;
    height: 50px;
}

.input-wrap {
    position: relative;
    width: 100%;
    height: 50px;
}

.input-wrap input {
    width: 100%;
    height: 50px;
    padding: 9px 40px 9px 44px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    background: var(--input-bg);
    color: var(--text);
    font-family: "Cairo", sans-serif;
    font-size: 16px;
    line-height: 30px;
    text-align: right;
    transition: 180ms ease;
}

.input-wrap input::placeholder {
    color: var(--placeholder);
    opacity: 1;
}

.input-wrap input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(194, 148, 71, 0.10);
    background: #FFFFFF;
}

.field-icon {
    position: absolute;
    right: 12px;
    top: 0;
    bottom: 0;
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(194, 148, 71, 0.67);
    z-index: 2;
    pointer-events: none;
}

.field-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.45;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.password-toggle {
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 30px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: #75777E;
    z-index: 3;
}

.password-toggle svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.password-toggle:hover {
    color: var(--gold);
}

.login-actions {
    width: 100%;
    height: 24px;
    margin-top: -2px;
    display: flex;
    direction: rtl;
    align-items: center;
    justify-content: space-between;
}

.forgot-password {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--gold);
    font-family: "Cairo", sans-serif;
    font-size: 14px;
    line-height: 20px;
    font-weight: 400;
}

.forgot-password:hover {
    text-decoration: underline;
}

.remember-me {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
    line-height: 24px;
    cursor: pointer;
}

.remember-me input,
.terms-row input {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    margin: 0;
    border: 1px solid #C5C6CE;
    border-radius: 4px;
    background: var(--input-bg);
    cursor: pointer;
    position: relative;
}

.remember-me input:checked,
.terms-row input:checked {
    background: var(--gold);
    border-color: var(--gold);
}

.remember-me input:checked::after,
.terms-row input:checked::after {
    content: "✓";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.submit-button {
    width: 100%;
    height: 48px;
    padding: 12px 16px;
    margin: 0;
    border: 0;
    border-radius: 9999px;
    background: var(--gold);
    box-shadow: 0 4px 14px rgba(194, 148, 71, 0.3);
    color: #FFFFFF;
    font-family: "Cairo", sans-serif;
    font-size: 16px;
    line-height: 24px;
    font-weight: 400;
    transition: 180ms ease;
}

.submit-button:hover {
    background: var(--gold-dark);
    transform: translateY(-1px);
}

.submit-button:disabled {
    cursor: wait;
    opacity: 0.65;
    transform: none;
}

.signup-form {
    gap: 16px;
}

.terms-row {
    width: 100%;
    min-height: 32px;
    margin-top: -4px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    line-height: 16px;
}

.terms-row a {
    color: var(--navy);
    font-weight: 500;
    text-decoration: underline;
}

/* =========================================================
   MESSAGES
   ========================================================= */

.message-box,
.modal-message {
    width: 100%;
    padding: 9px 12px;
    margin: 0 0 16px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 20px;
    position: relative;
    z-index: 4;
}

.message-box.error,
.modal-message.error {
    background: #FEF2F2;
    color: var(--danger);
    border: 1px solid #FECACA;
}

.message-box.success,
.modal-message.success {
    background: #F0FDF4;
    color: var(--success);
    border: 1px solid #BBF7D0;
}

/* =========================================================
   SOCIAL LOGIN
   ========================================================= */

.social-login {
    width: 100%;
    padding-top: 32px;
    position: relative;
    z-index: 2;
}

.social-divider {
    width: 100%;
    height: 20px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.social-divider::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: var(--border);
}

.social-divider span {
    position: relative;
    padding: 0 16px;
    background: #FFFFFF;
    color: var(--muted);
    font-size: 14px;
    line-height: 20px;
}

.social-buttons {
    width: 100%;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
}

.social-button {
    width: 48px;
    height: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--input-bg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: 180ms ease;
}

.social-button svg {
    width: 24px;
    height: 24px;
}

.social-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(10, 29, 56, 0.10);
}

/* =========================================================
   MODALS
   ========================================================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 29, 56, 0.52);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    position: relative;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 34px 34px 30px;
    background: #FFFFFF;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(10, 29, 56, 0.2);
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 12px;
    left: 15px;
    width: 32px;
    height: 32px;
    border: 0;
    background: #EEF0F2;
    color: #4B4F55;
    border-radius: 50%;
    font-size: 21px;
    line-height: 1;
}

.modal-icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(194, 148, 71, 0.13);
    color: var(--gold);
    border-radius: 50%;
    font-size: 23px;
}

.modal h2 {
    margin: 0;
    color: var(--navy);
    font-family: "Tajawal", sans-serif;
    font-size: 24px;
}

.modal p {
    margin: 8px auto 22px;
    color: var(--muted);
    font-size: 12px;
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 16px;
    text-align: right;
}

.modal-field label {
    color: var(--navy);
    font-size: 13px;
    font-weight: 600;
}

.modal-field input {
    width: 100%;
    height: 48px;
    padding: 0 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    outline: none;
}

.modal-field input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(194, 148, 71, 0.12);
}

.code-inputs {
    display: flex;
    direction: ltr;
    justify-content: center;
    gap: 8px;
    margin: 20px 0;
}

.code-inputs input {
    width: 48px;
    height: 54px;
    border: 1px solid var(--border);
    border-radius: 10px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--navy);
    outline: none;
}

.code-inputs input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(194, 148, 71, 0.12);
}

.resend-button {
    margin-top: 12px;
    border: 0;
    background: transparent;
    color: var(--gold);
    font-size: 12px;
    font-weight: 700;
}

.reset-step[hidden] {
    display: none !important;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {
    .auth-page {
        padding: 72px 24px 40px;
    }

    .auth-card {
        width: 100%;
        max-width: 700px;
        height: auto;
        min-height: 0;
    }

    .branding-panel,
    .form-panel {
        width: 50%;
        min-height: 560px;
    }

    .form-panel {
        padding: 32px;
    }

    .branding-panel {
        padding: 32px;
    }

    .branding-panel h2 {
        font-size: 25px;
    }

    .branding-panel p {
        font-size: 14px;
    }
}

@media (max-width: 700px) {
    .home-button {
        top: 16px;
        left: 16px;
        width: 40px;
        height: 40px;
    }

    .auth-page {
        padding: 72px 16px 24px;
        align-items: flex-start;
    }

    .auth-card,
    .auth-card.signup-mode {
        flex-direction: column;
        width: 100%;
        max-width: 500px;
        height: auto;
        min-height: 0;
        border-radius: 20px;
    }

    .branding-panel,
    .auth-card.signup-mode .branding-panel,
    .form-panel,
    .auth-card.signup-mode .form-panel {
        order: initial;
        width: 100%;
        min-height: 0;
    }

    .branding-panel {
        min-height: 260px;
        padding: 28px 24px;
    }

    .branding-logo-wrap {
        width: 90px;
        height: 70px;
        padding-bottom: 15px;
    }

    .branding-logo {
        width: 58px;
        height: 58px;
    }

    .branding-panel h2 {
        padding-bottom: 10px;
        font-size: 23px;
        line-height: 30px;
    }

    .branding-panel p {
        margin-bottom: 20px;
        font-size: 13px;
        line-height: 22px;
    }

    .switch-button {
        width: 180px;
        height: 46px;
        padding: 10px 24px;
        font-size: 14px;
    }

    .branding-glow {
        width: 180px;
        height: 180px;
        right: 50%;
        top: auto;
        bottom: -90px;
        transform: translateX(50%);
    }

    .form-panel {
        padding: 30px 24px 28px;
    }

    .auth-heading {
        padding-bottom: 24px;
    }

    .auth-heading h1 {
        font-size: 24px;
    }

    .auth-heading p {
        font-size: 13px;
    }

    .social-login {
        padding-top: 26px;
    }
}

@media (max-width: 420px) {
    .auth-page {
        padding-left: 10px;
        padding-right: 10px;
    }

    .form-panel {
        padding: 26px 18px 24px;
    }

    .branding-panel {
        padding-left: 18px;
        padding-right: 18px;
    }

    .login-actions {
        gap: 10px;
    }

    .code-inputs {
        gap: 5px;
    }

    .code-inputs input {
        width: 42px;
        height: 50px;
    }
}

@media (max-height: 700px) and (min-width: 701px) {
    .auth-page {
        padding-top: 40px;
        padding-bottom: 40px;
    }

    .auth-card {
        height: 540px;
    }
}
