/**
 * ============================================================
 * SONIC STOREFRONT — Login Page CSS
 * Premium glassmorphism design, mobile-first, RTL
 * ============================================================
 */

/* ── Reset & Base ─────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: var(--page-bg);
    font-family: 'Cairo', 'Tajawal', sans-serif;
}

/* ── Animated Background ──────────────────────────────────── */
.login-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.login-bg__gradient {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(var(--accent-rgb), 0.15) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(var(--accent-rgb), 0.10) 0%, transparent 55%),
        linear-gradient(160deg, var(--page-bg) 0%, var(--surface-bg) 100%);
}

.login-bg__orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.2;
    animation: orbFloat 8s ease-in-out infinite;
}

.login-bg__orb--1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(var(--accent-rgb), 0.5), transparent);
    top: -150px;
    left: -150px;
    animation-delay: 0s;
}

.login-bg__orb--2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(var(--accent-rgb), 0.3), transparent);
    bottom: -100px;
    right: -100px;
    animation-delay: 3s;
}

.login-bg__orb--3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.05), transparent);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 1.5s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%       { transform: translate(30px, -20px) scale(1.05); }
    66%       { transform: translate(-20px, 15px) scale(0.97); }
}

/* ── Grid Lines Overlay ───────────────────────────────────── */
.login-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
}

/* ── Main Card ────────────────────────────────────────────── */
.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 480px;
    margin: 20px;
    background: rgba(var(--card-bg-rgb), 0.82);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid rgba(var(--accent-rgb), 0.18);
    border-radius: 28px;
    padding: 48px 44px;
    box-shadow:
        0 32px 80px rgba(0,0,0,0.45),
        0 0 0 1px rgba(255,255,255,0.04),
        inset 0 1px 0 rgba(255,255,255,0.08);
    animation: cardReveal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cardReveal {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Logo Area ────────────────────────────────────────────── */
.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 36px;
    text-decoration: none;
}

.login-logo__img {
    max-height: 64px;
    max-width: 200px;
    object-fit: contain;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 12px rgba(var(--accent-rgb, 212,175,55), 0.4));
}

.login-logo__text {
    font-size: 1.7rem;
    font-weight: 900;
    color: var(--accent);
    letter-spacing: -0.5px;
    text-shadow: 0 0 30px rgba(var(--accent-rgb), 0.4);
}

/* ── Card Header ──────────────────────────────────────────── */
.login-head {
    text-align: center;
    margin-bottom: 32px;
}

.login-head__title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0 0 8px;
    line-height: 1.2;
}

.login-head__sub {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0;
}

/* ── Alert ────────────────────────────────────────────────── */
.login-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 24px;
    animation: alertSlide 0.3s ease;
    line-height: 1.5;
}

.login-alert--error {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.3);
    color: #fca5a5;
}

.login-alert--success {
    background: rgba(16,185,129,0.12);
    border: 1px solid rgba(16,185,129,0.3);
    color: #6ee7b7;
}

.login-alert i { margin-top: 2px; flex-shrink: 0; }

@keyframes alertSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Form Fields ──────────────────────────────────────────── */
.login-form { display: flex; flex-direction: column; gap: 0; }

.lf-group {
    position: relative;
    margin-bottom: 20px;
}

.lf-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted, #9CA3AF);
    margin-bottom: 8px;
    transition: color 0.2s;
}

.lf-input-wrap {
    position: relative;
}

.lf-icon {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted, #6B7280);
    font-size: 0.95rem;
    pointer-events: none;
    transition: color 0.25s;
    z-index: 2;
}

.lf-input {
    width: 100%;
    height: 54px;
    background: rgba(255,255,255,0.05);
    border: 1.5px solid rgba(255,255,255,0.10);
    border-radius: 14px;
    padding: 0 50px 0 20px;
    font-size: 0.97rem;
    font-family: inherit;
    color: var(--text-main, #F5F5F5);
    transition: all 0.25s ease;
    outline: none;
    direction: ltr;
    text-align: right;
}

.lf-input::placeholder {
    color: rgba(255,255,255,0.2);
    direction: rtl;
}

.lf-input:focus {
    border-color: var(--accent, #D4AF37);
    background: rgba(var(--accent-rgb, 212,175,55), 0.06);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb, 212,175,55), 0.12);
}

