/* WORCAS Live Tracking - Professional Design */

:root {
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #14b8a6;
    --accent: #f59e0b;
    --accent-light: rgba(245, 158, 11, 0.1);
    --warning: #f59e0b;
    --danger: #ef4444;
    --success: #10b981;
    --dark: #1e293b;
    --gray-900: #334155;
    --gray-700: #475569;
    --gray-500: #64748b;
    --gray-300: #e2e8f0;
    --gray-100: #f8fafc;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(60,64,67,0.1);
    --shadow: 0 1px 3px rgba(60,64,67,0.15), 0 1px 2px rgba(60,64,67,0.1);
    --shadow-lg: 0 4px 6px rgba(60,64,67,0.15), 0 1px 3px rgba(60,64,67,0.1);
    --shadow-xl: 0 10px 20px rgba(60,64,67,0.15), 0 3px 6px rgba(60,64,67,0.1);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-sm: 8px;
    --radius-xs: 6px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--dark);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Main Content */
.main-content {
    display: flex;
    height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 340px;
    background: var(--white);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    z-index: 50;
}

/* Logo Header */
.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon-box {
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon-box .logo-icon {
    width: 24px;
    height: 24px;
    fill: var(--white);
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--white);
    letter-spacing: -0.5px;
}

.logo-subtitle {
    font-size: 12px;
    color: rgba(255,255,255,0.8);
    font-weight: 500;
}

.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
}

.connection-status .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gray-500);
    animation: pulse-dot 2s infinite;
    transition: all 0.3s ease;
}

.connection-status .status-dot.online,
.connection-status.connected .status-dot {
    background: #34d399;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.3);
}

.connection-status .status-dot.loading,
.connection-status.loading .status-dot {
    background: var(--warning);
    box-shadow: 0 0 0 3px rgba(251, 188, 4, 0.3);
}

.connection-status .status-dot.error,
.connection-status.error .status-dot {
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(234, 67, 53, 0.3);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Stats Card */
.stats-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.08) 0%, rgba(16, 185, 129, 0.05) 100%);
    border: 1px solid rgba(13, 148, 136, 0.2);
    border-radius: var(--radius);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.online {
    background: var(--success);
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    fill: var(--white);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--gray-700);
    font-weight: 500;
    margin-top: 2px;
}

.btn-refresh {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.btn-refresh:hover {
    background: var(--primary);
    transform: rotate(180deg);
}

.btn-refresh:hover svg {
    fill: var(--white);
}

.btn-refresh svg {
    width: 20px;
    height: 20px;
    fill: var(--gray-700);
    transition: all 0.2s ease;
}

/* Search Box */
.search-box {
    padding: 0 16px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 12px 12px 12px 44px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
    background: var(--gray-100);
}

.search-box input:focus {
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.search-box input::placeholder {
    color: var(--gray-500);
}

.search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    fill: var(--gray-500);
}

/* Driver List Header */
.driver-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.last-update-mini {
    font-weight: 500;
    color: var(--gray-500);
    text-transform: none;
    letter-spacing: 0;
}

/* Driver List */
.driver-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
}

.driver-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 4px;
    border: 1px solid transparent;
}

.driver-item:hover {
    background: var(--gray-100);
}

.driver-item.selected {
    background: rgba(13, 148, 136, 0.08);
    border-color: var(--primary);
}

.driver-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.driver-avatar svg {
    width: 22px;
    height: 22px;
    fill: var(--white);
}

.driver-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: var(--success);
    border: 2px solid var(--white);
    border-radius: 50%;
}

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

.driver-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.driver-id {
    font-size: 12px;
    color: var(--primary);
    font-weight: 500;
    margin-top: 2px;
}

.driver-update {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Loading & Empty State */
.loading, .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    color: var(--gray-500);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

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

.empty-icon {
    width: 56px;
    height: 56px;
    fill: var(--gray-300);
    margin-bottom: 12px;
}

/* ==================== MAP CONTAINER ==================== */
.map-container {
    flex: 1;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
}

/* Map Controls */
.map-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.map-btn {
    width: 44px;
    height: 44px;
    background: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.map-btn:hover {
    background: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: scale(1.05);
}

.map-btn:hover svg {
    fill: var(--white);
}

.map-btn svg {
    width: 22px;
    height: 22px;
    fill: var(--gray-700);
    transition: fill 0.2s ease;
}

/* Auto Refresh Toggle */
.auto-refresh {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: var(--white);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    z-index: 1000;
}

.toggle {
    position: relative;
    width: 40px;
    height: 22px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gray-300);
    border-radius: 22px;
    cursor: pointer;
    transition: 0.2s ease;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: var(--white);
    border-radius: 50%;
    transition: 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(18px);
}

/* Map Info */
.map-info {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: var(--white);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--gray-700);
    z-index: 1000;
}

.map-info svg {
    width: 16px;
    height: 16px;
    fill: var(--gray-500);
}

/* Map Popup */
.map-popup {
    min-width: 200px;
    font-family: 'Inter', sans-serif;
}

.map-popup h4 {
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.map-popup p {
    font-size: 12px;
    color: var(--gray-700);
    margin: 4px 0;
}

.popup-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 8px;
}

.popup-status.online {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

/* Marker Animation */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.5); }
    70% { box-shadow: 0 0 0 15px rgba(13, 148, 136, 0); }
    100% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0); }
}

/* ==================== MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.25s ease;
    overflow: hidden;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.modal-title-wrapper {
    display: flex;
    align-items: center;
    gap: 14px;
}

.modal-avatar {
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-avatar svg {
    width: 26px;
    height: 26px;
    fill: var(--white);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--white);
    margin-bottom: 2px;
}

.modal-subtitle {
    font-size: 13px;
    color: rgba(255,255,255,0.8);
    font-weight: 500;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255,255,255,0.25);
}

.modal-close svg {
    width: 20px;
    height: 20px;
    fill: var(--white);
}

.modal-body {
    padding: 20px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.detail-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
}

.detail-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.detail-icon.status {
    background: var(--success);
}

.detail-icon svg {
    width: 20px;
    height: 20px;
    fill: var(--white);
}

.detail-info {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 11px;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    margin-top: 2px;
}

.detail-value.status-online {
    color: var(--success);
}

.location-card {
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.location-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 12px;
}

.location-header svg {
    width: 18px;
    height: 18px;
    fill: var(--primary);
}

.location-coords {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.coord {
    display: flex;
    flex-direction: column;
}

.coord-label {
    font-size: 11px;
    color: var(--gray-500);
    font-weight: 500;
}

.coord-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    font-family: 'SF Mono', Monaco, monospace;
    margin-top: 2px;
}

.location-time {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--gray-500);
    padding-top: 12px;
    border-top: 1px solid var(--gray-300);
}

.location-time svg {
    width: 14px;
    height: 14px;
    fill: var(--gray-500);
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px 20px;
}

.btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow);
}

.btn-primary svg {
    fill: var(--white);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--dark);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-secondary svg {
    fill: var(--gray-700);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -340px;
        top: 0;
        height: 100vh;
        transition: left 0.3s ease;
        z-index: 100;
    }

    .sidebar.show {
        left: 0;
    }

    .auto-refresh span {
        display: none;
    }

    .map-info span {
        display: none;
    }
}
