﻿/* ============================================================
   متغیرهای رنگ و تنظیمات پایه
   ============================================================ */
:root {
    --primary: #0b2e59;
    --primary-light: #1a4f85;
    --background-dark: #0a1628;
    --background-light: #1a5276;
    --text-dark: #1a2a3a;
    --muted-text: #6c757d;
    --danger: #dc3545;
    --card-max-width: 440px;
    --font-family: 'Vazirmatn', Tahoma, sans-serif;
}

/* ============================================================
   ریست اولیه
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    direction: rtl;
}

body {
    min-height: 100%;
    margin: 0;
    direction: rtl;
    text-align: right;
    font-family: var(--font-family);
    background: radial-gradient(circle at 30% 20%, var(--background-light), var(--background-dark));
}

/* ============================================================
   صفحه ورود
   ============================================================ */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px 16px;
}

.auth-container {
    width: 100%;
    max-width: var(--card-max-width);
}

/* ============================================================
   برند: لوگو و عنوان
   ============================================================ */
.auth-brand {
    margin-bottom: 30px;
    text-align: center;
}

    .auth-brand h1 {
        margin: 0;
        color: #ffffff;
        font-size: 24px;
        font-weight: 900;
        letter-spacing: 1px;
        text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .auth-brand p {
        margin: 5px 0 0;
        color: rgba(255, 255, 255, 0.72);
        font-size: 14px;
    }

/* ============================================================
   کارت ورود
   ============================================================ */
.auth-card {
    width: 100%;
    max-width: var(--card-max-width);
    margin: 0 auto;
    padding: 36px 32px;
    border-radius: 32px;
    background: #ffffff;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45);
}

.auth-title {
    margin: 0 0 24px;
    color: var(--primary);
    font-size: 20px;
    font-weight: 700;
    text-align: center;
}

/* ============================================================
   اعتبارسنجی فرم
   ============================================================ */
.validation-summary {
    margin-bottom: 16px;
    padding: 10px 14px;
    border-right: 4px solid var(--danger);
    border-radius: 12px;
    background: #fff0f0;
    color: #842029;
    font-size: 0.9rem;
}

.field-validation {
    display: block;
    margin-top: 6px;
    padding-right: 4px;
    color: var(--danger);
    font-size: 0.8rem;
}

/* ============================================================
   ورودی‌ها
   ============================================================ */
input,
button,
textarea,
select {
    font-family: var(--font-family);
}

.auth-input-group {
    position: relative;
    margin-bottom: 18px;
}

.input-icon {
    position: absolute;
    z-index: 2;
    top: 50%;
    right: 16px;
    color: #9aa3b5;
    font-size: 1.1rem;
    pointer-events: none;
    transform: translateY(-50%);
    transition: color 0.2s ease;
}

.auth-input-group:focus-within .input-icon {
    color: var(--primary);
}

.auth-input {
    width: 100%;
    height: 52px;
    padding: 12px 48px 12px 16px;
    border: 2px solid #e8edf5;
    border-radius: 16px;
    outline: none;
    background: #f8fafd;
    color: var(--text-dark);
    font-size: 0.95rem;
    transition: border-color 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}

    .auth-input::placeholder {
        color: #b0baca;
        font-weight: 400;
    }

    .auth-input:focus {
        border-color: var(--primary);
        background: #ffffff;
        box-shadow: 0 0 0 5px rgba(11, 46, 89, 0.12);
    }

    .auth-input.input-error {
        border-color: var(--danger);
        background: #fff8f8;
    }

    /* حذف آیکون پیش‌فرض نمایش رمز در برخی مرورگرها */
    .auth-input::-ms-reveal,
    .auth-input::-ms-clear {
        display: none;
    }

    .auth-input::-webkit-credentials-auto-fill-button {
        display: none !important;
        visibility: hidden;
        pointer-events: none;
    }

/* اصلاح ظاهر Autofill در Chrome و Edge */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset !important;
    -webkit-text-fill-color: var(--text-dark) !important;
    caret-color: var(--text-dark);
    transition: background-color 5000s ease-in-out 0s;
}

/* ============================================================
   گزینه‌های فرم
   ============================================================ */
