/* ============================================
   FONTS (Vazir FD)
============================================ */
@font-face {
    font-family: "Vazir FD";
    src: url("../../fonts/ef0d00bc563865136e2c7862189a087bb01d420f32392fbfc08890c907c44997.woff2") format("woff2");
    font-weight: 100;
    font-display: swap;
}

@font-face {
    font-family: "Vazir FD";
    src: url("../../fonts/e33b24022ec2dfbb92d5c22da4b3a49925397c0c9dfeea2796b9eb67467172c7.woff2") format("woff2");
    font-weight: 300;
    font-display: swap;
}

@font-face {
    font-family: "Vazir FD";
    src: url("../../fonts/47c66af4381435232bbadc5218cc7750734f01d171202e8242e932dbd6c3149d.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Vazir FD";
    src: url("../../fonts/5287509c7520f9c4d3f0cee37c1ee4faf099cafd0c314f18b763a33860c953b2.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "Vazir FD";
    src: url("../../fonts/c4db85cb63fadc85c0f1dd39f8fb12f06884ae7d6daa5e83f21966f2b329ba08.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
}

@font-face {
    font-family: "Vazir FD";
    src: url("../../fonts/f1a33789c334dd2126609d0fe55011b55b47e1e0145a03a852fbbc86e065a086.woff2") format("woff2");
    font-weight: 900;
    font-display: swap;
}

/* ============================================
   RESET & BASE
============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazir FD', sans-serif;
    min-height: 100vh;
    background: #ffffff;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    position: relative;
}

@media (min-width: 577px) {
    body {
        background-color: #f5f7fa;
        background-image: radial-gradient(circle at 15% 20%, rgba(72, 196, 183, 0.08), transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(34, 191, 120, 0.06), transparent 40%);
        align-items: center;
    }

    body::before {
        content: '';
        position: fixed;
        inset: 0;
        pointer-events: none;
        z-index: 0;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 260 260'%3E%3Cg stroke='rgba(72,196,183,0.20)' stroke-width='1' fill='none'%3E%3Cline x1='60' y1='70' x2='150' y2='40'/%3E%3Cline x1='150' y1='40' x2='210' y2='110'/%3E%3Cline x1='60' y1='70' x2='90' y2='160'/%3E%3Cline x1='90' y1='160' x2='210' y2='110'/%3E%3Cline x1='90' y1='160' x2='170' y2='210'/%3E%3Cline x1='210' y1='110' x2='170' y2='210'/%3E%3C/g%3E%3Ccircle cx='60' cy='70' r='4' fill='rgba(72,196,183,0.35)'/%3E%3Ccircle cx='150' cy='40' r='4' fill='rgba(72,196,183,0.35)'/%3E%3Ccircle cx='210' cy='110' r='4' fill='rgba(34,191,120,0.35)'/%3E%3Ccircle cx='90' cy='160' r='4' fill='rgba(72,196,183,0.35)'/%3E%3Ccircle cx='170' cy='210' r='4' fill='rgba(34,191,120,0.35)'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: 85% 90%;
        background-size: 260px;
        opacity: 0.9;
    }

    body::after {
        content: '';
        position: fixed;
        inset: 0;
        pointer-events: none;
        z-index: 0;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 260 260'%3E%3Cg stroke='rgba(72,196,183,0.12)' stroke-width='1' fill='none'%3E%3Cline x1='60' y1='70' x2='150' y2='40'/%3E%3Cline x1='150' y1='40' x2='210' y2='110'/%3E%3Cline x1='60' y1='70' x2='90' y2='160'/%3E%3Cline x1='90' y1='160' x2='210' y2='110'/%3E%3Cline x1='90' y1='160' x2='170' y2='210'/%3E%3Cline x1='210' y1='110' x2='170' y2='210'/%3E%3C/g%3E%3Ccircle cx='60' cy='70' r='3' fill='rgba(72,196,183,0.20)'/%3E%3Ccircle cx='150' cy='40' r='3' fill='rgba(72,196,183,0.20)'/%3E%3Ccircle cx='210' cy='110' r='3' fill='rgba(34,191,120,0.20)'/%3E%3Ccircle cx='90' cy='160' r='3' fill='rgba(72,196,183,0.20)'/%3E%3Ccircle cx='170' cy='210' r='3' fill='rgba(34,191,120,0.20)'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: 15% 10%;
        background-size: 180px;
        opacity: 0.6;
    }
}

/* ============================================
   LANGUAGE SWITCHER - داخل باکس (بالا سمت راست)
============================================ */
.lang-switcher {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
}

.lang-switcher .lang-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid #e8edf2;
    border-radius: 10px;
    color: #5a6b7a;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Vazir FD', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.lang-switcher .lang-btn:hover {
    border-color: #04a663;
    color: #04a663;
    background: rgba(4, 166, 99, 0.04);
}

.lang-switcher .lang-btn i {
    font-size: 14px;
    color: #90a4ae;
}

.lang-switcher .lang-btn:hover i {
    color: #04a663;
}

.lang-switcher .lang-btn .chevron {
    font-size: 9px;
    color: #b0bec5;
    transition: transform 0.2s ease;
}

.lang-switcher .lang-btn[aria-expanded="true"] .chevron {
    transform: rotate(180deg);
}

/* Dropdown */
.lang-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 140px;
    background: #ffffff;
    border: 1px solid #eef2f7;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    padding: 4px;
    display: none;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.lang-dropdown.open {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.lang-dropdown .lang-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    color: #2c3e50;
    font-size: 12px;
    font-weight: 400;
    font-family: 'Vazir FD', sans-serif;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
}

.lang-dropdown .lang-item:hover {
    background: #f0faf5;
    color: #04a663;
}

.lang-dropdown .lang-item .fi {
    font-size: 16px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.lang-dropdown .lang-item .lang-name {
    flex: 1;
}

/* ============================================
   CONTAINER / BOX
============================================ */
.login-container {
    width: 100%;
    max-width: 490px;
    padding: 0 20px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.login-box {
    background: #ffffff;
    border-radius: 16px;
    padding: 32px 28px 28px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    margin-top: 20px;
    margin-bottom: 20px;
    position: relative;
}

.logo {
    display: block;
    max-width: 120px;
    height: auto;
    margin: 8px auto 24px auto;
}

.login-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: #1a2a3a;
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: center;
    font-size: 14px;
    color: #7a8a9a;
    margin-bottom: 24px;
    font-weight: 300;
}

/* ============================================
   FORM GROUPS
============================================ */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 6px;
}

.form-label .helper-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    font-weight: 500;
    color: #04a663;
    cursor: pointer;
    font-family: 'Vazir FD', sans-serif;
}

.form-label .helper-link:hover {
    text-decoration: underline;
}

/* ============================================
   GENERIC FIELD BOX (shared shell used by
   phone / username / password so every field
   in the form looks and behaves the same)
============================================ */
.field-box {
    position: relative;
    display: flex;
    align-items: stretch;
    background: #f7f9fb;
    border: 2px solid #e8edf2;
    border-radius: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field-box.focused {
    border-color: #04a663;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(4, 166, 99, 0.08);
}

.field-box.field-error {
    border-color: #e74c3c;
    background: #fff8f8;
}

.field-box.field-success {
    border-color: #04a663;
}

@keyframes shakeInput {
    10%, 90% {
        transform: translateX(-0.5px);
    }
    20%, 80% {
        transform: translateX(1px);
    }
    30%, 50%, 70% {
        transform: translateX(-2px);
    }
    40%, 60% {
        transform: translateX(2px);
    }
}

.field-box.shake {
    animation: shakeInput 0.4s cubic-bezier(.36, .07, .19, .97) both;
    border-color: #e74c3c;
}

.field-input {
    flex: 1;
    min-width: 0;
    height: 56px;
    padding: 0 16px;
    font-size: 15px;
    font-family: 'Vazir FD', sans-serif;
    color: #1a2a3a;
    background: transparent;
    border: none;
    outline: none;
}

.field-input::placeholder {
    color: #b0bec5;
    font-weight: 300;
    font-size: 14px;
}

/* ---- phone: country trigger (identical mechanics to the OTP request page) ---- */
.phone-field {
    direction: ltr;
}

.country-trigger {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 56px;
    padding: 0 10px 0 14px;
    background: transparent;
    border: none;
    border-left: 1px solid #e8edf2;
    cursor: pointer;
    font-family: 'Vazir FD', sans-serif;
    color: #1a2a3a;
    font-size: 15px;
    direction: ltr;
}

.country-trigger .fi {
    font-size: 20px;
    line-height: 1;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.country-trigger .dial-code {
    font-weight: 600;
    color: #1a2a3a;
    white-space: nowrap;
}

.country-trigger .trigger-arrow {
    font-size: 11px;
    color: #9aa8b3;
    transition: transform 0.2s ease;
    margin-left: 2px;
}

.country-trigger[aria-expanded="true"] .trigger-arrow {
    transform: rotate(180deg);
}

.input-phone {
    direction: ltr;
    text-align: left;
    letter-spacing: 0.3px;
}

.country-dropdown-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 40;
    pointer-events: none;
}

.country-dropdown-backdrop.open {
    display: block;
}

.country-dropdown-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 300px;
    max-width: 90vw;
    background: #ffffff;
    border: 1px solid #e8edf2;
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(20, 30, 40, 0.14);
    z-index: 50;
    overflow: hidden;
    direction: ltr;
    pointer-events: auto;
}

.country-dropdown-panel.open {
    display: block;
}

.country-search-wrap {
    position: relative;
    padding: 10px;
    border-bottom: 1px solid #eef2f5;
}

.country-search-wrap input {
    width: 100%;
    height: 42px;
    padding: 0 36px 0 12px;
    border: 1px solid #e8edf2;
    border-radius: 10px;
    background: #f7f9fb;
    font-family: 'Vazir FD', sans-serif;
    font-size: 12px;
    outline: none;
    direction: rtl;
    text-align: right;
}

.country-search-wrap input:focus {
    border-color: #04a663;
}

.country-search-wrap i {
    position: absolute;
    left: 22px;
    top: 50%;
    transform: translateY(-50%);
    color: #9aa8b3;
    font-size: 15px;
    pointer-events: none;
}

.country-list {
    list-style: none;
    max-height: 280px;
    overflow-y: auto;
    padding: 6px;
    direction: rtl;
}

.country-list::-webkit-scrollbar {
    width: 6px;
}

.country-list::-webkit-scrollbar-thumb {
    background: #dfe6ea;
    border-radius: 6px;
}

.country-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #2c3e50;
}

