/* ===== Servo Suite — Auth Screens ===== */

/* --- Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
}

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+Arabic:wght@400;500;600;700&display=swap');

/* --- Design Tokens --- */
:root {
    --auth-bg: #FFFFFF;
    --auth-surface: #F8FAFC;
    --auth-surface-raised: #FFFFFF;
    --auth-text-primary: #111827;
    --auth-text-secondary: #475569;
    --auth-text-muted: #94A3B8;
    --auth-border: #E2E8F0;
    --auth-primary: #422AD5;
    --auth-primary-hover: #3520B0;
    --auth-primary-active: #2A1A82;
    --auth-primary-light: rgba(66, 42, 213, 0.1);
    --auth-primary-ring: rgba(66, 42, 213, 0.2);
    --auth-error: #EF4444;
    --auth-success: #22C55E;
    --auth-warning: #F59E0B;
    --auth-radius: 8px;
    --auth-radius-lg: 12px;
    --auth-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --auth-font: 'Inter', 'Noto Sans Arabic', system-ui, sans-serif;
}

.dark {
    --auth-bg: #0F0F14;
    --auth-surface: #1A1A24;
    --auth-surface-raised: #22222E;
    --auth-text-primary: #F1F5F9;
    --auth-text-secondary: #94A3B8;
    --auth-text-muted: #64748B;
    --auth-border: #2D2D3A;
    --auth-primary: #422AD5;
    --auth-primary-hover: #3520B0;
    --auth-primary-active: #2A1A82;
    --auth-primary-light: rgba(139, 123, 232, 0.15);
    --auth-primary-ring: rgba(139, 123, 232, 0.3);
    --auth-error: #EF4444;
    --auth-success: #22C55E;
    --auth-warning: #F59E0B;
    --auth-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* --- Base --- */
.auth-page {
    font-family: var(--auth-font);
    background: var(--auth-bg);
    color: var(--auth-text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transition: background 0.2s, color 0.2s;
}

[dir="rtl"] .auth-page {
    font-family: 'Noto Sans Arabic', 'Inter', system-ui, sans-serif;
}

.auth-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    width: 100%;
    max-width: 420px;
    animation: authFadeIn 0.3s ease-out;
}

/* --- Logo --- */
.auth-logo {
    height: 36px;
    width: auto;
}

.dark .auth-logo path[fill="#111827"] { fill: #F1F5F9; }
.dark .auth-logo path[fill="#4B5563"] { fill: #94A3B8; }

/* --- Card --- */
.auth-card {
    background: var(--auth-surface-raised);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-lg);
    padding: 32px;
    width: 100%;
    box-shadow: var(--auth-shadow);
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.auth-card-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--auth-text-primary);
}

.auth-card-subtitle {
    font-size: 14px;
    color: var(--auth-text-secondary);
    margin: 0 0 24px;
    line-height: 1.5;
}

/* --- Inputs --- */
.auth-input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    background: var(--auth-bg);
    color: var(--auth-text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-input:focus {
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 2px var(--auth-primary-ring);
}

.auth-input::placeholder {
    color: var(--auth-text-muted);
}

.auth-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-input.error {
    border-color: var(--auth-error);
}

.auth-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--auth-text-primary);
}

/* --- OTP Input --- */
.otp-group {
    display: flex;
    gap: 8px;
    justify-content: center;
    direction: ltr;
}

.otp-cell {
    width: 44px;
    height: 48px;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    background: var(--auth-bg);
    color: var(--auth-text-primary);
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    caret-color: transparent;
}

.otp-cell:focus {
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 2px var(--auth-primary-ring);
}

.otp-cell.error {
    border-color: var(--auth-error);
    animation: authShake 0.2s ease-in-out 0s 3;
}

.otp-cell.filled {
    border-color: var(--auth-primary);
}

/* --- Buttons --- */
.auth-btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 40px;
    background: var(--auth-primary);
    color: #FFFFFF;
    font-family: inherit;
    font-weight: 500;
    font-size: 14px;
    border: none;
    border-radius: var(--auth-radius);
    cursor: pointer;
    transition: background 0.15s;
}

.auth-btn-primary:hover { background: var(--auth-primary-hover); }
.auth-btn-primary:active { background: var(--auth-primary-active); }
.auth-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-btn-outline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 40px;
    background: transparent;
    color: var(--auth-text-primary);
    font-family: inherit;
    font-weight: 500;
    font-size: 14px;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    cursor: pointer;
    transition: background 0.15s;
}

.auth-btn-outline:hover { background: var(--auth-surface); }

.auth-btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--auth-primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.dark .auth-btn-ghost { color: #8B7BE8; }
.auth-btn-ghost:hover { background: var(--auth-primary-light); }
.auth-btn-ghost:disabled { opacity: 0.5; cursor: not-allowed; }

a.auth-btn-ghost { text-decoration: none; }

/* --- Divider --- */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--auth-text-muted);
    font-size: 13px;
    margin: 20px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--auth-border);
}

