/* =========================================
   1. CSS Variables (Design Tokens)
========================================= */
:root {
    --navy: #1b2a38;
    --navy-deep: #111c26;
    --paper: #f7f3eb;
    --white: #ffffff;
    --rose: #b8254b;
    --rose-hover: #961b3b;
    --teal: #1e6b65;
    --line: #dcd8ce;
    --danger: #c92a2a;
    --muted: #556068;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-btn: 0 8px 20px -4px rgba(184, 37, 75, 0.4);
    --shadow-card: 0 10px 40px rgba(0, 0, 0, 0.08);
    --font-sans: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* =========================================
   2. Reset & Base Styles
========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--paper); /* رنگ پیش‌فرض پس‌زمینه اپلیکیشن */
    color: var(--navy);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* =========================================
   3. SPA View Management
========================================= */
.screen-view {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.screen-view.active {
    display: block;
    opacity: 1;
}

/* =========================================
   4. Layout Containers
========================================= */
/* هدر اصلی (لاگین و ثبت‌نام) */
.site-header {
    width: 100%;
    height: 70px;
    background-color: var(--white);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    width: 100%;
    max-width: 500px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
}

.header-inner img {
    height: 35px;
}

.header-badge {
    font-size: 0.75rem;
    color: var(--teal);
    font-weight: 600;
    background: rgba(30, 107, 101, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
}

/* محفظه اصلی صفحات احراز هویت */
.app-shell {
    width: 100%;
    max-width: 480px;
    padding: 2rem 1rem;
    flex: 1;
}

/* کارت اصلی احراز هویت */
.auth-card {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-card);
}

.card-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-align: center;
}

.card-desc {
    font-size: 0.9rem;
    color: var(--muted);
    text-align: center;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* =========================================
   5. Buttons & Badges
========================================= */
.btn {
    width: 100%;
    padding: 0.9rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-primary, .btn-submit {
    background-color: var(--rose);
    color: var(--white);
    box-shadow: var(--shadow-btn);
}

.btn-submit {
    margin-top: 1rem;
}

.btn-primary:hover, .btn-submit:hover {
    background-color: var(--rose-hover);
}

.btn-primary:active, .btn-submit:active {
    transform: scale(0.98);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--line);
    color: var(--navy);
}

.btn-hidden {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.btn-submit.is-loading {
    pointer-events: none;
    opacity: 0.8;
}

.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-left: 8px;
}

.btn-submit.is-loading .spinner {
    display: inline-block;
}

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

/* =========================================
   6. Forms & Inputs
========================================= */
.form-group {
    margin-bottom: 1.2rem;
    position: relative;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--navy);
}

.form-control {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--navy);
}

.input-wrapper {
    position: relative;
}

/* دکمه نمایش/مخفی رمز */
.btn-eye {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--muted);
    display: flex;
    align-items: center;
}

/* گروه ورودی موبایل (کد کشور + شماره) */
.phone-input-group {
    display: flex;
    direction: ltr;
}

.phone-input-group select {
    width: 38%;
    border: 1px solid var(--line);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    background-color: #faf9f7;
    padding: 0.8rem;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--navy);
    outline: none;
}

.phone-input-group input {
    width: 62%;
    border: 1px solid var(--line);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: 0.8rem;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.phone-input-group input:focus, .phone-input-group select:focus {
    border-color: var(--navy);
}

/* =========================================
   7. OTP Components
========================================= */
.otp-container {
    display: flex;
    justify-content: space-between;
    direction: ltr;
    margin-bottom: 1.5rem;
}

.otp-box {
    width: 45px;
    height: 55px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #faf9f7;
    outline: none;
}

.otp-box:focus {
    border-color: var(--rose);
    background: var(--white);
}

.otp-timer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.timer-badge {
    background: var(--paper);
    padding: 4px 10px;
    border-radius: 20px;
    color: var(--muted);
    font-family: monospace;
    font-size: 0.95rem;
}

.resend-btn {
    background: none;
    border: none;
    color: var(--teal);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.resend-btn:disabled {
    color: var(--muted);
    cursor: not-allowed;
}

/* =========================================
   8. Specific Components (Tabs, Alerts, Traps)
========================================= */
/* تب‌های لاگین (رمز/OTP) */
.auth-mode-tabs {
    display: flex;
    background: #eeebe3;
    padding: 4px;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    gap: 4px;
}

.auth-mode-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-mode-btn.active {
    background: var(--white);
    color: var(--navy);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* هشدارها */
.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    display: none;
    border: 1px solid #ffeeba;
}

.text-danger {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 5px;
    display: block;
}

.auth-links {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.auth-links a {
    color: var(--teal);
    font-weight: 700;
    text-decoration: none;
    transition: color 0.2s;
}

.auth-links a:hover {
    text-decoration: underline;
    color: var(--navy);
}

/* تله ربات‌ها */
.website_url_trap {
    display: none !important;
}

/* =========================================
   9. Language Switcher (Shared)
========================================= */
.lang-switcher-wrap {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px dashed var(--line);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.lang-switcher-label {
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 500;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.lang-switcher {
    display: inline-flex;
    align-items: center;
    background: #ede9df;
    padding: 3px;
    border-radius: 30px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}

.lang-btn {
    border: none;
    background: transparent;
    padding: 5px 14px;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.2;
}

.lang-btn:hover:not(.active) {
    color: var(--navy);
}

.lang-btn.active {
    background: var(--white);
    color: var(--rose);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* =========================================
   10. Onboarding Specific Styles
========================================= */
.app-container {
    width: 100%;
    max-width: 600px;
    height: 100dvh;
    background-color: var(--white);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(0,0,0,0.25);
}

@media (min-width: 600px) {
    .app-container {
        height: 92dvh;
        border-radius: var(--radius-lg);
        margin: auto; /* برای وسط چین شدن در دسکتاپ */
    }
}

.top-bar {
    width: 100%;
    height: 65px;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    position: relative;
    z-index: 50;
    background-color: var(--white);
}

.lang-switch, .skip-btn {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--navy);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--paper);
    border-color: transparent;
}

.lang-switch:hover, .skip-btn:hover {
    border-color: var(--navy);
}

.slider-viewport {
    flex: 1;
    width: 100%;
    overflow: hidden;
    position: relative;
}

.slider-track {
    display: flex;
    height: 100%;
    width: 100%;
    transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

.slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem;
    text-align: center;
    user-select: none;
}

.slide-img {
    width: 250px;
    height: 250px;
    max-width: 70vw;
    max-height: 70vw;
    background-color: var(--paper);
    border-radius: 50%;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 4px solid var(--paper);
    box-shadow: 0 10px 30px rgba(27,42,56,0.06);
}

.slide-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.slide-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 0.85rem;
    line-height: 1.4;
}

.slide-desc {
    font-size: 0.95rem;
    color: var(--muted);
    line-height: 1.7;
    max-width: 440px;
}

.bottom-nav {
    width: 100%;
    padding: 1.25rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background-color: var(--white);
    flex-shrink: 0;
    z-index: 50;
}

.dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    direction: ltr !important;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--line);
    transition: all 0.3s ease;
}

.dot.active {
    width: 26px;
    border-radius: 4px;
    background-color: var(--rose);
}

.actions {
    display: flex;
    gap: 1rem;
    width: 100%;
}
