/* ============================================================
   SignalAds Auth Template — full-page phone OTP login/register.
   Based on .dev/auth_1.html
   ============================================================ */

.sa-auth-wrap {
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    direction: rtl;
    min-height: 100vh;
    background: #ffffff;
    --sa-accent: #7a9ae6;
    --sa-accent-dark: #6282d6;
    --sa-bg-soft: #f0f4f8;
    --sa-line: #e2e8f0;
    --sa-text: #1f2937;
    --sa-muted: #6b7280;
    --sa-danger: #dc2626;
    --sa-success: #16a34a;
    --sa-radius: 10px;
}

/* Two-column layout */
.sa-auth-wrap .row.g-0 { min-height: 100vh; }

/* Illustration side — image fills the whole panel edge-to-edge */
.sa-auth-illustration {
    background-color: var(--sa-tpl-illustration-bg, var(--sa-bg-soft)) !important;
    display: block;
    padding: 0;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}
.sa-auth-illustration-img {
    display: block;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    object-fit: cover;
    object-position: center center;
}
/* Contain mode: image at its natural aspect, centered, fixed 600x500 box */
.sa-auth-illustration-img--contain {
    width: auto;
    height: auto;
    max-width: 600px;
    max-height: 500px;
    object-fit: contain;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 0;
}

/* Form side background driven by admin color picker */
.sa-auth-form-side {
    background-color: var(--sa-tpl-form-bg, #ffffff) !important;
}

/* "Content side" — when no image, content occupies the left column */
.sa-auth-content-side {
    background-color: var(--sa-tpl-illustration-bg, var(--sa-bg-soft)) !important;
    padding: 3rem 2.5rem;
    min-height: 100vh;
    overflow: auto;
    align-items: center !important;
    justify-content: center !important;
}
.sa-auth-content--side {
    max-width: 480px;
    margin: auto;
    color: var(--sa-text);
    line-height: 1.7;
}
.sa-auth-content--side > *:first-child { margin-top: 0; }
.sa-auth-content--side > *:last-child  { margin-bottom: 0; }
.sa-auth-content--side h1 { font-size: 1.9rem; margin: 0.6em 0 0.4em; }
.sa-auth-content--side h2 { font-size: 1.6rem; margin: 0.6em 0 0.4em; }
.sa-auth-content--side h3 { font-size: 1.35rem; margin: 0.6em 0 0.4em; }
.sa-auth-content--side h4 { font-size: 1.15rem; margin: 0.6em 0 0.4em; }
.sa-auth-content--side p  { margin: 0.6em 0; font-size: 1.02rem; }

/* Empty illustration variant — just a colored panel */
.sa-auth-illustration--empty {
    background-image: none !important;
}

/* Form side */
.sa-auth-form-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem 2rem;
    min-height: 100vh;
}

/* Logo */
.sa-auth-logo {
    font-size: 3.5rem;
    color: var(--sa-accent);
    margin-bottom: 1rem;
    line-height: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}
.sa-auth-logo-icon,
.sa-auth-logo svg {
    width: 56px;
    height: 56px;
    display: block;
    color: var(--sa-accent);
}
.sa-auth-logo-img {
    display: block;
    max-height: 64px;
    width: auto;
    max-width: 240px;
    margin: 0 auto 1rem;
    object-fit: contain;
}

