﻿/* ===================================================
   auth.css — صفحه ورود/ثبت‌نام فیلمینجو
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #f9fafb;
    --card-bg:   #ffffff;
    --border:    #e5e7eb;
    --text:      #111827;
    --muted:     #6b7280;
    --primary:   #008CFF;
    --green:     #22c55e;
    --green-hov: #16a34a;
    --amber:     #f59e0b;
    --amber-hov: #d97706;
    --red:       #ef4444;
    --radius:    12px;
}

html, body {
    font-family: 'Vazirmatn', sans-serif;
    direction: rtl;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
}

/* ─── Layout ─────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 16px 48px;
}

/* ─── Logo / Brand ───────────────────────────────── */
.auth-logo {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.04em;
    text-decoration: none;
    margin-bottom: 8px;
    display: block;
    text-align: center;
}
.auth-logo:hover { color: #0070CC; }

/* ─── Topbar (back + title) ──────────────────────── */
.auth-topbar {
    width: 100%;
    max-width: 560px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.auth-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--muted);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 0;
    transition: color .2s;
    flex-shrink: 0;
}
.auth-back-btn:hover { color: var(--primary); }
.auth-back-btn svg { width: 18px; height: 18px; }

.auth-page-title {
    flex: 1;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    padding-left: 28px; /* compensate for back btn width */
}

/* ─── Step wrapper — عرض ثابت برای همه مراحل ──────── */
.auth-step {
    width: 100%;
    max-width: 560px;
}

/* ─── Card ───────────────────────────────────────── */
.auth-card {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
}

.auth-card-hint {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 20px;
    line-height: 1.65;
}

/* ─── Form fields ────────────────────────────────── */
.auth-field {
    position: relative;
    margin-bottom: 16px;
}
.auth-field-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    display: flex;
    pointer-events: none;
}
.auth-field-icon svg { width: 18px; height: 18px; }

