/**
 * Fleet360 - Login Page Styles
 * Ultra-modern SaaS login with glassmorphism, animations
 */

/* ===== CSS Variables ===== */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #06b6d4;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --bg-input: #f1f5f9;
    --bg-input-focus: #ffffff;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    
    --border-color: #e2e8f0;
    --border-focus: #6366f1;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    --font-primary: 'Plus Jakarta Sans', 'Inter', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.85);
    --bg-card-hover: rgba(30, 41, 59, 0.95);
    --bg-input: #1e293b;
    --bg-input-focus: #334155;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    --border-color: #334155;
    --border-focus: #818cf8;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: var(--font-primary);
    overflow: hidden;
}

body {
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

/* ===== Animated Background ===== */
.login-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.bg-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 25%, #312e81 50%, #1e1b4b 75%, #0f172a 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

[data-theme="light"] .bg-gradient {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 25%, #a5b4fc 50%, #c7d2fe 75%, #e0e7ff 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.bg-grid {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* Floating Shapes */
.bg-shapes .shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.08;
    animation: floatShape 20s ease-in-out infinite;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.shape-2 {
    width: 300px;
    height: 300px;
    background: var(--secondary);
    bottom: -50px;
    left: -50px;
    animation-delay: -5s;
}

.shape-3 {
    width: 200px;
    height: 200px;
    background: var(--accent);
    top: 50%;
    left: 50%;
    animation-delay: -10s;
}

.shape-4 {
    width: 150px;
    height: 150px;
    background: var(--success);
    top: 30%;
    right: 20%;
    animation-delay: -3s;
}

.shape-5 {
    width: 250px;
    height: 250px;
    background: var(--primary-light);
    bottom: 20%;
    right: 30%;
    animation-delay: -7s;
}

@keyframes floatShape {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(20px, 10px) scale(1.02); }
}

/* Floating vehicle icons */
.floating-vehicles i {
    position: absolute;
    color: rgba(99, 102, 241, 0.06);
    font-size: 3rem;
    animation: floatIcon 25s ease-in-out infinite;
}

.fv-1 { top: 15%; left: 10%; animation-delay: 0s; font-size: 4rem; }
.fv-2 { top: 70%; left: 5%; animation-delay: -5s; }
.fv-3 { top: 25%; right: 8%; animation-delay: -10s; font-size: 3.5rem; }
.fv-4 { bottom: 15%; right: 15%; animation-delay: -15s; font-size: 4rem; }
.fv-5 { top: 50%; left: 30%; animation-delay: -8s; font-size: 2.5rem; }

@keyframes floatIcon {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.06; }
    50% { transform: translateY(-20px) rotate(5deg); opacity: 0.1; }
}

/* ===== Login Container ===== */
.login-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 520px;
    padding: 2.5rem;
    animation: fadeInUp 0.8s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Brand Section ===== */
.brand-section {
    margin-bottom: 2rem;
}

.brand-logo {
    display: inline-block;
    margin-bottom: 1rem;
}

.logo-icon {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.35);
    animation: pulse 3s ease-in-out infinite;
}

.logo-icon i {
    font-size: 1.8rem;
    color: white;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(99, 102, 241, 0.35); }
    50% { box-shadow: 0 8px 48px rgba(99, 102, 241, 0.55); }
}

.brand-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.5px;
}

[data-theme="light"] .brand-title {
    color: var(--text-primary);
}

.text-accent {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95rem;
    font-weight: 400;
    margin-top: 0.25rem;
}

[data-theme="light"] .brand-subtitle {
    color: var(--text-secondary);
}

/* ===== Portal Selection ===== */
.portal-selection {
    animation: fadeIn 0.5s ease;
}

.selection-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    text-align: center;
    margin-bottom: 0.5rem;
}

[data-theme="light"] .selection-title {
    color: var(--text-primary);
}

.selection-subtitle {
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

[data-theme="light"] .selection-subtitle {
    color: var(--text-muted);
}

.portal-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ===== Portal Cards ===== */
.portal-card {
    position: relative;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.portal-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
}

.portal-card:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.card-glow {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.4s ease;
    border-radius: var(--radius-lg);
}

.admin-card .card-glow {
    background: radial-gradient(circle at 30% 50%, rgba(99, 102, 241, 0.1), transparent 70%);
}

.dispatcher-card .card-glow {
    background: radial-gradient(circle at 30% 50%, rgba(139, 92, 246, 0.1), transparent 70%);
}

.foreman-card .card-glow {
    background: radial-gradient(circle at 30% 50%, rgba(239, 68, 68, 0.1), transparent 70%);
}

.driver-card .card-glow {
    background: radial-gradient(circle at 30% 50%, rgba(6, 182, 212, 0.1), transparent 70%);
}

.portal-card:hover .card-glow {
    opacity: 1;
}

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.4rem;
}