/* Custom rich content above the form */
.sa-auth-content {
    width: 100%;
    max-width: 420px;
    margin: 0 0 1.25rem;
    color: var(--sa-text);
    line-height: 1.6;
}
.sa-auth-content > *:first-child { margin-top: 0; }
.sa-auth-content > *:last-child  { margin-bottom: 0; }
.sa-auth-content h1,
.sa-auth-content h2,
.sa-auth-content h3,
.sa-auth-content h4 {
    font-weight: 700;
    line-height: 1.3;
    margin: 0.6em 0 0.4em;
    color: var(--sa-text);
}
.sa-auth-content h1 { font-size: 1.6rem; }
.sa-auth-content h2 { font-size: 1.4rem; }
.sa-auth-content h3 { font-size: 1.2rem; }
.sa-auth-content h4 { font-size: 1rem; }
.sa-auth-content p { margin: 0.5em 0; }
.sa-auth-content a {
    color: var(--sa-accent);
    text-decoration: none;
    font-weight: 600;
}
.sa-auth-content a:hover { text-decoration: underline; }
.sa-auth-content ul,
.sa-auth-content ol { margin: 0.5em 0; padding-right: 1.5em; }
.sa-auth-content ul li { list-style: disc; }
.sa-auth-content ol li { list-style: decimal; }
.sa-auth-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 0.5em 0;
}

.sa-auth-title {
    font-weight: 700 !important;
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    color: var(--sa-text);
    text-align: center;
}

.sa-auth-subtitle {
    color: var(--sa-muted);
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Forms */
.sa-auth-form {
    width: 100%;
    max-width: 420px;
}

.sa-auth-field {
    margin-bottom: 0.85rem;
}

/* Input + button share the same height via box-sizing + min-height */
.sa-auth-input {
    border-radius: var(--sa-radius) !important;
    border: 1px solid var(--sa-line) !important;
    padding: 0 1.2rem !important;
    font-size: 1rem !important;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
    font-family: inherit;
    min-height: 50px !important;
    box-sizing: border-box !important;
    display: block;
    width: 100%;
}

.sa-auth-input:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(122, 154, 230, .22) !important;
    border-color: var(--sa-accent) !important;
}

.sa-auth-otp-input {
    letter-spacing: 0.5em;
    text-align: center;
    font-size: 1.2rem !important;
    font-weight: 700;
}

/* Primary button — disabled by default, becomes saturated when valid input.
   Matches the input's height exactly (min-height: 50px, box-sizing: border-box). */
.sa-auth-btn-primary {
    width: 100%;
    background: var(--sa-accent);
    border: 0;
    color: #fff;
    border-radius: var(--sa-radius);
    padding: 0 1rem;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .2s ease, transform .1s ease, opacity .2s ease, box-shadow .2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    box-sizing: border-box;
    margin-top: 0;
    margin-bottom: 0.85rem;
}
/* Disabled (default / invalid input): desaturated, grayish, no pointer */
.sa-auth-btn-primary:disabled,
.sa-auth-btn-primary[disabled] {
    background: #cbd5e1 !important; /* slate-300 — desaturated */
    color: #f8fafc !important;
    opacity: 0.75;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}
/* Enabled (valid input): fully saturated + brighter + glow */
.sa-auth-btn-primary:not(:disabled) {
    background: linear-gradient(135deg, var(--sa-accent) 0%, var(--sa-accent-dark) 100%);
    color: #fff;
    box-shadow: 0 6px 14px -4px rgba(122, 154, 230, 0.55);
}
.sa-auth-btn-primary:not(:disabled):hover {
    background: var(--sa-accent-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 10px 18px -6px rgba(122, 154, 230, 0.7);
}
.sa-auth-btn-primary:not(:disabled):active {
    transform: translateY(1px);
}

/* Spinner inside button */
.sa-auth-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    display: inline-block;
    animation: sa-auth-spin 0.75s linear infinite;
}
@keyframes sa-auth-spin { to { transform: rotate(360deg); } }

/* OTP step hint */
.sa-auth-otp-hint {
    text-align: center;
    color: var(--sa-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.sa-auth-otp-hint code {
    background: var(--sa-bg-soft);
    color: var(--sa-text);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Link buttons (resend, change phone) */
.sa-auth-btn-link {
    width: 100%;
    background: transparent;
    color: var(--sa-accent);
    border: 0;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.5rem;
    text-align: center;
}
.sa-auth-btn-link:hover:not(:disabled) {
    text-decoration: underline;
    background: transparent;
    color: var(--sa-accent-dark);
}
.sa-auth-btn-link:disabled {
    color: var(--sa-muted);
    cursor: not-allowed;
    opacity: .7;
}
.sa-auth-change-phone {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--sa-muted);
    font-weight: 500;
}

/* Footer */
.sa-auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--sa-muted);
    font-size: 0.85rem;
    max-width: 420px;
}
.sa-auth-link {
    color: var(--sa-accent);
    text-decoration: none;
    font-weight: 500;
}
.sa-auth-link:hover {
    text-decoration: underline;
}

