/* --- Global Variables & Basic Reset --- */
:root {
    --primary-color-auth: #007bff;
    --secondary-color-auth: #2c3e50;
    --background-color-auth: #f0f2f5;
    --form-background-auth: #ffffff;
    --text-color-auth: #333;
    --text-light-auth: #777;
    --border-color-auth: #e0e0e0;
    --font-family-auth: "Cairo", sans-serif;
    --border-radius-auth: 8px;
    --success-color-auth: #28a745;
    --danger-color-auth: #dc3545;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: var(--font-family-auth);
    background-color: var(--background-color-auth);
    color: var(--text-color-auth);
    line-height: 1.7;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    direction: rtl;
}
.auth-container {
    display: flex;
    width: 100%;
    max-width: 900px;
    min-height: 550px;
    background-color: var(--form-background-auth);
    border-radius: var(--border-radius-auth);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Image Section */
.auth-image-section {
    flex: 1;
    background-image: url("../images/auth.jpg");
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 40px;
    text-align: center;
    color: white;
}
.auth-image-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1;
}
.image-overlay-content {
    position: relative;
    z-index: 2;
}
.auth-page-wrapper {
    min-width: 74%;
    margin: 22px;
}
.image-overlay-content h1 {
    font-size: 2em;
    font-weight: 900;
    margin-bottom: 15px;
}
.image-overlay-content p {
    font-size: 1.05em;
    margin-bottom: 30px;
    max-width: 350px;
    line-height: 1.6;
}
.logo-on-image {
    width: 120px;
    height: auto;
    filter: brightness(0) invert(1);
}

/* Form Section */
.auth-form-section {
    flex: 1;
    padding: 30px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--form-background-auth);
    position: relative;
}
.form-content-wrapper {
    width: 100%;
    max-width: 360px;
    text-align: center;
}
.logo-form-top {
    width: 120px;
    height: auto;
    margin-bottom: 20px;
}
.auth-state {
    display: none;
    width: 100%;
    animation: fadeInState 0.4s ease-out;
}
.auth-state.active {
    display: block;
}
@keyframes fadeInState {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.back-button {
    position: absolute;
    top: 25px;
    right: 25px;
    background: none;
    border: none;
    font-size: 1.4em;
    color: var(--text-light-auth);
    cursor: pointer;
    padding: 5px;
}
.back-button:hover {
    color: var(--primary-color-auth);
}
.auth-state h2 {
    font-size: 1.7em;
    font-weight: 700;
    color: var(--secondary-color-auth);
    margin-bottom: 10px;
    margin-top: 30px;
}
.auth-state:first-child h2,
#loginState h2,
#signupState h2 {
    margin-top: 10px;
} /* Adjust for first state or states without prominent back button */
.state-subtitle {
    font-size: 0.9em;
    color: var(--text-light-auth);
    margin-bottom: 25px;
    line-height: 1.5;
}
.state-subtitle span {
    font-weight: 600;
    color: var(--text-color-auth);
}
.auth-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color-auth);
}
.auth-tab-btn {
    flex: 1;
    padding: 12px 10px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-family: var(--font-family-auth);
    font-size: 0.95em;
    font-weight: 600;
    color: var(--text-light-auth);
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.auth-tab-btn.active,
.auth-tab-btn:hover {
    color: var(--primary-color-auth);
    border-bottom-color: var(--primary-color-auth);
}
.auth-tab-content {
    display: none;
}
.auth-tab-content.active {
    display: block;
    animation: fadeInState 0.3s ease-out;
}
.form-group {
    margin-bottom: 20px;
    text-align: right;
}
.form-group label {
    display: inline-block;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--secondary-color-auth);
    margin-bottom: 6px;
}
.input-group {
    position: relative;
}
.input-group input[type="email"],
.input-group input[type="tel"],
.input-group input[type="password"],
.input-group input[type="text"],
.input-group input[type="date"],
.auth-state select {
    width: 100%;
    padding: 12px 44px;
    border: 1px solid var(--border-color-auth);
    border-radius: var(--border-radius-auth);
    font-family: var(--font-family-auth);
    font-size: 0.95em;
    transition: border-color 0.2s ease;
}
.input-group input[type="password"] {
    padding-right: 45px;
}
.input-group input:focus,
.auth-state select:focus {
    border-color: var(--primary-color-auth);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}