.admin-card .card-icon {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.dispatcher-card .card-icon {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.foreman-card .card-icon {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.driver-card .card-icon {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.card-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.card-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 500;
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.driver-card .role-badge {
    background: rgba(6, 182, 212, 0.08);
    color: var(--secondary);
    border-color: rgba(6, 182, 212, 0.15);
}

.dispatcher-card .role-badge {
    background: rgba(139, 92, 246, 0.08);
    color: #8b5cf6;
    border-color: rgba(139, 92, 246, 0.15);
}

.foreman-card .role-badge {
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.15);
}

.card-arrow {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
    transition: var(--transition);
    flex-shrink: 0;
}

.driver-card .card-arrow {
    background: rgba(6, 182, 212, 0.08);
    color: var(--secondary);
}

.dispatcher-card .card-arrow {
    background: rgba(139, 92, 246, 0.08);
    color: #8b5cf6;
}

.foreman-card .card-arrow {
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
}

.portal-card:hover .card-arrow {
    transform: translateX(4px);
    background: var(--primary);
    color: white;
}

.driver-card:hover .card-arrow {
    background: var(--secondary);
}

.dispatcher-card:hover .card-arrow {
    background: #8b5cf6;
}

.foreman-card:hover .card-arrow {
    background: #ef4444;
}

/* ===== Login Form Section ===== */
.login-form-section {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-xl);
    padding: 2rem;
    animation: fadeInUp 0.5s ease;
}

.form-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.back-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.back-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.form-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0;
}

.form-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    letter-spacing: 0.01em;
}

.input-group-custom {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 0.9rem;
    z-index: 2;
    transition: color 0.3s ease;
}

.form-control {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.75rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.form-control:focus + .input-icon,
.form-control:focus ~ .input-icon {
    color: var(--primary);
}

.input-group-custom .form-control:focus ~ .input-icon {
    color: var(--primary);
}

.toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    z-index: 2;
    transition: color 0.3s ease;
}

.toggle-password:hover {
    color: var(--primary);
}

/* ===== Form Options ===== */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.custom-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.custom-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.forgot-link {
    font-size: 0.82rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.forgot-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ===== Login Buttons ===== */
.btn-login {
    width: 100%;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn-admin-login {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-admin-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-driver-login {
    background: linear-gradient(135deg, var(--secondary), #0891b2);
    color: white;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.btn-driver-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.4);
}

.btn-icon {
    transition: transform 0.3s ease;
}

.btn-login:hover .btn-icon {
    transform: translateX(4px);
}

.btn-loader {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Error/Messages ===== */
.login-error {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.login-error::before {
    content: '\f06a';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
}

.login-message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

.login-message.success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--success);
}

/* ===== Login Footer ===== */
.login-footer {
    margin-top: 2rem;
    text-align: center;
}

.login-footer p {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.78rem;
    margin-bottom: 0.5rem;
}

[data-theme="light"] .login-footer p {
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
    text-decoration: none;
    transition: color 0.3s ease;
}

[data-theme="light"] .footer-links a {
    color: var(--text-muted);
}

.footer-links a:hover {
    color: var(--primary-light);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: white;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
}

[data-theme="light"] .theme-toggle {
    color: var(--text-primary);
    background: var(--bg-card);
    border-color: var(--border-color);
}

.theme-toggle:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== Toast Notification ===== */
.toast-notification {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    z-index: 10000;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    max-width: 400px;
    width: 90%;
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    font-size: 0.88rem;
    color: var(--text-primary);
}

.toast-icon {
    font-size: 1.1rem;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== Responsive ===== */
@media (max-width: 576px) {
    .login-container {
        padding: 1.5rem 1rem;
        max-width: 100%;
    }
    
    .brand-title {
        font-size: 1.8rem;
    }
    
    .logo-icon {
        width: 56px;
        height: 56px;
    }
    
    .logo-icon i {
        font-size: 1.4rem;
    }
    
    .portal-card {
        padding: 1.25rem;
    }
    
    .card-icon {
        width: 48px;
        height: 48px;
    }
    
    .card-roles {
        display: none;
    }
    
    .login-form-section {
        padding: 1.5rem;
    }
    
    .form-title {
        font-size: 1.2rem;
    }
}

@media (max-width: 380px) {
    .login-container {
        padding: 1rem 0.75rem;
    }
    
    .portal-card {
        padding: 1rem;
        gap: 1rem;
    }
}
