/* RTL Support */
.rtl {
    direction: rtl;
    text-align: right;
}

:root {
    --auth-bg: #fff6e5;
    /* var(--co-yellowish) */
    --auth-primary: #C8102E;
    /* var(--co-red) */
    --auth-primary-hover: #a00d25;
    --auth-secondary: #0d0c22;
    /* var(--copyyek-black) */
    --auth-text: #363636;
    /* var(--black-text) */
    --auth-back: #f0e4cd;
    /* var(--co-back) */
    --auth-white: #ffffff;
    --auth-shadow: 0 10px 15px -3px rgba(13, 12, 34, 0.1), 0 4px 6px -2px rgba(13, 12, 34, 0.05);
}

.auth-page-container {
    min-height: 100vh;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--auth-bg);
    padding: 16px;
    box-sizing: border-box;
}

.custom-auth-container {
    width: 100%;
    max-width: 440px;
    background: var(--auth-back);
    border-radius: 2rem;
    box-shadow: var(--auth-shadow);
    padding: 40px;
    font-family: 'IRANSansX', sans-serif;
    position: relative;
    overflow: hidden;
    animation: authFadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

/* Ensure all inputs use the correct font and support Persian digits if possible via CSS */
.custom-auth-container input {
    font-family: 'IRANSansX', sans-serif !important;
    font-feature-settings: "ss01", "onum";
    /* Common features for Persian digits in some fonts */
}

@keyframes authFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.custom-auth-form h2,
.custom-auth-logged-in h2 {
    margin: 0 0 16px 0;
    color: var(--auth-primary);
    text-align: center;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.4;
}

.custom-auth-form p {
    color: var(--auth-text);
    text-align: center;
    margin-bottom: 32px;
    font-size: 14px;
    line-height: 1.8;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--auth-secondary);
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--auth-white);
    border: 1px solid rgba(13, 12, 34, 0.1);
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
    outline: none;
}

.form-group input:focus {
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 4px rgba(200, 16, 46, 0.1);
}

/* OTP Boxes Style */
.otp-boxes-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    direction: ltr;
    /* Boxes go left to right even in RTL */
    margin-bottom: 24px;
}

.otp-digit-input {
    width: 48px;
    height: 56px;
    text-align: center !important;
    font-size: 20px !important;
    font-weight: 700;
    border-radius: 12px !important;
    padding: 0 !important;
}

.error-message {
    color: var(--auth-primary);
    font-size: 13px;
    margin-top: 8px;
    margin-bottom: 16px;
    min-height: 18px;
    text-align: center;
    font-weight: 600;
    line-height: 1.6;
}

.btn-primary,
.btn-secondary {
    display: block;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 2rem;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'IRANSansX', sans-serif;
    text-align: center;
}

.btn-primary {
    background: var(--auth-primary);
    color: white;
    margin-bottom: 12px;
}

.btn-primary:hover {
    scale: 1.03;
    background: var(--auth-primary-hover);
}

.btn-primary:active {
    scale: 0.95;
}

.btn-secondary {
    background: var(--auth-secondary);
    color: white;
    margin-bottom: 12px;
}

.btn-secondary:hover {
    scale: 1.03;
}

.btn-secondary:active {
    scale: 0.95;
}

.status-message {
    text-align: center;
    font-size: 13px;
    margin-top: 16px;
    color: var(--auth-text);
    line-height: 1.6;
}

/* Transitions */
.form-transition {
    animation: formSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes formSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

/* Loading State */
.btn-primary.is-loading {
    color: transparent;
    position: relative;
    pointer-events: none;
}

.btn-primary.is-loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: authSpin 0.8s linear infinite;
}

@keyframes authSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Cancel Button */
.cancel-auth-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--auth-secondary);
    transition: color 0.2s;
}

.cancel-auth-btn:hover {
    color: var(--auth-primary);
}

.highlight-phone {
    color: var(--auth-primary);
    font-weight: 700;
}

.success-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

@media (max-width: 480px) {
    .custom-auth-container {
        padding: 32px 16px;
        border-radius: 1.5rem;
    }

    .otp-boxes-container {
        gap: 6px;
    }

    .otp-digit-input {
        width: 14%;
        /* Fluid width to fit even smaller screens */
        max-width: 48px;
        height: 52px;
        font-size: 18px !important;
    }
}

@media (max-width: 360px) {
    .otp-boxes-container {
        gap: 4px;
    }

    .otp-digit-input {
        height: 48px;
        font-size: 16px !important;
    }
}