/* --- Error & Timer --- */
.auth-error-msg {
    color: var(--auth-error);
    font-size: 13px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.auth-timer {
    color: var(--auth-text-muted);
    font-size: 13px;
    text-align: center;
}

.auth-lockout-banner {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--auth-radius);
    padding: 12px 14px;
    font-size: 13px;
    color: var(--auth-error);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

/* --- Stepper --- */
.auth-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 28px;
}

[dir="rtl"] .auth-stepper { flex-direction: row-reverse; }

.auth-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.auth-step-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid var(--auth-border);
    color: var(--auth-text-muted);
    background: var(--auth-bg);
    transition: all 0.2s;
}

.auth-step-circle.active,
.auth-step-circle.completed {
    border-color: var(--auth-primary);
    color: #FFFFFF;
    background: var(--auth-primary);
}

.auth-step-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--auth-text-muted);
}

.auth-step-label.active {
    color: var(--auth-text-secondary);
}

.auth-step-line {
    flex: 1;
    height: 2px;
    background: var(--auth-border);
    margin: 0 8px;
    transition: background 0.2s;
    align-self: flex-start;
    margin-top: 14px;
    min-width: 40px;
}

.auth-step-line.active { background: var(--auth-primary); }

/* --- Tenant Card --- */
.auth-tenant-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    cursor: pointer;
    transition: all 0.15s;
    background: transparent;
    width: 100%;
    text-align: start;
    text-decoration: none;
    color: inherit;
    font-family: inherit;
}

.auth-tenant-card:hover {
    background: var(--auth-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.auth-tenant-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--auth-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.auth-tenant-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--auth-text-primary);
}

.auth-tenant-role {
    font-size: 12px;
    color: var(--auth-text-muted);
    margin-top: 2px;
}

.auth-tenant-chevron {
    margin-inline-start: auto;
    opacity: 0.3;
    flex-shrink: 0;
}

/* --- Invitation Card --- */
.auth-invite-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--auth-surface);
    border: 1px solid var(--auth-border);
    border-radius: 10px;
    text-align: start;
}

.auth-invite-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: var(--auth-primary-light);
    color: var(--auth-primary);
    flex-shrink: 0;
}

.dark .auth-invite-icon { color: #8B7BE8; }

.auth-invite-name {
    font-weight: 600;
    font-size: 15px;
}

.auth-invite-by {
    font-size: 13px;
    color: var(--auth-text-muted);
    margin-top: 2px;
}

/* --- Footer --- */
.auth-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--auth-text-muted);
}

.auth-footer-lang {
    display: flex;
    gap: 8px;
    align-items: center;
}

.auth-footer-lang-sep {
    opacity: 0.4;
}

.auth-footer-user {
    font-size: 13px;
    color: var(--auth-text-secondary);
}

/* --- Spinner --- */
.auth-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: authSpin 0.6s linear infinite;
}

.auth-spinner-dark {
    border-color: rgba(66, 42, 213, 0.2);
    border-top-color: var(--auth-primary);
}

/* --- Checkbox --- */
.auth-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--auth-primary);
    cursor: pointer;
    margin-top: 3px;
    flex-shrink: 0;
}

/* --- Phone Input --- */
.auth-phone-group {
    display: flex;
    gap: 8px;
}

.auth-phone-prefix {
    position: relative;
}

.auth-phone-prefix select {
    width: 100px;
    padding-inline-start: 36px;
    appearance: none;
    cursor: pointer;
}

.auth-phone-flag {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    inset-inline-start: 10px;
    font-size: 16px;
    pointer-events: none;
}

/* --- Helper classes --- */
.auth-text-center { text-align: center; }
.auth-text-secondary { color: var(--auth-text-secondary); }
.auth-text-muted { color: var(--auth-text-muted); }
.auth-text-sm { font-size: 13px; }
.auth-text-xs { font-size: 12px; }
.auth-mt-4 { margin-top: 16px; }
.auth-mt-5 { margin-top: 20px; }
.auth-mb-5 { margin-bottom: 20px; }
.auth-gap-10 { gap: 10px; }
.auth-flex-col { display: flex; flex-direction: column; }
.auth-hidden { display: none !important; }

/* --- Animations --- */
@keyframes authShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

@keyframes authFadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes authSlideLeft {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

[dir="rtl"] @keyframes authSlideLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

.auth-animate-slide { animation: authSlideLeft 0.2s ease-out; }

/* --- Responsive --- */
@media (max-width: 640px) {
    .auth-page {
        padding: 16px;
        align-items: flex-start;
        padding-top: 48px;
    }

    .auth-card {
        padding: 24px 20px;
        border-radius: var(--auth-radius);
    }

    .auth-wrapper {
        max-width: 100%;
    }

    .otp-cell {
        width: 40px;
        height: 44px;
        font-size: 18px;
    }
}

/* --- Scrollbar --- */
.auth-page ::-webkit-scrollbar { width: 6px; }
.auth-page ::-webkit-scrollbar-track { background: transparent; }
.auth-page ::-webkit-scrollbar-thumb { background: var(--auth-border); border-radius: 3px; }