.lf-input:focus + .lf-icon,
.lf-group:focus-within .lf-icon { color: var(--accent, #D4AF37); }

.lf-group:focus-within .lf-label { color: var(--accent, #D4AF37); }

/* Valid / Invalid States */
.lf-input.is-valid {
    border-color: #10b981;
    background: rgba(16,185,129,0.05);
}
.lf-input.is-invalid {
    border-color: #ef4444;
    background: rgba(239,68,68,0.05);
}
.lf-field-msg {
    font-size: 0.78rem;
    margin-top: 6px;
    padding-right: 4px;
    display: none;
}
.lf-field-msg.show { display: block; }
.lf-field-msg.error { color: #f87171; }
.lf-field-msg.success { color: #34d399; }

/* ── Password Toggle ──────────────────────────────────────── */
.lf-pass-toggle {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted, #6B7280);
    cursor: pointer;
    padding: 4px;
    font-size: 0.95rem;
    transition: color 0.2s;
    z-index: 2;
    display: flex;
    align-items: center;
}

.lf-pass-toggle:hover { color: var(--accent, #D4AF37); }

/* ── Row (remember me + forgot) ───────────────────────────── */
.lf-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Custom Checkbox ──────────────────────────────────────── */
.lf-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.lf-checkbox input[type="checkbox"] {
    display: none;
}

.lf-checkbox__box {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.lf-checkbox input:checked ~ .lf-checkbox__box {
    background: var(--accent, #D4AF37);
    border-color: var(--accent, #D4AF37);
}

.lf-checkbox__box i {
    color: #0d0d0d;
    font-size: 0.7rem;
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
}

.lf-checkbox input:checked ~ .lf-checkbox__box i {
    opacity: 1;
    transform: scale(1);
}

.lf-checkbox__label {
    font-size: 0.88rem;
    color: var(--text-muted, #9CA3AF);
    font-weight: 600;
}

/* ── Forgot Link ──────────────────────────────────────────── */
.lf-forgot {
    font-size: 0.88rem;
    color: var(--accent, #D4AF37);
    font-weight: 700;
    text-decoration: none;
    transition: opacity 0.2s;
}
.lf-forgot:hover { opacity: 0.75; text-decoration: underline; }

/* ── Submit Button ────────────────────────────────────────── */
.lf-btn-submit {
    position: relative;
    width: 100%;
    height: 56px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    border: none;
    border-radius: 16px;
    font-size: 1.05rem;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: var(--shadow-accent);
    letter-spacing: 0.3px;
}

.lf-btn-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    opacity: 0.9;
}

.lf-btn-submit:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 4px 16px rgba(var(--accent-rgb, 212,175,55), 0.3);
}

.lf-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Shine effect */
.lf-btn-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s;
}
.lf-btn-submit:hover::before { left: 160%; }

/* Loading spinner inside button */
.lf-btn-submit .spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(0,0,0,0.3);
    border-top-color: #0d0d0d;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.lf-btn-submit.loading .spinner { display: block; }
.lf-btn-submit.loading .btn-text { display: none; }

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

/* ── Divider ──────────────────────────────────────────────── */
.lf-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 28px 0;
    color: rgba(255,255,255,0.2);
    font-size: 0.8rem;
}
.lf-divider::before,
.lf-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.08);
}

/* ── Footer Link ──────────────────────────────────────────── */
.lf-footer {
    text-align: center;
    margin-top: 28px;
    font-size: 0.9rem;
    color: var(--text-muted, #9CA3AF);
}

.lf-footer a {
    color: var(--accent, #D4AF37);
    font-weight: 800;
    text-decoration: none;
    transition: opacity 0.2s;
}
.lf-footer a:hover { opacity: 0.8; text-decoration: underline; }

/* ── Rate Limit Warning ───────────────────────────────────── */
.lf-rate-warn {
    display: none;
    font-size: 0.8rem;
    color: #f59e0b;
    margin-top: 8px;
    text-align: center;
}
.lf-rate-warn.show { display: block; }

/* ── Lockout Countdown ────────────────────────────────────── */
.lf-lockout {
    display: none;
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: 12px;
    padding: 14px 18px;
    text-align: center;
    color: #f87171;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 20px;
}
.lf-lockout.show { display: block; }
.lf-lockout__timer { font-size: 1.4rem; font-weight: 900; display: block; margin-top: 4px; }

/* ── Security Badge ───────────────────────────────────────── */
.lf-security-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.25);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 520px) {
    .login-card {
        margin: 0;
        min-height: 100dvh;
        border-radius: 0;
        padding: 40px 24px 32px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        border: none;
    }

    .login-logo__text { font-size: 1.5rem; }
    .login-head__title { font-size: 1.5rem; }

    .lf-input { height: 50px; font-size: 1rem; }
    .lf-btn-submit { height: 52px; }
}

@media (min-width: 521px) and (max-width: 768px) {
    .login-card { padding: 40px 32px; }
}
