/**
 * GEO-LINK - Fleet & Field Service GPS Tracking System
 * Powered by Microssoftcomputers.in
 * Developed by Maniprasanth (9566637969)
 * Modern Responsive Stylesheet (Desktop + Mobile / WebView)
 */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --navy-sidebar: #0f172a;
    --navy-sidebar-dark: #090d16;
    --navy-active: #1e293b;
    --accent-cyan: #06b6d4;
    --status-online: #10b981;
    --status-idle: #f59e0b;
    --status-offline: #ef4444;
    --bg-main: #f1f5f9;
    --card-border: #e2e8f0;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-main);
    color: #1e293b;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* -------------------------------------------------------------
 * Layout Structure: Sidebar + Main Content Wrapper
 * ----------------------------------------------------------- */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Desktop Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--navy-sidebar);
    color: #94a3b8;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease-in-out;
}

.sidebar-brand-container {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-title {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-icon-box {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #2563eb, #06b6d4);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.sidebar-menu-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    scrollbar-width: thin;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    padding: 10px 12px 6px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #94a3b8;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

.sidebar-nav-link i {
    font-size: 1.15rem;
    width: 22px;
    text-align: center;
}

.sidebar-nav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.06);
}

.sidebar-nav-link.active {
    color: #ffffff;
    background: linear-gradient(90deg, #2563eb, #1d4ed8);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.sidebar-credits {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background-color: var(--navy-sidebar-dark);
    font-size: 0.78rem;
    line-height: 1.4;
}

.sidebar-credits a {
    color: #38bdf8;
    text-decoration: none;
}
.sidebar-credits a:hover {
    text-decoration: underline;
}

/* Main Content Area */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease-in-out;
    width: calc(100% - var(--sidebar-width));
}

/* Top Mobile Navigation Bar */
.mobile-topbar {
    display: none;
    background-color: var(--navy-sidebar);
    color: white;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Responsive Breakpoints */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.show-mobile {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
}

/* -------------------------------------------------------------
 * Map & Card Styles
 * ----------------------------------------------------------- */
.dashboard-map-container {
    height: 800px;
    min-height: 750px;
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    background: #e2e8f0;
}

@media (min-width: 1400px) {
    .dashboard-map-container {
        height: 860px;
        min-height: 800px;
    }
}

@media (max-width: 991px) {
    .dashboard-map-container {
        height: 680px;
        min-height: 620px;
    }
}

#liveMap, #timelineMap, #simMap {
    width: 100%;
    height: 100%;
    z-index: 1;
}

.map-sidebar-card {
    height: 800px;
    min-height: 750px;
    display: flex;
    flex-direction: column;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

@media (min-width: 1400px) {
    .map-sidebar-card {
        height: 860px;
        min-height: 800px;
    }
}

@media (max-width: 991px) {
    .map-sidebar-card {
        height: 480px;
        min-height: 420px;
    }
}

.employee-scroll-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
}

.employee-list-item {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border-left: 4px solid transparent;
}

.employee-list-item:hover {
    background-color: #f8fafc;
    transform: translateX(2px);
}

.employee-list-item.active-selected {
    background-color: #eff6ff;
    border-left-color: var(--primary-color);
}

/* Pulsing Status Indicators */
.pulse-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
}

.pulse-indicator.green {
    background-color: var(--status-online);
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.5);
    animation: pulse-green 1.8s infinite;
}

.pulse-indicator.yellow {
    background-color: var(--status-idle);
    box-shadow: 0 0 0 rgba(245, 158, 11, 0.5);
    animation: pulse-yellow 1.8s infinite;
}

