/* ==========================================================
 * Login Styles for Sales Portal (Light Theme First)
 * Modern, Mobile-Optimized Aesthetic for Hoang Giang Solar
 * ========================================================== */

:root {
    --bg-page: #F1F5F9;
    --panel-bg: #FFFFFF;
    --border-color: #E2E8F0;
    --solar-orange: #FF6A1A;
    --solar-orange-hover: #EA580C;
    --solar-yellow: #F59E0B;
    --solar-red: #EF4444;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --input-bg: #F8FAFC;
    --input-border: #CBD5E1;
    --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --glow-orange: rgba(255, 106, 26, 0.15);
    --card-shadow: 0 20px 40px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark theme toggle compatibility - crisp dark mode */
[data-theme="dark"], body.dark-mode {
    --bg-page: #0F172A;
    --panel-bg: #1E293B;
    --border-color: #334155;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --input-bg: #0F172A;
    --input-border: #475569;
    --card-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

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

body {
    background-color: var(--bg-page) !important;
    background-image: none !important;
    font-family: var(--font-main);
    color: var(--text-main) !important;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    position: relative;
    overflow-x: hidden;
}

/* ── Animated Background Orbs ── */
.bg-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.bg-layer::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        conic-gradient(from 0deg at 30% 30%, rgba(249, 115, 22, 0.08) 0deg, transparent 120deg),
        conic-gradient(from 180deg at 70% 70%, rgba(14, 165, 233, 0.06) 0deg, transparent 120deg);
    animation: bgRotate 30s linear infinite;
}

@keyframes bgRotate {
    100% { transform: rotate(360deg); }
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    animation: float 10s ease-in-out infinite;
}

.bg-orb-1 {
    width: 400px; height: 400px;
    top: 5%; left: 5%;
    background: radial-gradient(circle, rgba(249, 115, 22, 0.22), transparent 70%);
}

.bg-orb-2 {
    width: 350px; height: 350px;
    bottom: 5%; right: 5%;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.18), transparent 70%);
    animation-delay: -5s;
}

.bg-orb-3 {
    width: 250px; height: 250px;
    top: 45%; left: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(245, 158, 11, 0.14), transparent 70%);
    animation-delay: -2.5s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(12px, -20px); }
    50% { transform: translate(-10px, 12px); }
    75% { transform: translate(15px, 8px); }
}

/* ── Grid Pattern ── */
.grid-pattern {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.8) 0%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.8) 0%, transparent 75%);
}

/* ── Login Container ── */
.login-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 440px;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-card {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 40px 32px 32px;
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
}

/* Top accent line */
.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--solar-orange), var(--solar-yellow), var(--solar-orange));
    background-size: 200% 100%;
    animation: shimmer 4s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: 200% 0; }
    50% { background-position: -200% 0; }
}

/* ── Logo ── */
.logo-section {
    text-align: center;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.logo-brand-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.login-brand-img {
    max-height: 96px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.05));
    transition: transform 0.3s ease;
}

.login-brand-img:hover {
    transform: scale(1.03);
}

.logo-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2.5px;
    font-weight: 700;
}

/* ── Alert Messages ── */
.alert-msg {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 20px;
    animation: fadeSlide 0.3s ease-out;
}

.alert-msg.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.alert-msg.success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #059669;
}

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

/* ── Form Controls ── */
.login-form {
    position: relative;
    z-index: 1;
}

.field-group {
    margin-bottom: 18px;
}

.field-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.field-wrap {
    position: relative;
}

.field-wrap i.field-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
    transition: var(--transition);
    pointer-events: none;
    z-index: 2;
}

.field-input {
    width: 100%;
    height: 48px;
    padding: 0 16px 0 44px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 500;
    outline: none;
    transition: var(--transition);
}

.field-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.field-input:focus {
    border-color: var(--solar-orange);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.12);
}

.field-input:focus ~ i.field-icon {
    color: var(--solar-orange);
}

/* Password toggle button */
.pwd-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    font-size: 0.95rem;
    transition: var(--transition);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwd-toggle:hover {
    color: var(--solar-orange);
}

/* ── Options Row ── */
.options-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}

.checkbox-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-wrap input {
    display: none;
}

.checkbox-visual {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 1.5px solid var(--input-border);
    background: var(--input-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.checkbox-visual i {
    font-size: 0.65rem;
    color: #ffffff;
    opacity: 0;
    transform: scale(0.5);
    transition: var(--transition);
}

.checkbox-wrap input:checked ~ .checkbox-visual {
    background: var(--solar-orange);
    border-color: var(--solar-orange);
}

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

.checkbox-wrap .cb-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.checkbox-wrap:hover .cb-label {
    color: var(--text-main);
}

/* ── Submit Button ── */
.btn-login {
    width: 100%;
    height: 48px;
    background: linear-gradient(135deg, var(--solar-orange), var(--solar-orange-hover));
    border: none;
    border-radius: 12px;
    color: #ffffff;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(249, 115, 22, 0.35);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login .spinner {
    display: none;
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-login.loading .btn-text { display: none; }
.btn-login.loading .spinner { display: inline-block; }

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

/* ── Login History (Recent Accounts) ── */
.history-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: var(--transition);
}

.history-clear:hover {
    color: var(--solar-red);
    background: #fef2f2;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.history-item:hover {
    background: #fff7ed;
    border-color: rgba(249, 115, 22, 0.3);
}

.history-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.15), rgba(245, 158, 11, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--solar-orange);
    flex-shrink: 0;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-email {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.history-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    opacity: 0.6;
    cursor: pointer;
    padding: 4px;
    font-size: 0.8rem;
    transition: var(--transition);
}

.history-item:hover .history-remove {
    opacity: 1;
}

.history-remove:hover {
    color: var(--solar-red);
}

/* ── Footer ── */
.login-footer {
    text-align: center;
    margin-top: 20px;
}

.login-footer small {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* ── Responsive Mobile Adjustments ── */
@media (max-width: 480px) {
    body {
        padding: 16px 12px;
        align-items: center;
        justify-content: center;
    }
    .login-card {
        padding: 28px 20px 24px;
        border-radius: 20px;
    }
    .login-brand-img {
        max-height: 80px;
    }
    .field-input { font-size: 16px; /* Prevents auto-zoom on iOS */ }
}