/* ===== Toasts ===== */
.sa-auth-toast-wrap {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: max-content;
    max-width: 92vw;
}
.sa-auth-toast {
    background: #fff;
    color: var(--sa-text);
    padding: 12px 18px;
    border-radius: var(--sa-radius);
    box-shadow: 0 12px 30px -10px rgba(15,23,42,.25), 0 1px 3px rgba(15,23,42,.06);
    border: 1px solid var(--sa-line);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    pointer-events: auto;
    animation: sa-toast-in .25s ease;
}
@keyframes sa-toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.sa-auth-toast.sa-toast-out {
    animation: sa-toast-out .25s ease forwards;
}
@keyframes sa-toast-out {
    to { opacity: 0; transform: translateY(-8px); }
}
.sa-auth-toast .sa-toast-ic {
    width: 22px; height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    color: #fff;
    font-size: 14px;
}
.sa-auth-toast.is-ok    { border-color: rgba(22,163,74,.25); }
.sa-auth-toast.is-ok    .sa-toast-ic { background: var(--sa-success); }
.sa-auth-toast.is-err   { border-color: rgba(220,38,38,.25); }
.sa-auth-toast.is-err   .sa-toast-ic { background: var(--sa-danger); }
.sa-auth-toast.is-info  .sa-toast-ic { background: var(--sa-accent); }
.sa-auth-toast.is-warn  { border-color: rgba(217,119,6,.3); }
.sa-auth-toast.is-warn  .sa-toast-ic { background: #d97706; }
.sa-auth-toast .sa-toast-msg { flex: 1; }
.sa-auth-toast .sa-toast-x {
    background: transparent;
    border: 0;
    color: var(--sa-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 0 0 4px;
}

/* ===== "Already logged in" card ===== */
.sa-auth-body { margin: 0; }

.sa-auth-logged-in-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--sa-bg-soft);
    border: 1px solid var(--sa-line);
    border-right: 4px solid var(--sa-accent);
    border-radius: var(--sa-radius);
    padding: 18px 20px;
    width: 100%;
    max-width: 420px;
    box-sizing: border-box;
}
.sa-auth-logged-in-avatar {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fff;
    color: var(--sa-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.sa-auth-logged-in-body {
    flex: 1;
    min-width: 0;
}
.sa-auth-logged-in-label {
    margin: 0;
    font-size: 0.85rem;
    color: var(--sa-muted);
    margin-bottom: 4px;
}
.sa-auth-logged-in-name {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--sa-text);
    line-height: 1.3;
}
.sa-auth-logged-in-email {
    margin: 2px 0 0;
    font-size: 0.85rem;
    color: var(--sa-muted);
    direction: ltr;
    text-align: right;
}
.sa-auth-logged-in-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    width: 100%;
    max-width: 420px;
}
.sa-auth-logged-in-actions .sa-auth-btn-primary {
    text-decoration: none;
}
.sa-auth-logged-in-actions .sa-auth-btn-link {
    margin-top: 0;
}
.sa-auth-logged-in-actions .bi { margin-left: 4px; }

/* ===== Mobile ===== */
@media (max-width: 991.98px) {
    .sa-auth-illustration { display: none !important; }
    .sa-auth-form-side {
        min-height: 100vh;
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .sa-auth-logo { font-size: 2.8rem; }
    .sa-auth-title { font-size: 1.4rem; }
    .sa-auth-input { padding: 0.75rem 1rem !important; font-size: 0.95rem !important; }
    .sa-auth-toast { min-width: 240px; font-size: 0.85rem; }
}
