/* ==========================================================================
   Aero Fleet 360 - Premium CSS Design System
   ========================================================================== */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    /* Color Palette */
    --bg-main: #2a282d;
    --bg-surface: #363339;
    --bg-surface-glass: rgba(54, 51, 57, 0.78);
    --border-glass: rgba(221, 181, 246, 0.18);
    
    --text-primary: #fafafb;
    --text-secondary: #dfd4ea;
    --text-muted: #9a85b8;
    
    --accent-indigo: #f4c155;
    --accent-indigo-glow: rgba(244, 193, 85, 0.2);
    
    --status-success: #10B981;
    --status-success-glow: rgba(16, 185, 129, 0.15);
    
    --status-warning: #f4c155;
    --status-warning-glow: rgba(244, 193, 85, 0.15);
    
    --status-danger: #EF4444;
    --status-danger-glow: rgba(239, 68, 68, 0.2);
    
    --status-info: #9a85b8;
    --status-info-glow: rgba(154, 133, 184, 0.15);
    
    /* Layout & Styling Values */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-main: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.02em;
}

a {
    color: var(--accent-indigo);
    text-decoration: none;
    transition: var(--transition-smooth);
}

a:hover {
    color: #818cf8;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: #1f2937;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #374151;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--bg-surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-main);
    padding: 24px;
    transition: var(--transition-smooth);
}

.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Sidebar Layout */
.app-sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 16px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.brand-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    width: 100%;
}

.brand-logo {
    height: 72px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
}

.brand-name {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 50%, #f4c155 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-menu {
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.menu-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.group-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-left: 12px;
    margin-bottom: 6px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.sidebar-item i {
    width: 16px;
    text-align: center;
}

.sidebar-item:hover, .sidebar-item.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid var(--accent-indigo);
    padding-left: 9px;
}

/* Top bar for contents */
.top-bar {
    margin-left: 260px;
    padding: 16px 40px;
    background: rgba(42, 40, 45, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 900;
}

.content-wrapper {
    margin-left: 260px;
    padding: 40px;
    min-height: calc(100vh - 73px);
}

/* System Role Switcher */
.role-switch-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 12px;
    border-radius: 30px;
    border: 1px solid var(--border-glass);
}

.role-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.role-select {
    background: transparent;
    color: var(--accent-indigo);
    border: none;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    font-size: 13px;
    padding-right: 8px;
}

/* Dashboard Metrics & Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 0 0 24px 0;
}

.metric-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.metric-icon {
    font-size: 18px;
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    font-family: var(--font-heading);
    margin: 12px 0 4px;
    color: var(--text-primary);
}

.metric-footer {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.trend-up { color: var(--status-success); }
.trend-down { color: var(--status-danger); }
.trend-neutral { color: var(--text-secondary); }

/* Main Dashboard Content Layout */
.main-layout {
    display: grid;
    grid-template-columns: 2.2fr 1.8fr;
    gap: 24px;
    padding: 0;
}

.map-container {
    height: 480px;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-glass);
}

/* Leaflet Map Adjustments */
#leaflet-map {
    width: 100%;
    height: 100%;
    z-index: 10;
}

/* Floating Alerts Panel */
.floating-alert {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 100;
    width: 280px;
}

/* Active Alert Items */
.alert-card {
    display: flex;
    gap: 12px;
    background: rgba(239, 68, 68, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.3);
    margin-bottom: 8px;
    animation: pulse-border 2s infinite, slide-in 0.4s ease-out;
}

.alert-card.warning {
    background: rgba(245, 158, 11, 0.95);
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.3);
}

.alert-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
}

.alert-desc {
    font-size: 12px;
    opacity: 0.9;
}

/* Tab Headers */
.tab-header {
    display: flex;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 20px;
    gap: 8px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 20px;
    font-weight: 600;
    font-family: var(--font-heading);
    cursor: pointer;
    transition: var(--transition-smooth);
    border-bottom: 2px solid transparent;
    font-size: 14px;
}

.tab-btn.active {
    color: var(--accent-indigo);
    border-bottom-color: var(--accent-indigo);
}

/* Tables Styling */
.table-container {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-glass);
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-size: 14px;
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-success { background: var(--status-success-glow); color: var(--status-success); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-warning { background: var(--status-warning-glow); color: var(--status-warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-danger { background: var(--status-danger-glow); color: var(--status-danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-info { background: var(--status-info-glow); color: var(--status-info); border: 1px solid rgba(59, 130, 246, 0.2); }

/* Forms & Inputs */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    color: white;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    outline: none;
    font-family: inherit;
    transition: var(--transition-smooth);
}

.form-control:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-family: var(--font-heading);
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    gap: 8px;
    font-size: 14px;
}

.btn-primary {
    background: var(--accent-indigo);
    color: white;
}
.btn-primary:hover {
    background: #4f46e5;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.btn-danger {
    background: var(--status-danger);
    color: white;
}
.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Driver Safety Gamified Module */
.driver-safety-card {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
}

.driver-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-indigo-glow);
    border: 2px solid var(--accent-indigo);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.driver-score-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}
.score-high { background: var(--status-success-glow); color: var(--status-success); border: 2px solid var(--status-success); }
.score-medium { background: var(--status-warning-glow); color: var(--status-warning); border: 2px solid var(--status-warning); }
.score-low { background: var(--status-danger-glow); color: var(--status-danger); border: 2px solid var(--status-danger); }

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.01);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.leaderboard-rank {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 700;
    width: 24px;
}

.leaderboard-name {
    font-weight: 500;
    flex: 1;
    font-size: 14px;
}

.leaderboard-score {
    font-weight: 700;
    font-size: 14px;
}

/* EV Battery Health Widget */
.battery-widget {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(17, 24, 39, 0.6) 100%);
    border: 1px solid rgba(16, 185, 129, 0.15);
}

.battery-visual {
    width: 80px;
    height: 36px;
    border: 3px solid var(--text-primary);
    border-radius: 6px;
    padding: 2px;
    position: relative;
    margin-right: 12px;
}

.battery-visual::after {
    content: '';
    width: 4px;
    height: 14px;
    background: var(--text-primary);
    position: absolute;
    right: -7px;
    top: 8px;
    border-radius: 0 3px 3px 0;
}

.battery-fill {
    height: 100%;
    background: var(--status-success);
    border-radius: 2px;
    transition: var(--transition-smooth);
}

.battery-fill.low { background: var(--status-danger); }
.battery-fill.medium { background: var(--status-warning); }

/* AI Natural Language Chat Interface */
.ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 520px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    background: rgba(0, 0, 0, 0.15);
}

.chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
}

.bubble-user {
    background: var(--accent-indigo);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.bubble-bot {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-glass);
}

.chat-input-bar {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    border-top: none;
    padding: 12px;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    gap: 12px;
}

.chat-suggested-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.suggested-prompt-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.suggested-prompt-btn:hover {
    background: var(--accent-indigo-glow);
    color: var(--text-primary);
    border-color: var(--accent-indigo);
}

/* Interactive ePOD Signature Canvas */
.sig-canvas-container {
    border: 1px dashed var(--border-glass);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-sm);
    position: relative;
    height: 180px;
}

#signature-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Animations */
@keyframes pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

@keyframes slide-in {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Grid Layout modifications */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* Responsive adjustments */
@media(max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media(max-width: 640px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .app-header {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }
}