.country-item:hover, .country-item.active {
    background: #f0faf5;
    color: #04a663;
}

.country-item .fi {
    font-size: 18px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.country-item .country-name {
    flex: 1;
}

.country-item .country-dial {
    direction: ltr;
    color: #7a8a9a;
    font-size: 13px;
}

.country-empty {
    padding: 24px 10px;
    text-align: center;
    color: #9aa8b3;
    font-size: 13px;
}

/* ---- username: fixed domain prefix + status icon ---- */
.username-field {
    direction: ltr;
}

.username-prefix {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 4px 0 14px;
    color: #9aa8b3;
    font-size: 15px;
    font-family: 'Vazir FD', sans-serif;
    white-space: nowrap;
    border-right: 1px solid #e8edf2;
}

.input-username {
    direction: ltr;
    text-align: left;
    padding-left: 8px;
}

.username-status {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    font-size: 16px;
}

.username-status .bi-check-circle-fill {
    color: #04a663;
}

.username-status .bi-x-circle-fill {
    color: #e74c3c;
}

.username-status .bi-exclamation-circle-fill {
    color: #e5a100;
}

.field-help {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #9aa8b3;
    direction: ltr;
    text-align: left;
}

.field-help .username-preview {
    color: #1a2a3a;
    font-weight: 600;
}

.field-message {
    margin-top: 6px;
    font-size: 12px;
    font-weight: 500;
    min-height: 16px;
}

.field-message.text-success {
    color: #04a663;
}

.field-message.text-danger {
    color: #e74c3c;
}

.field-message.text-warning {
    color: #e5a100;
}

.field-message.text-muted {
    color: #9aa8b3;
}

/* ---- password: eye toggle ---- */
.password-toggle {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    background: none;
    border: none;
    color: #9aa8b3;
    font-size: 17px;
    cursor: pointer;
}

.password-toggle:hover {
    color: #5a6b7a;
}

/* ============================================
   TERMS CHECKBOX
============================================ */
.terms-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 18px;
}