.pulse-indicator.red {
    background-color: var(--status-offline);
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 9px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulse-yellow {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { box-shadow: 0 0 0 9px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* Custom Leaflet Map Markers */
.geo-custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.marker-pin {
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -24px 0 0 -18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 2px solid #ffffff;
}

.marker-pin.online {
    background: #10b981;
}

.marker-pin.idle {
    background: #f59e0b;
}

.marker-pin.offline {
    background: #ef4444;
}

.marker-icon-inner {
    transform: rotate(45deg);
    color: white;
    font-size: 16px;
}

/* KPI Cards */
.kpi-card {
    border: none;
    border-radius: 14px;
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.kpi-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

/* Stop Marker Badge on Timeline */
.stop-marker-badge {
    background-color: #4f46e5;
    color: #ffffff;
    font-weight: bold;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    font-size: 12px;
}

/* Footer in main content */
footer.geo-footer-main {
    margin-top: auto;
    background-color: #ffffff;
    border-top: 1px solid var(--card-border);
    color: #64748b;
    padding: 16px 24px;
    font-size: 0.85rem;
}

footer.geo-footer-main a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}
footer.geo-footer-main a:hover {
    text-decoration: underline;
}

/* Developer Credit Highlight Pill */
.dev-credit-badge {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

/* -------------------------------------------------------------
 * Floating Map Drag / Page Scroll Mode Toggle FAB (Bottom-Left: Keeps center clear)
 * ----------------------------------------------------------- */
.map-interaction-fab-wrap {
    position: absolute;
    bottom: 20px;
    left: 20px;
    transform: none;
    z-index: 1000;
    pointer-events: auto;
}

@media (max-width: 576px) {
    .map-interaction-fab-wrap {
        bottom: 14px;
        left: 12px;
    }
    .map-interaction-fab {
        padding: 8px 14px !important;
        font-size: 0.78rem !important;
    }
}

.map-interaction-fab {
    border-radius: 50rem;
    padding: 9px 18px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* State A: Locked for Page Scroll (Default on touch devices) */
.map-interaction-fab.mode-page-scroll {
    background: #ffffff;
    color: #0f172a;
    border-color: #e2e8f0;
}

.map-interaction-fab.mode-page-scroll:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.map-interaction-fab.mode-page-scroll .fab-icon {
    background-color: #eff6ff;
    color: #2563eb;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

/* State B: Map Move / Pan Mode Active */
.map-interaction-fab.mode-map-pan {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    border-color: #6ee7b7;
    box-shadow: 0 6px 24px rgba(16, 185, 129, 0.45);
    animation: fab-pan-pulse 2s infinite;
}

.map-interaction-fab.mode-map-pan .fab-icon {
    background-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

@keyframes fab-pan-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* -------------------------------------------------------------
 * CRITICAL LEAFLET POPUP OVERRIDES - Fixes Invisible Button Text & Overlaps
 * ----------------------------------------------------------- */
.leaflet-popup-pane {
    z-index: 1040 !important;
}

.leaflet-popup {
    z-index: 1050 !important;
}

.leaflet-popup-content-wrapper {
    border-radius: 14px !important;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.28) !important;
    padding: 0 !important;
    overflow-y: auto !important;
    max-height: 82vh !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
}

.leaflet-popup-content {
    margin: 12px 14px !important;
    line-height: 1.4 !important;
}

/* Force popup button text to ALWAYS be visible and bold white */
.leaflet-popup-content a.btn,
.leaflet-popup-content a.btn-primary,
.leaflet-popup-content .btn,
.leaflet-popup-content .btn-primary,
.leaflet-popup-content a.btn-primary *,
.leaflet-popup-content .btn * {
    color: #ffffff !important;
    text-decoration: none !important;
    font-weight: 700 !important;
}

.leaflet-popup-content a.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35) !important;
    padding: 8px 14px !important;
    border-radius: 8px !important;
}

.leaflet-popup-content a.btn-primary:hover,
.leaflet-popup-content a.btn-primary:active {
    background: linear-gradient(135deg, #1d4ed8, #1e40af) !important;
    color: #ffffff !important;
}

/* Alert badge pills inside popup */
.popup-alert-pill {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