.auth-input {
    width: 100%;
    padding: 11px 42px 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    background: #f9fafb;
    color: var(--text);
    transition: border-color .2s, box-shadow .2s;
    direction: ltr;
    text-align: right;
}
.auth-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,140,255,.12);
    background: #fff;
}
.auth-input::placeholder { color: #9ca3af; font-family: inherit; direction: rtl; }

/* eye toggle */
.auth-eye-btn {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    align-items: center;
    transition: color .2s;
}
.auth-eye-btn:hover { color: var(--primary); }
.auth-eye-btn svg { width: 18px; height: 18px; }

/* ─── Buttons ────────────────────────────────────── */
.auth-btn {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s, transform .1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.auth-btn:active { transform: scale(0.98); }

.auth-btn-green  { background: var(--green);  color: #fff; }
.auth-btn-green:hover  { background: var(--green-hov); }

.auth-btn-amber  { background: var(--amber);  color: #fff; }
.auth-btn-amber:hover  { background: var(--amber-hov); }

.auth-btn-google {
    background: #fff;
    color: #374151;
    border: 1.5px solid var(--border);
}
.auth-btn-google:hover { background: #f3f4f6; }

/* ─── Divider «یا» ───────────────────────────────── */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0;
    color: var(--muted);
    font-size: 13px;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ─── Forgot link ────────────────────────────────── */
.auth-forgot-link {
    display: block;
    text-align: center;
    color: var(--primary);
    font-size: 13px;
    text-decoration: none;
    margin-top: 10px;
    cursor: pointer;
}
.auth-forgot-link:hover { text-decoration: underline; }

/* ─── OTP option rows ────────────────────────────── */
.auth-opt-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.auth-opt-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
}
.auth-opt-row:hover { border-color: var(--primary); background: #f0fdfe; }
.auth-opt-row-left { display: flex; align-items: center; gap: 10px; }
.auth-opt-row-left svg { width: 18px; height: 18px; color: var(--primary); }
.auth-opt-row svg.arrow { width: 16px; height: 16px; color: var(--muted); transform: rotate(180deg); }

/* ─── Radio group (forgot) ───────────────────────── */
.auth-radio-group { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.auth-radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 15px;
}
.auth-radio-label input[type="radio"] { display: none; }
.auth-radio-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    transition: border-color .2s, background .2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-radio-label input[type="radio"]:checked + .auth-radio-dot {
    border-color: var(--amber);
    background: var(--amber);
}
.auth-radio-label input[type="radio"]:checked + .auth-radio-dot::after {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #fff;
}
.auth-radio-field { margin-top: 10px; display: none; }
.auth-radio-field.visible { display: block; }

/* ─── OTP boxes ──────────────────────────────────── */
.otp-wrapper {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 18px;
    direction: ltr;
}
.otp-box {
    width: 52px;
    height: 60px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color .2s, box-shadow .2s;
    caret-color: var(--primary);
}
.otp-box:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,140,255,.15);
}
.otp-box.filled {
    border-color: var(--primary);
    background: #f0fdfe;
}

.otp-security-note {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: 16px;
    text-align: center;
}

/* ─── Timer ──────────────────────────────────────── */
.auth-timer {
    text-align: center;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 16px;
    min-height: 22px;
}
.auth-timer-value { font-weight: 700; color: var(--text); }
.auth-resend-link {
    display: none;
    text-align: center;
    font-size: 13px;
    color: var(--primary);
    cursor: pointer;
    text-decoration: underline;
    margin-bottom: 16px;
}

/* ─── Support section ────────────────────────────── */
.auth-support {
    width: 100%;
    margin-top: 20px;
}
.auth-support-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
    transition: border-color .2s;
}
.auth-support-toggle:hover { border-color: var(--primary); color: var(--primary); }
.auth-support-toggle svg { width: 16px; height: 16px; transition: transform .25s; }
.auth-support-toggle.open svg { transform: rotate(180deg); }
.auth-support-body {
    display: none;
    border: 1.5px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 14px 16px;
    font-size: 13px;
    color: var(--muted);
    line-height: 2;
    background: #fff;
}
.auth-support-body a { color: var(--primary); text-decoration: none; }
.auth-support-body a:hover { text-decoration: underline; }

/* ─── Google icon inline SVG ─────────────────────── */
.g-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ─── دکمه ثانویه (ورود به حساب) ────────────────── */
.auth-btn-secondary {
    background: #f3f4f6;
    color: var(--primary);
    border: 1.5px solid #e5e7eb;
    font-weight: 600;
}
.auth-btn-secondary:hover { background: #e5e7eb; }

/* ─── دکمه آیکون‌دار ─────────────────────────────── */
.auth-btn-icon {
    gap: 10px;
}

/* ─── Confirm step ───────────────────────────────── */
.auth-card-center {
    text-align: center;
}
.auth-confirm-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 14px;
    line-height: 1.5;
}
.auth-confirm-subtitle {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 28px;
    line-height: 1.8;
}
.auth-confirm-subtitle bdi {
    color: var(--text);
    font-weight: 600;
}
.auth-confirm-divider {
    margin: 24px 0 16px;
    color: var(--muted);
    font-size: 14px;
}

/* ─── Field error message ────────────────────────── */
.auth-field-error {
    font-size: 12.5px;
    color: var(--red);
    margin-top: 6px;
    line-height: 1.5;
    display: none;
    text-align: right;
    padding-right: 2px;
}
.auth-field-error.visible {
    display: block;
}
/* خطای OTP وسط‌چین است چون باکس‌ها وسط هستند */
#otp-error {
    text-align: center;
    padding-right: 0;
}
/* خطای کلی مراحل (فراموشی رمز، رمز جدید) هم وسط */
#forgot-error {
    text-align: center;
    padding-right: 0;
}

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 480px) {
    .auth-card { padding: 22px 16px 20px; }
    .otp-box { width: 44px; height: 54px; font-size: 20px; }
    .otp-wrapper { gap: 7px; }
    .auth-confirm-title { font-size: 17px; }
}

/* ═══════════════════════════════════════════════
   مودال حداکثر دستگاه (max_devices_reached)
═══════════════════════════════════════════════ */
.auth-devices-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
}

.auth-devices-modal {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    color: #f1f5f9;
    font-family: 'Vazirmatn', sans-serif;
    direction: rtl;
}

.auth-devices-modal-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1.0625rem;
    font-weight: 700;
    color: #f59e0b;
    margin-bottom: 0.875rem;
}

.auth-devices-modal-desc {
    font-size: 0.875rem;
    color: #94a3b8;
    line-height: 1.7;
    margin-bottom: 1.125rem;
}

.auth-devices-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.auth-device-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 10px;
    padding: 0.75rem 1rem;
}

.auth-device-item-info {
    flex: 1;
    min-width: 0;
}

.auth-device-item-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-device-item-meta {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auth-device-logout-btn {
    flex-shrink: 0;
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    border-radius: 7px;
    padding: 0.35rem 0.8rem;
    font-size: 0.8125rem;
    font-family: 'Vazirmatn', sans-serif;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.auth-device-logout-btn:hover:not(:disabled) {
    background: #ef4444;
    color: #fff;
}

.auth-device-logout-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.auth-btn-secondary {
    width: 100%;
    background: transparent;
    border: 1px solid #475569;
    color: #94a3b8;
    border-radius: var(--radius);
    padding: 0.75rem;
    font-size: 0.9375rem;
    font-family: 'Vazirmatn', sans-serif;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    font-weight: 500;
}

.auth-btn-secondary:hover {
    border-color: #94a3b8;
    color: #f1f5f9;
}