.terms-checkbox {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: #04a663;
    cursor: pointer;
}

.terms-label {
    font-size: 13px;
    color: #5a6b7a;
    line-height: 1.6;
}

.terms-label a {
    color: #04a663;
    text-decoration: none;
    font-weight: 500;
}

.terms-label a:hover {
    text-decoration: underline;
}

/* ============================================
   BUTTON
============================================ */
.btn-login {
    width: 100%;
    height: 56px;
    padding: 0 24px;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Vazir FD', sans-serif;
    color: #fff;
    background: #04a663;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-login:hover:not(:disabled) {
    background: #039855;
}

.btn-login:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background: #b0bec5;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    flex-shrink: 0;
}

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

/* ============================================
   LINKS / MESSAGES
============================================ */
.register-text {
    display: block;
    text-align: center;
    font-size: 13px;
    color: #7a8a9a;
    margin-top: 20px;
}

.register-text span {
    color: #04a663;
    font-weight: 600;
}

.register-text:hover span {
    text-decoration: underline;
}

.error-message {
    display: none;
    color: #e74c3c;
    font-size: 13px;
    font-weight: 400;
    margin-top: 6px;
    padding: 6px 0;
    animation: fadeIn 0.25s ease;
}

.error-message.show {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.error-global {
    margin-bottom: 16px;
    text-align: center;
    font-size: 13px;
}

/* ============================================
   MODAL (restyled to match theme)
============================================ */
.modal-content {
    border-radius: 18px;
    border: none;
    font-family: 'Vazir FD', sans-serif;
}

.modal-content .modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #f0faf5;
    color: #04a663;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    margin: 0 auto 14px auto;
}