.input-icon {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    color: var(--text-light-auth);
}
.input-group input[type="date"] {
    padding-left: 15px;
    padding-right: 40px;
}
.input-group input[type="date"] + .input-icon {
    left: auto;
    right: 15px;
}
.form-group.with-country-code .input-group {
    display: flex;
}
.form-group.with-country-code select {
    padding: 12px 8px;
    border-left: none;
    border-top-right-radius: var(--border-radius-auth);
    border-bottom-right-radius: var(--border-radius-auth);
    background-color: var(--light-gray);
    font-size: 0.95em;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23333' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.5rem center;
    padding-left: 2rem;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    background-size: 21.5px;
}
.form-group.with-country-code input[type="tel"] {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--border-radius-auth);
    border-bottom-left-radius: var(--border-radius-auth);
    padding-left: 40px;
}
.password-group .toggle-password {
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    color: var(--text-light-auth);
    cursor: pointer;
    padding: 5px;
}
.btn-auth {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color-auth);
    color: white;
    border: none;
    border-radius: var(--border-radius-auth);
    font-family: var(--font-family-auth);
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.btn-auth:hover {
    background-color: #0056b3;
}
.btn-auth:disabled {
    background-color: var(--medium-gray);
    cursor: not-allowed;
}
.forgot-password-link,
.alternate-auth-link,
.switch-auth-mode {
    display: block;
    margin-top: 15px;
    font-size: 0.9em;
}
.forgot-password-link,
.alternate-auth-link,
.switch-auth-mode a {
    color: var(--primary-color-auth);
    text-decoration: none;
    font-weight: 600;
    margin-right: 5px;
}

.otp-inputs {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 20px;
    direction: ltr;
}
.otp-digit {
    width: 50px;
    height: 55px;
    text-align: center;
    font-size: 1.5em;
    font-weight: 600;
    border: 1px solid var(--border-color-auth);
    border-radius: var(--border-radius-auth);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.otp-digit:focus {
    border-color: var(--primary-color-auth);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}
.resend-otp-text {
    font-size: 0.85em;
    color: var(--text-light-auth);
    margin-bottom: 20px;
}
.resend-otp-text a {
    color: var(--primary-color-auth);
    text-decoration: none;
}
.resend-otp-text a:hover {
    text-decoration: underline;
}
#otpTimer {
    color: var(--text-color-auth);
    font-weight: 600;
}
.password-criteria {
    list-style: none;
    padding: 0;
    margin-top: 10px;
    font-size: 0.8em;
    text-align: right;
}
.password-criteria li {
    margin-bottom: 4px;
    color: var(--text-light-auth);
}
.password-criteria li i {
    margin-left: 5px;
}
.password-criteria li.valid {
    color: var(--success-color-auth);
}
.password-criteria li.valid i {
    color: var(--success-color-auth);
}
.password-criteria li.invalid i {
    color: var(--danger-color-auth);
}
.password-criteria li .fa-times {
    color: var(--danger-color-auth);
}
.password-criteria li .fa-check {
    color: var(--success-color-auth);
}
.success-icon-container {
    font-size: 4em;
    margin-bottom: 20px;
    animation: popIn 0.5s ease-out;
}
.success-icon-container .fa-check-circle {
    color: var(--success-color-auth);
}
.success-icon-container .fa-user-check {
    color: var(--primary-color-auth);
} /* For signup success */
@keyframes popIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}
#passwordChangedSuccessState h2,
#signupSuccessState h2 {
    margin-bottom: 15px;
}
#passwordChangedSuccessState .state-subtitle,
#signupSuccessState .state-subtitle {
    margin-bottom: 30px;
}
.terms-text.small {
    font-size: 0.75em;
    margin-top: 15px;
    margin-bottom: 20px;
}

/* Responsive */
@media (max-width: 850px) {
    .auth-container {
        flex-direction: column;
        max-width: 480px;
        min-height: auto;
    }
    .auth-image-section {
        min-height: 200px;
        padding: 30px;
    }
    .image-overlay-content h1 {
        font-size: 1.8em;
    }
    .image-overlay-content p {
        font-size: 0.95em;
    }
    .auth-form-section {
        padding: 30px 25px;
    }
}
@media (max-width: 480px) {
    .auth-image-section {
        display: none;
    }
    .auth-container {
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .auth-form-section {
        min-height: 100vh;
        padding: 25px 20px;
        justify-content: flex-start;
        padding-top: 40px;
    }
    .logo-form-top {
        width: 100px;
        margin-bottom: 15px;
    }
    .auth-state h2 {
        font-size: 1.5em;
    }
    .otp-inputs {
        gap: 5px;
    }
    .otp-digit {
        width: 45px;
        height: 50px;
        font-size: 1.3em;
    }
}