.auth-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 6px 0 20px;
    font-size: 0.9rem;
}

    .auth-options .form-check {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .auth-options .form-check-input {
        width: 18px;
        height: 18px;
        margin: 0;
        border: 2px solid #d0d8e4;
        border-radius: 4px;
        cursor: pointer;
    }

        .auth-options .form-check-input:checked {
            border-color: var(--primary);
            background-color: var(--primary);
        }

    .auth-options .form-check-label {
        color: #4a5a6e;
        font-weight: 500;
        cursor: pointer;
        user-select: none;
    }

    .auth-options a {
        color: var(--primary);
        font-size: 0.85rem;
        font-weight: 600;
        text-decoration: none;
        transition: color 0.2s ease;
    }

        .auth-options a:hover {
            color: var(--primary-light);
            text-decoration: underline;
        }

/* ============================================================
   دکمه ورود
   ============================================================ */
.auth-btn-primary {
    position: relative;
    width: 100%;
    height: 54px;
    overflow: hidden;
    border: none;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    box-shadow: 0 10px 30px rgba(11, 46, 89, 0.35);
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

    .auth-btn-primary:hover:not(:disabled) {
        background: linear-gradient(135deg, #0f3a6e, #1f5a94);
        box-shadow: 0 14px 40px rgba(11, 46, 89, 0.45);
        transform: translateY(-2px);
    }

    .auth-btn-primary:active:not(:disabled) {
        transform: translateY(0);
    }

    .auth-btn-primary:disabled {
        opacity: 0.75;
        cursor: not-allowed;
    }

    .auth-btn-primary:focus-visible,
    .apk-download-btn:focus-visible {
        outline: 3px solid #8ee8ff;
        outline-offset: 3px;
    }

/* اسپینر داخل دکمه ورود */
.btn-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    margin-left: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    vertical-align: middle;
    animation: spin 0.6s linear infinite;
}

/* ============================================================
   دکمه دانلود اپلیکیشن Android
   ============================================================ */

/*
  این کانتینر باید بلافاصله بعد از auth-card قرار گیرد.
  عرض آن دقیقاً برابر با عرض کارت ورود است.
*/
.apk-download-container {
    width: 100%;
    max-width: var(--card-max-width);
    margin: 26px auto 0;
}

/*
  پشتیبانی از حالتی که لینک دانلود مستقیم در auth-container
  قرار گرفته و div با کلاس apk-download-container وجود ندارد.
*/
.auth-container > .apk-download-btn {
    width: 100%;
    max-width: var(--card-max-width);
    margin: 26px auto 0;
}

.apk-download-btn {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 68px;
    gap: 12px;
    padding: 10px 14px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 20px;
    background: linear-gradient(135deg, #12629a, var(--primary));
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
    color: #ffffff;
    text-decoration: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
}

    .apk-download-btn::before {
        position: absolute;
        top: 0;
        right: -130%;
        width: 70%;
        height: 100%;
        content: "";
        background: linear-gradient( 90deg, transparent, rgba(255, 255, 255, 0.2), transparent );
        transform: skewX(-22deg);
        transition: right 0.65s ease;
    }

    .apk-download-btn:hover {
        color: #ffffff;
        box-shadow: 0 16px 34px rgba(0, 0, 0, 0.32);
        filter: brightness(1.08);
        transform: translateY(-3px);
    }

        .apk-download-btn:hover::before {
            right: 150%;
        }

    .apk-download-btn:active {
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
        transform: translateY(0);
    }

/* آیکون اندروید */
.apk-download-icon {
    position: relative;
    z-index: 1;
    display: inline-flex;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.16);
    color: #8ee8ff;
    font-size: 1.55rem;
}

/* متن دکمه دانلود */
.apk-download-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
    text-align: right;
}

    .apk-download-content strong {
        color: #ffffff;
        font-size: 0.92rem;
        font-weight: 700;
        line-height: 1.5;
    }

    .apk-download-content small {
        overflow: hidden;
        color: rgba(255, 255, 255, 0.74);
        font-size: 0.72rem;
        font-weight: 400;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

/* فلش دانلود */
.apk-download-arrow {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    color: #ffffff;
    font-size: 1.2rem;
    transition: transform 0.25s ease;
}

.apk-download-btn:hover .apk-download-arrow {
    transform: translateY(3px);
}

/* ============================================================
   فوتر
   ============================================================ */
.auth-footer {
    margin-top: 20px;
    color: rgba(255, 255, 255, 0.64);
    font-size: 0.85rem;
    text-align: center;
}

/* ============================================================
   لودینگ
   ============================================================ */
.loading-overlay {
    position: fixed;
    z-index: 99999;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

    .loading-overlay.show {
        display: flex !important;
    }

    .loading-overlay.d-none {
        display: none !important;
    }

.loading-card {
    width: calc(100% - 32px);
    max-width: 320px;
    min-width: 260px;
    padding: 40px 32px;
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    text-align: center;
    animation: fadeInUp 0.4s ease;
}

.loading-spinner {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border: 5px solid #e5eaf0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    margin-top: 16px;
    color: #0f172a;
    font-size: 1rem;
    font-weight: 700;
}

.loading-subtext {
    margin-top: 4px;
    color: var(--muted-text);
    font-size: 0.85rem;
}

/* ============================================================
   انیمیشن‌ها
   ============================================================ */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================================
   حالت موبایل
   ============================================================ */
@media (max-width: 576px) {
    .auth-page {
        align-items: flex-start;
        padding: 28px 16px;
    }

    .auth-brand {
        margin-bottom: 22px;
    }

        .auth-brand h1 {
            font-size: 20px;
        }

    .auth-card {
        padding: 24px 18px;
        border-radius: 24px;
    }

    .auth-title {
        font-size: 18px;
    }

    .auth-input {
        height: 48px;
        padding: 10px 44px 10px 14px;
        font-size: 0.85rem;
    }

    .auth-btn-primary {
        height: 48px;
        font-size: 0.95rem;
    }

    .auth-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .apk-download-container,
    .auth-container > .apk-download-btn {
        margin-top: 20px;
    }

    .apk-download-btn {
        min-height: 64px;
        border-radius: 18px;
    }

    .loading-card {
        min-width: 0;
        padding: 30px 24px;
    }
}

/* ============================================================
   مرورگرهای بدون backdrop-filter
   ============================================================ */
@supports not (backdrop-filter: blur(8px)) {
    .loading-overlay {
        background: rgba(0, 0, 0, 0.72);
    }
}

/* ============================================================
   حالت چاپ
   ============================================================ */
@media print {
    .loading-overlay,
    .auth-btn-primary,
    .apk-download-container,
    .apk-download-btn,
    .auth-options a {
        display: none !important;
    }

    .auth-card {
        border: 1px solid #dddddd;
        box-shadow: none;
    }
}