.modal-content p {
    font-size: 13px;
    color: #5a6b7a;
    margin-bottom: 8px;
    line-height: 1.8;
}

.modal-content .btn-outline-secondary {
    border-radius: 12px;
    font-family: 'Vazir FD', sans-serif;
    font-size: 14px;
    border-color: #e8edf2;
    color: #5a6b7a;
}

.modal-content .btn-outline-secondary:hover {
    background: #f7f9fb;
    color: #1a2a3a;
}

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width: 576px) {
    body {
        align-items: flex-start;
        padding-top: 16px;
        background: #ffffff;
    }

    body::before, body::after {
        display: none;
    }

    .login-container {
        padding: 0 16px;
        max-width: 100%;
    }

    .login-box {
        padding: 24px 16px 20px;
        border-radius: 14px;
        box-shadow: none;
        margin-top: 0;
    }

    .lang-switcher {
        top: 12px;
        right: 12px;
    }

    .lang-switcher .lang-btn {
        padding: 3px 8px;
        font-size: 11px;
        border-radius: 8px;
    }

    .lang-switcher .lang-btn i {
        font-size: 12px;
    }

    .lang-dropdown {
        min-width: 120px;
        right: 0;
        top: calc(100% + 4px);
    }

    .lang-dropdown .lang-item {
        font-size: 11px;
        padding: 5px 10px;
    }

    .logo {
        max-width: 90px;
        margin: 4px auto 20px auto;
    }

    .login-title {
        font-size: 20px;
    }

    .login-subtitle {
        font-size: 13px;
        margin-bottom: 20px;
    }

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

    .field-input, .country-trigger, .username-prefix {
        height: 52px;
    }

    .input-phone, .input-username, input[type="password"].field-input {
        font-size: 16px !important;
    }

    .field-box {
        border-radius: 12px;
    }

    .btn-login {
        height: 52px;
        font-size: 15px;
        border-radius: 12px;
    }

    .error-message {
        font-size: 12px;
        margin-top: 4px;
    }

    .error-global {
        font-size: 12px;
        padding: 8px 12px;
        margin-bottom: 14px;
    }

    .country-dropdown-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        max-width: 100%;
        border-radius: 18px 18px 0 0;
        max-height: 75vh;
        display: none;
        transform: translateY(100%);
        transition: transform 0.25s ease;
        z-index: 60;
        pointer-events: auto;
    }

    .country-dropdown-panel.open {
        display: flex;
        flex-direction: column;
        transform: translateY(0);
    }

    .country-dropdown-panel .country-search-wrap {
        flex-shrink: 0;
    }

    .country-list {
        max-height: none;
        flex: 1;
    }

    .sheet-handle {
        width: 40px;
        height: 4px;
        background: #e0e6ea;
        border-radius: 4px;
        margin: 10px auto 0;
    }
}

@media (max-width: 380px) {
    .login-box {
        padding: 16px 12px 16px;
    }

    .login-title {
        font-size: 18px;
    }

    .login-subtitle {
        font-size: 12px;
        margin-bottom: 18px;
    }

    .field-input, .country-trigger, .username-prefix {
        height: 48px;
    }

    .btn-login {
        height: 48px;
        font-size: 14px;
        border-radius: 10px;
    }

    .logo {
        max-width: 85px;
        margin-bottom: 18px;
    }

    .lang-switcher {
        top: 10px;
        right: 10px;
    }
}

@media (min-width: 577px) {
    .login-container {
        padding: 0 24px;
    }

    .login-box {
        padding: 40px 36px 32px;
        border-radius: 16px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.07);
        margin-top: 0;
    }

    .lang-switcher {
        top: 20px;
        right: 20px;
    }

    .lang-switcher .lang-btn {
        padding: 5px 12px;
        font-size: 12px;
    }

    .lang-switcher .lang-btn .lang-label {
        display: inline;
    }

    .logo {
        max-width: 130px;
        margin: 4px auto 28px auto;
    }

    .login-title {
        font-size: 24px;
    }

    .login-subtitle {
        font-size: 14px;
        margin-bottom: 28px;
    }

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

    .field-box {
        border-radius: 14px;
    }

    .btn-login {
        height: 56px;
        font-size: 16px;
        border-radius: 14px;
    }
}

/* ============================================
   FOCUS RING / AUTOFILL / SELECTION
============================================ */
.country-trigger:focus-visible,
.country-search-wrap input:focus-visible,
.password-toggle:focus-visible,
.terms-checkbox:focus-visible {
    outline: 2px solid #04a663;
    outline-offset: 2px;
}

.field-input:focus-visible {
    outline: none;
}

.btn-login:focus-visible {
    outline: 3px solid #04a663;
    outline-offset: 2px;
}

.field-input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #f7f9fb inset !important;
    -webkit-text-fill-color: #1a2a3a !important;
}

.field-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset !important;
}

::selection {
    background: rgba(4, 166, 99, 0.2);
    color: #1a2a3a;
}

input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}
