/**
 * Job Map Floating Controls
 * Industrial Precision Design System
 *
 * Clean, professional floating panels over full-screen map
 * Supports both light and dark themes via system preference or data-bs-theme
 */

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */

/* Light theme (default) */
:root {
    /* Light palette */
    --map-panel-bg: rgba(255, 255, 255, 0.95);
    --map-panel-bg-solid: #ffffff;
    --map-panel-border: rgba(0, 0, 0, 0.1);
    --map-panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);

    /* Text colors - light theme */
    --map-text-primary: #1e293b;
    --map-text-secondary: #475569;
    --map-text-muted: #94a3b8;

    /* Accent - using brand blue */
    --map-accent: #008eff;
    --map-accent-hover: #0070d6;
    --map-accent-glow: rgba(0, 142, 255, 0.2);

    /* Input styling - light theme */
    --map-input-bg: rgba(241, 245, 249, 0.9);
    --map-input-border: rgba(0, 0, 0, 0.12);
    --map-input-focus-border: var(--map-accent);

    /* Status colors (same for both themes) */
    --status-proposal: #f59e0b;
    --status-open: #22c55e;
    --status-complete: #6366f1;

    /* Spacing */
    --panel-padding: 16px;
    --panel-radius: 12px;
    --control-radius: 8px;

    /* Hover states - light theme */
    --map-hover-bg: rgba(0, 142, 255, 0.08);
    --map-active-bg: rgba(0, 142, 255, 0.15);

    /* Subtle backgrounds - light theme */
    --map-subtle-bg: rgba(0, 0, 0, 0.03);
    --map-subtle-bg-hover: rgba(0, 0, 0, 0.06);
    --map-inset-bg: rgba(0, 0, 0, 0.05);
    --map-scrollbar: rgba(0, 0, 0, 0.15);
}

/* Dark theme via system preference */
@media (prefers-color-scheme: dark) {
    :root {
        --map-panel-bg: rgba(15, 23, 42, 0.92);
        --map-panel-bg-solid: #0f172a;
        --map-panel-border: rgba(255, 255, 255, 0.08);
        --map-panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);

        --map-text-primary: #f1f5f9;
        --map-text-secondary: #94a3b8;
        --map-text-muted: #64748b;

        --map-input-bg: rgba(30, 41, 59, 0.8);
        --map-input-border: rgba(255, 255, 255, 0.12);

        --map-hover-bg: rgba(0, 142, 255, 0.12);
        --map-active-bg: rgba(0, 142, 255, 0.2);

        /* Subtle backgrounds - dark theme */
        --map-subtle-bg: rgba(255, 255, 255, 0.03);
        --map-subtle-bg-hover: rgba(255, 255, 255, 0.06);
        --map-inset-bg: rgba(0, 0, 0, 0.15);
        --map-scrollbar: rgba(255, 255, 255, 0.15);
    }
}

/* Dark theme via Bootstrap attribute (manual toggle) */
[data-bs-theme="dark"] {
    --map-panel-bg: rgba(15, 23, 42, 0.92);
    --map-panel-bg-solid: #0f172a;
    --map-panel-border: rgba(255, 255, 255, 0.08);
    --map-panel-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);

    --map-text-primary: #f1f5f9;
    --map-text-secondary: #94a3b8;
    --map-text-muted: #64748b;

    --map-input-bg: rgba(30, 41, 59, 0.8);
    --map-input-border: rgba(255, 255, 255, 0.12);

    --map-hover-bg: rgba(0, 142, 255, 0.12);
    --map-active-bg: rgba(0, 142, 255, 0.2);

    /* Subtle backgrounds - dark theme */
    --map-subtle-bg: rgba(255, 255, 255, 0.03);
    --map-subtle-bg-hover: rgba(255, 255, 255, 0.06);
    --map-inset-bg: rgba(0, 0, 0, 0.15);
    --map-scrollbar: rgba(255, 255, 255, 0.15);
}


/* ============================================
   Full-Screen Map Section
   ============================================ */
#jobMapSection.fullscreen-map {
    position: fixed !important;
    top: 56px; /* Below navbar */
    left: 200px; /* Default sidebar width */
    right: 0;
    bottom: 0;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    height: auto !important; /* Let top/bottom handle height */
    width: auto !important; /* Let left/right handle width */
    min-height: 0;
}

/* Adjust for collapsed sidebar */
body.sidebar-collapsed #jobMapSection.fullscreen-map {
    left: 70px;
}

/* Adjust for closed/hidden sidebar */
body.sidebar-closed #jobMapSection.fullscreen-map,
body:not(.sidebar-open):not(.sidebar-collapsed) #jobMapSection.fullscreen-map {
    left: 0;
}

#jobMapSection.fullscreen-map .section-header {
    display: none; /* Hide traditional header */
}

#jobMapSection.fullscreen-map #mapContainer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
}

#jobMapSection.fullscreen-map #jobMap {
    height: 100% !important;
    width: 100% !important;
}


/* ============================================
   Floating Panel Base
   ============================================ */
.map-floating-panel {
    position: absolute;
    background: var(--map-panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--map-panel-border);
    border-radius: var(--panel-radius);
    box-shadow: var(--map-panel-shadow);
    color: var(--map-text-primary);
    z-index: 100;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.map-floating-panel.collapsed {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}


/* ============================================
   Tab Navigation (Top Left)
   ============================================ */
.map-tab-nav {
    top: 20px;
    left: 16px;
    padding: 4px;
    display: flex;
    gap: 2px;
}

.map-tab-btn {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--map-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.map-tab-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--map-text-primary);
}

.map-tab-btn.active {
    background: var(--map-accent);
    color: white;
}


/* ============================================
   Search & Filter Panel (Left Side)
   ============================================ */
.map-controls-panel {
    top: 76px;
    left: 16px;
    width: 360px;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--panel-padding);
}

/* Scrollbar styling */
.map-controls-panel::-webkit-scrollbar {
    width: 6px;
}

.map-controls-panel::-webkit-scrollbar-track {
    background: transparent;
}

.map-controls-panel::-webkit-scrollbar-thumb {
    background: var(--map-scrollbar);
    border-radius: 3px;
}


/* ============================================
   Search Input Group
   ============================================ */
.map-search-group {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    position: relative; /* For PAC dropdown positioning */
    background: var(--map-input-bg);
    border: 1px solid var(--map-input-border);
    border-radius: var(--control-radius);
    padding: 4px;
    margin-bottom: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.map-search-group:focus-within {
    border-color: var(--map-accent);
    box-shadow: 0 0 0 3px var(--map-accent-glow);
}

/* Icon stays first */
.map-search-group > .material-icons:first-child {
    order: 0;
    flex-shrink: 0;
}

/* Inputs take up remaining space */
.map-search-input {
    flex: 1 1 auto;
    min-width: 0;
    order: 1;
    background: transparent;
    border: none;
    padding: 10px 12px;
    color: var(--map-text-primary);
    font-size: 14px;
    outline: none;
}

.map-search-input::placeholder {
    color: var(--map-text-muted);
}

/* Button stays last */
.map-search-btn {
    order: 2;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 6px;
    color: var(--map-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.map-search-btn:hover {
    background: var(--map-accent);
    color: white;
}

.map-search-btn .material-icons {
    font-size: 18px;
}


/* ============================================
   Filter Section
   ============================================ */
.map-filter-section {
    margin-bottom: 16px;
}

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

.map-filter-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--map-text-muted);
}

.map-filter-clear {
    font-size: 11px;
    color: var(--map-accent);
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.map-filter-clear:hover {
    opacity: 1;
    text-decoration: underline;
}


/* ============================================
   Status Toggle Chips
   ============================================ */
.map-status-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.map-status-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--map-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.map-status-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.map-status-chip.active {
    color: white;
    border-color: transparent;
}

.map-status-chip[data-status="Proposal"].active {
    background: var(--status-proposal);
}

.map-status-chip[data-status="Open Job"].active {
    background: var(--status-open);
}

.map-status-chip[data-status="Complete"].active {
    background: var(--status-complete);
}

.map-status-chip .chip-count {
    margin-left: 6px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    font-size: 11px;
}


/* ============================================
   Filter Dropdowns
   ============================================ */
.map-filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.map-filter-select {
    appearance: none;
    background: var(--map-input-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M2 4l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 12px center;
    border: 1px solid var(--map-input-border);
    border-radius: var(--control-radius);
    padding: 10px 32px 10px 12px;
    color: var(--map-text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.map-filter-select:focus {
    outline: none;
    border-color: var(--map-accent);
    box-shadow: 0 0 0 3px var(--map-accent-glow);
}

.map-filter-select option {
    background: var(--map-panel-bg-solid);
    color: var(--map-text-primary);
}


/* ============================================
   Work Order Toggle
   ============================================ */
.map-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-top: 1px solid var(--map-panel-border);
    margin-top: 12px;
}

.map-toggle-label {
    font-size: 13px;
    color: var(--map-text-secondary);
}

.map-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.map-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.map-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    transition: 0.3s;
}

.map-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.map-toggle-switch input:checked + .map-toggle-slider {
    background: var(--map-accent);
}

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


/* ============================================
   Panel Collapse Toggle
   ============================================ */
.map-panel-toggle {
    position: absolute;
    top: 72px;
    left: 16px;
    width: 44px;
    height: 44px;
    background: var(--map-panel-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--map-panel-border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--map-text-secondary);
    cursor: pointer;
    z-index: 99;
    transition: all 0.2s;
    box-shadow: var(--map-panel-shadow);
}

.map-panel-toggle:hover {
    background: var(--map-accent);
    color: white;
}

.map-panel-toggle.hidden {
    display: none;
}


/* ============================================
   Side Panel (Project Details)
   ============================================ */
#mapSidePanel.map-side-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    left: auto;
    width: 360px;
    max-height: calc(100vh - 100px);
    background: var(--map-panel-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--map-panel-border);
    border-radius: var(--panel-radius);
    box-shadow: var(--map-panel-shadow);
    transform: translateX(calc(100% + 32px));
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    z-index: 150;
    padding: 0;
}

#mapSidePanel.map-side-panel.open {
    transform: translateX(0);
}

/* Side panel header */
.map-side-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--map-panel-border);
    position: sticky;
    top: 0;
    background: var(--map-panel-bg);
    z-index: 10;
}

.map-side-panel-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--map-text-primary);
}

.map-side-panel-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 8px;
    color: var(--map-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.map-side-panel-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Side panel content overrides */
#mapSidePanelContent {
    padding: var(--panel-padding);
    color: var(--map-text-primary);
}

#mapSidePanelContent h2,
#mapSidePanelContent h4 {
    color: var(--map-text-primary);
    font-weight: 600;
}

#mapSidePanelContent .table {
    color: var(--map-text-secondary);
    --bs-table-bg: transparent;
}

#mapSidePanelContent .table td {
    border-color: var(--map-panel-border);
    padding: 8px 0;
}

#mapSidePanelContent .table strong {
    color: var(--map-text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
}

/* Action buttons in side panel */
#mapSidePanelContent .action-buttons {
    display: flex;
    gap: 16px;
    margin: 16px 0;
    justify-content: flex-start;
}

#mapSidePanelContent .circle-icon {
    background: var(--map-accent);
    width: 44px;
    height: 44px;
}

#mapSidePanelContent .icon-text {
    color: var(--map-text-secondary);
    font-size: 12px;
}

/* List groups */
#mapSidePanelContent .list-group-item {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--map-panel-border);
    color: var(--map-text-primary);
}


/* ============================================
   Bottom Toolbar
   ============================================ */
.map-bottom-toolbar {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 6px;
    background: var(--map-panel-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--map-panel-border);
    border-radius: 28px;
    box-shadow: var(--map-panel-shadow);
    z-index: 500; /* Higher than other map elements */
}

.map-toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 20px;
    color: var(--map-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.map-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--map-text-primary);
}

.map-toolbar-btn.active {
    background: var(--map-accent);
    color: white;
}

.map-toolbar-btn .material-icons {
    font-size: 18px;
}


/* ============================================
   Stats Badge (Top Right)
   ============================================ */
.map-stats-badge {
    position: absolute;
    top: 20px;
    right: 16px;
    padding: 10px 16px;
    background: var(--map-panel-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--map-panel-border);
    border-radius: 24px;
    font-size: 13px;
    color: var(--map-text-secondary);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-stats-badge .count {
    font-weight: 600;
    color: var(--map-text-primary);
}


/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 768px) {
    .map-controls-panel {
        width: calc(100vw - 32px);
        max-width: 360px;
    }

    #mapSidePanel.map-side-panel {
        width: calc(100vw - 32px);
        max-width: none;
        left: 16px;
        right: 16px;
    }

    .map-bottom-toolbar {
        width: calc(100vw - 32px);
        justify-content: center;
    }

    .map-toolbar-btn span:not(.material-icons) {
        display: none; /* Hide text, show only icons */
    }

    .map-filter-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .map-tab-nav {
        left: 8px;
        right: 8px;
        width: auto;
    }

    .map-tab-btn {
        flex: 1;
        padding: 10px 8px;
        font-size: 12px;
        text-align: center;
    }

    .map-controls-panel {
        left: 8px;
        top: 64px;
        width: calc(100vw - 16px);
    }
}


/* ============================================
   Animations
   ============================================ */
@keyframes panelSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.map-floating-panel {
    animation: panelSlideIn 0.3s ease-out;
}


/* ============================================
   Utility Classes
   ============================================ */
.map-divider {
    height: 1px;
    background: var(--map-panel-border);
    margin: 16px 0;
}

.map-text-muted {
    color: var(--map-text-muted);
}

.map-text-accent {
    color: var(--map-accent);
}


/* ============================================
   Context Menu (Right-Click)
   ============================================ */
.map-context-menu {
    position: fixed;
    z-index: 10000;
    min-width: 220px;
    background: var(--map-panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--map-panel-border);
    border-radius: var(--control-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    padding: 6px 0;
    animation: contextMenuFadeIn 0.12s ease-out;
}

@keyframes contextMenuFadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.context-menu-coords {
    padding: 10px 14px;
    font-size: 11px;
    font-family: 'SF Mono', 'JetBrains Mono', 'Consolas', monospace;
    color: var(--map-text-muted);
    background: var(--map-inset-bg);
    border-bottom: 1px solid var(--map-panel-border);
    letter-spacing: 0.3px;
}

.context-menu-divider {
    height: 1px;
    background: var(--map-panel-border);
    margin: 4px 0;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--map-text-primary);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}

.context-menu-item:hover {
    background: var(--map-hover-bg);
}

.context-menu-item:active {
    background: var(--map-active-bg);
}

.context-menu-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.context-menu-item.loading {
    pointer-events: none;
    opacity: 0.7;
}

.context-menu-item.loading .context-menu-icon {
    animation: spin 1s linear infinite;
}

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


/* ============================================
   Depth Estimate Results Panel
   ============================================ */
.map-estimate-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 380px;
    max-height: calc(100vh - 100px);
    background: var(--map-panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--map-panel-border);
    border-radius: var(--panel-radius);
    box-shadow: var(--map-panel-shadow);
    z-index: 200;
    overflow: hidden;
    animation: panelSlideIn 0.25s ease-out;
}

.estimate-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--map-active-bg), var(--map-hover-bg));
    border-bottom: 1px solid var(--map-panel-border);
}

.estimate-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--map-text-primary);
}

.estimate-panel-title .material-icons {
    color: var(--map-accent);
    font-size: 20px;
}

.estimate-panel-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 6px;
    color: var(--map-text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.estimate-panel-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.estimate-panel-coords {
    padding: 10px 16px;
    font-size: 11px;
    font-family: 'SF Mono', 'JetBrains Mono', 'Consolas', monospace;
    color: var(--map-text-muted);
    background: var(--map-inset-bg);
    border-bottom: 1px solid var(--map-panel-border);
}

.estimate-panel-content {
    padding: 16px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* Estimate stat cards */
.estimate-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.estimate-stat {
    background: var(--map-subtle-bg);
    border: 1px solid var(--map-panel-border);
    border-radius: var(--control-radius);
    padding: 14px;
}

.estimate-stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--map-text-muted);
    margin-bottom: 6px;
}

.estimate-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--map-text-primary);
    line-height: 1;
}

.estimate-stat-value small {
    font-size: 14px;
    font-weight: 400;
    color: var(--map-text-secondary);
}

.estimate-stat.primary {
    background: linear-gradient(135deg, var(--map-hover-bg), transparent);
    border-color: var(--map-accent-glow);
}

.estimate-stat.primary .estimate-stat-value {
    color: var(--map-accent);
}

/* Nearby wells list */
.estimate-wells-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--map-panel-border);
}

.estimate-wells-header {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--map-text-muted);
    margin-bottom: 12px;
}

.estimate-well-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--map-subtle-bg);
    border: 1px solid var(--map-panel-border);
    border-radius: 6px;
    margin-bottom: 8px;
    transition: background 0.15s;
}

.estimate-well-item:hover {
    background: var(--map-subtle-bg-hover);
}

.estimate-well-name {
    font-size: 13px;
    color: var(--map-text-primary);
    font-weight: 500;
}

.estimate-well-depth {
    font-size: 13px;
    color: var(--map-text-secondary);
}

.estimate-well-distance {
    font-size: 11px;
    color: var(--map-text-muted);
}

/* Loading state */
.estimate-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.estimate-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--map-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

.estimate-loading-text {
    font-size: 14px;
    color: var(--map-text-secondary);
}

.estimate-loading-subtext {
    font-size: 12px;
    color: var(--map-text-muted);
    margin-top: 4px;
}

/* Error state */
.estimate-error {
    padding: 24px;
    text-align: center;
}

.estimate-error-icon {
    font-size: 48px;
    color: #f59e0b;
    margin-bottom: 12px;
}

.estimate-error-text {
    font-size: 14px;
    color: var(--map-text-secondary);
}

/* Action buttons */
.estimate-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--map-panel-border);
}

.estimate-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--map-panel-border);
    border-radius: var(--control-radius);
    color: var(--map-text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.estimate-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.estimate-action-btn.primary {
    background: var(--map-accent);
    border-color: var(--map-accent);
    color: white;
}

.estimate-action-btn.primary:hover {
    background: var(--map-accent-hover);
}

/* Responsive */
@media (max-width: 768px) {
    .map-estimate-panel {
        width: calc(100vw - 32px);
        left: 16px;
        right: 16px;
    }

    .estimate-stats {
        grid-template-columns: 1fr;
    }
}


/* ============================================
   deck.gl Historical Wells Controls
   ============================================ */
.deck-control-panel {
    top: 72px;
    right: 16px;
    width: 260px;
    padding: 0;
    overflow: hidden;
}

.deck-control-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(99, 102, 241, 0.05));
    border-bottom: 1px solid var(--map-panel-border);
    font-size: 14px;
    font-weight: 600;
    color: var(--map-text-primary);
}

.deck-control-header .material-icons {
    color: #6366f1;
    font-size: 18px;
}

.deck-control-close {
    margin-left: auto;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-radius: 6px;
    color: var(--map-text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.deck-control-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.deck-control-close .material-icons {
    font-size: 16px;
}

.deck-control-stats {
    display: flex;
    padding: 12px 16px;
    gap: 16px;
    border-bottom: 1px solid var(--map-panel-border);
    background: var(--map-inset-bg);
}

.deck-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.deck-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--map-text-primary);
}

.deck-stat-label {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--map-text-muted);
}

.deck-control-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--map-panel-border);
}

.deck-control-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--map-text-muted);
    margin-bottom: 8px;
}

.deck-toggle-group {
    display: flex;
    gap: 6px;
}

.deck-toggle {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--map-subtle-bg);
    border: 1px solid var(--map-panel-border);
    border-radius: 6px;
    color: var(--map-text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.deck-toggle:hover {
    background: var(--map-subtle-bg-hover);
    color: var(--map-text-primary);
}

.deck-toggle.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.4);
    color: #a5b4fc;
}

.deck-toggle .material-icons {
    font-size: 16px;
}

.deck-legend {
    padding: 12px 16px;
}

.deck-legend-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--map-text-muted);
    margin-bottom: 8px;
}

.deck-legend-gradient {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg,
        #4285f4,
        #00bcd4,
        #4caf50,
        #ffeb3b,
        #ff9800,
        #f44336
    );
    margin-bottom: 4px;
}

.deck-legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--map-text-muted);
}


/* ============================================
   deck.gl Tooltip
   ============================================ */
.deck-tooltip {
    position: fixed;
    z-index: 10001;
    padding: 10px 14px;
    background: var(--map-panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--map-panel-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    display: none;
    max-width: 220px;
}

.deck-tooltip-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--map-text-primary);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deck-tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    margin-bottom: 3px;
}

.deck-tooltip-row span {
    color: var(--map-text-muted);
}

.deck-tooltip-row strong {
    color: var(--map-text-primary);
}

.deck-tooltip-city {
    font-size: 11px;
    color: var(--map-text-muted);
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--map-panel-border);
}


/* ============================================
   deck.gl Responsive
   ============================================ */
@media (max-width: 768px) {
    .deck-control-panel {
        top: auto;
        bottom: 80px;
        right: 16px;
        left: 16px;
        width: auto;
    }

    .deck-control-stats {
        justify-content: center;
    }

    .deck-toggle-group {
        flex-wrap: wrap;
    }
}


/* ============================================
   Google Places Autocomplete Styling
   ============================================ */

/* New PlaceAutocompleteElement styling */
gmp-place-autocomplete {
    --gmp-mat-color-surface: var(--map-panel-bg-solid) !important;
    --gmp-mat-color-on-surface: var(--map-text-primary) !important;
    --gmp-mat-color-on-surface-variant: var(--map-text-secondary) !important;
    --gmp-mat-color-primary: var(--map-accent) !important;
    font-family: inherit !important;
}

/* PlaceAutocompleteElement input styling */
gmp-place-autocomplete::part(input) {
    background: var(--map-input-bg) !important;
    border: 1px solid var(--map-input-border) !important;
    border-radius: var(--control-radius) !important;
    color: var(--map-text-primary) !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
}

gmp-place-autocomplete::part(input):focus {
    border-color: var(--map-accent) !important;
    box-shadow: 0 0 0 3px var(--map-accent-glow) !important;
    outline: none !important;
}

gmp-place-autocomplete::part(input)::placeholder {
    color: var(--map-text-muted) !important;
}

/* Dropdown list styling */
gmp-place-autocomplete::part(list) {
    background: var(--map-panel-bg-solid) !important;
    border: 1px solid var(--map-panel-border) !important;
    border-radius: var(--control-radius) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
    margin-top: 4px !important;
}

/* Dropdown item styling */
gmp-place-autocomplete::part(prediction-item) {
    padding: 10px 14px !important;
    color: var(--map-text-primary) !important;
    transition: background 0.15s !important;
}

gmp-place-autocomplete::part(prediction-item):hover,
gmp-place-autocomplete::part(prediction-item-selected) {
    background: var(--map-hover-bg) !important;
}

gmp-place-autocomplete::part(prediction-item-main-text) {
    color: var(--map-text-primary) !important;
    font-weight: 500 !important;
}

gmp-place-autocomplete::part(prediction-item-secondary-text) {
    color: var(--map-text-muted) !important;
    font-size: 12px !important;
}

/* Legacy pac-container styling (fallback for older implementations) */
.pac-container {
    background: var(--map-panel-bg-solid) !important;
    border: 1px solid var(--map-panel-border) !important;
    border-radius: var(--control-radius) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
    font-family: inherit !important;
    z-index: 10001 !important;
    margin-top: 4px !important;
}

.pac-container:after {
    display: none !important; /* Hide "Powered by Google" */
}

.pac-item {
    padding: 10px 14px !important;
    border-top: 1px solid var(--map-panel-border) !important;
    color: var(--map-text-primary) !important;
    cursor: pointer !important;
    transition: background 0.15s !important;
}

.pac-item:first-child {
    border-top: none !important;
}

.pac-item:hover,
.pac-item-selected {
    background: var(--map-hover-bg) !important;
}

.pac-item-query {
    color: var(--map-text-primary) !important;
    font-weight: 500 !important;
}

.pac-matched {
    color: var(--map-accent) !important;
    font-weight: 600 !important;
}

.pac-icon {
    display: none !important; /* Hide default icons for cleaner look */
}

/* Address search enhancement - integrate PAC inline with search group */
/* Note: position: relative added to base .map-search-group rule above */

/* Make PAC element fill available space inline (not on new line) */
.map-search-group gmp-place-autocomplete {
    flex: 1 1 auto;
    min-width: 0;
    order: 1; /* Place after icon, before button */
}

/* Style the PAC input to match our theme */
.map-search-group gmp-place-autocomplete::part(input) {
    background: transparent !important;
    border: none !important;
    padding: 10px 12px !important;
    color: var(--map-text-primary) !important;
    font-size: 14px !important;
    box-shadow: none !important;
    outline: none !important;
    width: 100% !important;
}

.map-search-group gmp-place-autocomplete::part(input)::placeholder {
    color: var(--map-text-muted) !important;
}

/* Style the dropdown list */
.map-search-group gmp-place-autocomplete::part(list) {
    background: var(--map-panel-bg-solid) !important;
    border: 1px solid var(--map-panel-border) !important;
    border-radius: var(--control-radius) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4) !important;
    margin-top: 8px !important;
}

/* Ensure original input is hidden when PAC is present */
.map-search-group #mapPlaceSearch {
    display: none;
}

/* If PAC element has [hidden] attribute, show the original input */
.map-search-group:has(gmp-place-autocomplete[hidden]) #mapPlaceSearch {
    display: block;
    flex: 1;
}

/* Hide autocomplete when not focused */
.map-search-group gmp-place-autocomplete[hidden] {
    display: none !important;
}


/* ============================================
   Stats Badge Visibility & Positioning
   ============================================ */

/* Hide stats badge when side panel is open (they would overlap) */
#mapSidePanel.map-side-panel.open ~ .map-stats-badge,
#mapSidePanel.open ~ .map-stats-badge {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Ensure stats badge is visible by default */
.map-stats-badge {
    transition: opacity 0.2s ease, transform 0.2s ease;
}


/* ============================================
   Mobile Improvements
   ============================================ */

@media (max-width: 768px) {
    /* Full-width controls panel on mobile */
    .map-controls-panel {
        top: 68px;
        left: 8px;
        width: calc(100vw - 16px);
        max-height: 50vh;
    }

    /* Smaller tab nav on mobile */
    .map-tab-nav {
        top: 8px;
        left: 8px;
        right: 8px;
        width: auto;
        flex-wrap: wrap;
        gap: 4px;
    }

    .map-tab-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .map-tab-btn .material-icons {
        display: none;
    }

    /* Stats badge repositioned */
    .map-stats-badge {
        top: auto;
        bottom: 90px;
        right: 8px;
        padding: 8px 12px;
        font-size: 12px;
    }

    /* Side panel takes more space on mobile */
    #mapSidePanel.map-side-panel {
        top: 68px;
        right: 8px;
        left: 8px;
        width: auto;
        max-height: calc(100vh - 160px);
    }

    /* Collapsed panel toggle */
    .map-panel-toggle {
        top: 68px;
        left: 8px;
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    /* Even more compact on small phones */
    .map-controls-panel {
        top: 60px;
        max-height: 45vh;
    }

    .map-tab-nav {
        top: 4px;
        left: 4px;
        right: 4px;
    }

    .map-tab-btn {
        padding: 6px 10px;
        font-size: 11px;
        flex: 1;
        justify-content: center;
    }

    .map-bottom-toolbar {
        bottom: 16px;
        left: 8px;
        right: 8px;
        width: auto;
        transform: none;
    }

    .map-toolbar-btn {
        padding: 8px 12px;
    }

    .map-status-group {
        flex-direction: column;
    }

    .map-status-chip {
        width: 100%;
        justify-content: center;
    }
}


/* ============================================
   Close Panel Button Enhancement
   ============================================ */

#closePanelBtn {
    background: none;
    border: none;
    padding: 0;
}

/* Smooth panel slide animation */
#mapSidePanel.map-side-panel {
    will-change: transform;
}

/* Better focus states for accessibility */
.map-tab-btn:focus-visible,
.map-toolbar-btn:focus-visible,
.map-status-chip:focus-visible,
.map-filter-select:focus-visible {
    outline: 2px solid var(--map-accent);
    outline-offset: 2px;
}

/* Touch-friendly tap targets (min 44px) */
@media (pointer: coarse) {
    .map-tab-btn,
    .map-toolbar-btn,
    .map-status-chip {
        min-height: 44px;
    }

    .map-search-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .map-side-panel-close,
    .map-panel-toggle {
        min-width: 44px;
        min-height: 44px;
    }
}


/* ============================================
   Panel Header Styling
   ============================================ */

.map-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.map-panel-header .map-filter-label {
    margin: 0;
}

.map-panel-header .map-side-panel-close .material-icons {
    font-size: 18px;
}


/* ============================================
   Status Chip Icon & Label Styling
   ============================================ */

.map-status-chip .chip-icon {
    font-size: 14px;
    margin-right: 4px;
}

.map-status-chip .chip-label {
    font-weight: 500;
}

/* Stats badge icon sizing */
.map-stats-badge .stats-icon {
    font-size: 18px;
}


/* ============================================
   Search Group Icon Styling
   ============================================ */

.map-search-group .material-icons:first-child {
    color: var(--map-text-muted);
    margin-left: 8px;
    font-size: 20px;
}


/* ============================================
   Reduced Motion Support
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .map-floating-panel,
    .map-side-panel,
    #mapSidePanel.map-side-panel,
    .map-status-chip,
    .map-tab-btn,
    .map-toolbar-btn {
        transition: none !important;
        animation: none !important;
    }
}


/* ============================================
   Browser Fallbacks
   ============================================ */

/* Fallback for browsers without backdrop-filter */
@supports not (backdrop-filter: blur(16px)) {
    .map-floating-panel,
    .map-tab-nav,
    .map-controls-panel,
    .map-bottom-toolbar,
    .map-stats-badge,
    #mapSidePanel.map-side-panel {
        background: var(--map-panel-bg-solid);
    }
}

/* Note: inset property fallback removed - main rule now uses explicit top/right/bottom/left */


/* ============================================
   Toolbar Label Styling
   ============================================ */

.map-toolbar-btn .toolbar-label {
    font-weight: 500;
}

/* Hide toolbar labels on mobile - show only icons */
@media (max-width: 768px) {
    .map-toolbar-btn .toolbar-label {
        display: none;
    }
}


/* ============================================
   Firefox Scrollbar Support
   ============================================ */

.map-controls-panel {
    scrollbar-width: thin;
    scrollbar-color: var(--map-scrollbar) transparent;
}


/* ============================================
   Sidebar Adjustments for Fullscreen Map
   ============================================ */

/* Sidebar adjustments are now handled in the main fullscreen-map rules above */
/* Using position: fixed with left property for proper sidebar awareness */

/* Prevent body scroll when map is active */
body:has(#jobMapSection.fullscreen-map:not(.hide)) {
    overflow: hidden !important;
}

/* Mobile: no sidebar, full width */
@media (max-width: 767.98px) {
    #jobMapSection.fullscreen-map {
        left: 0 !important;
        top: 56px;
    }
}


/* ============================================
   Google Maps InfoWindow Styling
   ============================================ */

/* Target the InfoWindow content wrapper */
.gm-style .gm-style-iw-c {
    padding: 0 !important;
    max-width: 260px !important;
}

/* Content area - single scrollable container */
.gm-style .gm-style-iw-d {
    overflow: auto !important;
    max-height: 180px !important;
    padding: 0 !important;
}

/* Well info window content - no nested scroll */
.well-info-content {
    font-size: 10px;
    line-height: 1.2;
    padding: 8px 10px;
    background: white;
    color: #333;
}

.well-info-content h4 {
    margin: 0 0 4px 0;
    font-size: 11px;
    font-weight: 600;
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 3px;
}

.well-info-content p {
    margin: 0 0 1px 0;
    padding: 0;
    font-size: 10px;
    line-height: 1.15;
}

.well-info-content strong {
    color: #64748b;
    font-weight: 500;
    font-size: 9px;
}

.well-info-content a {
    color: #008eff;
    text-decoration: none;
}

.well-info-content a:hover {
    text-decoration: underline;
}

/* Hide the default close button tail/arrow */
.gm-style-iw-tc {
    display: none;
}

/* Compact scrollbar for Google Maps InfoWindow */
.gm-style .gm-style-iw-d::-webkit-scrollbar {
    width: 5px;
}

.gm-style .gm-style-iw-d::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.gm-style .gm-style-iw-d::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.gm-style .gm-style-iw-d::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ============================================
   Project Info Window (hover)
   ============================================ */
.project-info-window {
    padding: 10px 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    min-width: 160px;
}

.project-info-window .project-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.project-info-window .project-id {
    font-weight: 700;
    font-size: 14px;
    color: #1e293b;
}

.project-info-window .project-status {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.project-info-window .project-status.status-open {
    background: #fef3c7;
    color: #92400e;
}

.project-info-window .project-status.status-proposal {
    background: #e0e7ff;
    color: #3730a3;
}

.project-info-window .project-status.status-complete {
    background: #dcfce7;
    color: #166534;
}

.project-info-window .project-title {
    font-weight: 500;
    color: #334155;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.project-info-window .project-employee {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 2px;
}

.project-info-window .project-type {
    font-size: 11px;
    color: #94a3b8;
}

.project-info-window .project-detail {
    font-size: 12px;
    color: #475569;
    margin-bottom: 2px;
}

.project-info-window .project-count {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

/* ============================================
   Equipment Info Window (click)
   ============================================ */
.equipment-info-window {
    padding: 10px 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    min-width: 180px;
}

.equipment-info-window .equipment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.equipment-info-window .equipment-name {
    font-weight: 700;
    font-size: 14px;
    color: #1e293b;
}

.equipment-info-window .equipment-engine {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.equipment-info-window .equipment-engine.engine-on {
    background: #dcfce7;
    color: #166534;
}

.equipment-info-window .equipment-engine.engine-off {
    background: #f1f5f9;
    color: #64748b;
}

.equipment-info-window .equipment-operator {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 6px;
}

.equipment-info-window .equipment-status {
    font-size: 12px;
    color: #475569;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
}

.equipment-info-window .equipment-job {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
}

.equipment-info-window .equipment-job a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    font-size: 12px;
}

.equipment-info-window .equipment-job a:hover {
    text-decoration: underline;
}

/* ============================================
   Historical Wells Legend
   ============================================ */

.historical-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--map-panel-bg, rgba(255, 255, 255, 0.95));
    border-radius: 8px;
    font-size: 11px;
    color: var(--map-text, #1e293b);
}

.historical-legend .legend-title {
    font-weight: 600;
    white-space: nowrap;
}

.historical-legend .legend-gradient {
    width: 120px;
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(to right,
        #0000ff 0%,      /* Blue - 1900 */
        #00ffff 25%,     /* Cyan */
        #00ff00 50%,     /* Green */
        #ffff00 75%,     /* Yellow */
        #ff0000 100%     /* Red - 2025 */
    );
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.historical-legend .legend-labels {
    display: flex;
    justify-content: space-between;
    width: 120px;
    font-size: 9px;
    color: var(--map-text-muted, #64748b);
    margin-left: -120px;
    margin-top: 18px;
}

/* Adjust layout for the legend in toolbar */
.map-bottom-toolbar .historical-legend {
    margin: 0 8px;
}

/* ============================================
   Dark Mode - Info Windows
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Google Maps InfoWindow container */
    .gm-style .gm-style-iw-c {
        background: #1e293b !important;
    }

    .gm-style .gm-style-iw-d {
        background: #1e293b;
    }

    /* Well info window */
    .well-info-content {
        background: #1e293b;
        color: #e2e8f0;
    }

    .well-info-content h4 {
        color: #f1f5f9;
        border-bottom-color: #334155;
    }

    .well-info-content strong {
        color: #94a3b8;
    }

    .well-info-content a {
        color: #60a5fa;
    }

    /* Scrollbar for dark mode */
    .gm-style .gm-style-iw-d::-webkit-scrollbar-track {
        background: #334155;
    }

    .gm-style .gm-style-iw-d::-webkit-scrollbar-thumb {
        background: #475569;
    }

    .gm-style .gm-style-iw-d::-webkit-scrollbar-thumb:hover {
        background: #64748b;
    }

    /* Project info window */
    .project-info-window .project-id {
        color: #f1f5f9;
    }

    .project-info-window .project-title {
        color: #cbd5e1;
    }

    .project-info-window .project-employee {
        color: #94a3b8;
    }

    .project-info-window .project-type {
        color: #64748b;
    }

    .project-info-window .project-detail {
        color: #94a3b8;
    }

    .project-info-window .project-count {
        color: #94a3b8;
    }

    /* Equipment info window */
    .equipment-info-window .equipment-name {
        color: #f1f5f9;
    }

    .equipment-info-window .equipment-engine.engine-off {
        background: #334155;
        color: #94a3b8;
    }

    .equipment-info-window .equipment-operator {
        color: #94a3b8;
    }

    .equipment-info-window .equipment-status {
        color: #cbd5e1;
    }

    .equipment-info-window .equipment-job {
        border-top-color: #334155;
    }

    .equipment-info-window .equipment-job a {
        color: #60a5fa;
    }
}

/* Dark mode via Bootstrap attribute */
[data-bs-theme="dark"] {
    /* Google Maps InfoWindow container */
    .gm-style .gm-style-iw-c {
        background: #1e293b !important;
    }

    .gm-style .gm-style-iw-d {
        background: #1e293b;
    }

    /* Well info window */
    .well-info-content {
        background: #1e293b;
        color: #e2e8f0;
    }

    .well-info-content h4 {
        color: #f1f5f9;
        border-bottom-color: #334155;
    }

    .well-info-content strong {
        color: #94a3b8;
    }

    .well-info-content a {
        color: #60a5fa;
    }

    /* Scrollbar for dark mode */
    .gm-style .gm-style-iw-d::-webkit-scrollbar-track {
        background: #334155;
    }

    .gm-style .gm-style-iw-d::-webkit-scrollbar-thumb {
        background: #475569;
    }

    .gm-style .gm-style-iw-d::-webkit-scrollbar-thumb:hover {
        background: #64748b;
    }

    /* Project info window */
    .project-info-window .project-id {
        color: #f1f5f9;
    }

    .project-info-window .project-title {
        color: #cbd5e1;
    }

    .project-info-window .project-employee {
        color: #94a3b8;
    }

    .project-info-window .project-type {
        color: #64748b;
    }

    .project-info-window .project-detail {
        color: #94a3b8;
    }

    .project-info-window .project-count {
        color: #94a3b8;
    }

    /* Equipment info window */
    .equipment-info-window .equipment-name {
        color: #f1f5f9;
    }

    .equipment-info-window .equipment-engine.engine-off {
        background: #334155;
        color: #94a3b8;
    }

    .equipment-info-window .equipment-operator {
        color: #94a3b8;
    }

    .equipment-info-window .equipment-status {
        color: #cbd5e1;
    }

    .equipment-info-window .equipment-job {
        border-top-color: #334155;
    }

    .equipment-info-window .equipment-job a {
        color: #60a5fa;
    }
}

/* ============================================
   NEARBY WELLS PANEL STYLES
   ============================================ */

/* Loading state */
.nearby-wells-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--map-text-muted);
}

/* Wells list container */
.nearby-wells-list {
    padding: 12px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* Results count header */
.nearby-wells-count {
    font-size: 13px;
    color: var(--map-text-muted);
    margin-bottom: 12px;
    padding: 0 4px;
}

/* Individual well card */
.nearby-well-card {
    background: var(--map-panel-bg);
    border: 1px solid var(--map-border);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.nearby-well-card:hover {
    border-color: var(--map-accent);
}

.nearby-well-card.expanded {
    border-color: var(--map-accent);
    box-shadow: 0 2px 8px rgba(0, 142, 255, 0.15);
}

/* Card header (always visible) */
.well-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    gap: 10px;
}

.well-card-main {
    flex: 1;
    min-width: 0;
}

.well-card-id {
    font-weight: 600;
    font-size: 14px;
    color: var(--map-text-primary);
    margin-bottom: 4px;
}

.well-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.well-card-distance {
    font-size: 12px;
    color: var(--map-text-muted);
}

.well-card-date {
    font-size: 12px;
    color: var(--map-text-muted);
}

/* Expand indicator */
.well-card-expand {
    color: var(--map-text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.nearby-well-card.expanded .well-card-expand {
    transform: rotate(180deg);
}

/* Depth badge */
.well-depth-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.depth-shallow {
    background: #e3f2fd;
    color: #1565c0;
}

.depth-medium {
    background: #e8f5e9;
    color: #2e7d32;
}

.depth-deep {
    background: #fff3e0;
    color: #ef6c00;
}

.depth-very-deep {
    background: #ffebee;
    color: #c62828;
}

/* Expandable details section */
.well-card-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    border-top: 1px solid transparent;
}

.nearby-well-card.expanded .well-card-details {
    max-height: 400px;
    border-top-color: var(--map-border);
}

.well-details-inner {
    padding: 12px;
}

.well-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--map-border);
    font-size: 13px;
}

.well-detail-row:last-child {
    border-bottom: none;
}

.well-detail-label {
    color: var(--map-text-muted);
}

.well-detail-value {
    color: var(--map-text-primary);
    font-weight: 500;
    text-align: right;
}

/* Well log link button */
.well-log-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    background: var(--map-accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease;
}

.well-log-link:hover {
    background: #0070cc;
    color: white;
}

.well-log-link .material-icons {
    font-size: 18px;
}

/* Load more button */
.nearby-wells-load-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    margin-top: 8px;
    background: transparent;
    border: 1px dashed var(--map-border);
    border-radius: 8px;
    color: var(--map-accent);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.nearby-wells-load-more:hover {
    background: rgba(0, 142, 255, 0.05);
    border-color: var(--map-accent);
}

.nearby-wells-load-more:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* No results / error states */
.nearby-wells-empty,
.nearby-wells-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--map-text-muted);
}

.nearby-wells-empty .material-icons,
.nearby-wells-error .material-icons {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.nearby-wells-empty h6,
.nearby-wells-error h6 {
    font-size: 16px;
    color: var(--map-text-primary);
    margin-bottom: 8px;
}

.nearby-wells-empty p,
.nearby-wells-error p {
    font-size: 13px;
    margin: 0;
}

/* ============================================
   Nearby Wells Panel Header & Close Button
   ============================================ */

/* Panel header - sticky with glassmorphism */
#mapSidePanel .map-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 14px 16px;
    margin: 0;
    border-bottom: 1px solid var(--map-border);
    background: var(--map-panel-bg);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Title styling */
#mapSidePanel .map-panel-header h6 {
    display: flex;
    align-items: center;
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--map-text-primary);
    letter-spacing: -0.01em;
}

#mapSidePanel .map-panel-header h6 .material-icons {
    color: var(--map-accent);
    margin-right: 8px;
    font-size: 20px;
}

/* Close button styling */
#mapSidePanel .map-panel-close {
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(100, 116, 139, 0.1);
    border: none;
    border-radius: 8px;
    color: var(--map-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

#mapSidePanel .map-panel-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    transform: scale(1.05);
}

#mapSidePanel .map-panel-close:active {
    transform: scale(0.95);
}

#mapSidePanel .map-panel-close .material-icons {
    font-size: 20px;
}

/* Scrollbar styling for the panel */
#mapSidePanel::-webkit-scrollbar {
    width: 6px;
}

#mapSidePanel::-webkit-scrollbar-track {
    background: transparent;
}

#mapSidePanel::-webkit-scrollbar-thumb {
    background: var(--map-border);
    border-radius: 3px;
}

#mapSidePanel::-webkit-scrollbar-thumb:hover {
    background: var(--map-text-muted);
}

/* Wells list scrollbar */
.nearby-wells-list::-webkit-scrollbar {
    width: 5px;
}

.nearby-wells-list::-webkit-scrollbar-track {
    background: transparent;
}

.nearby-wells-list::-webkit-scrollbar-thumb {
    background: var(--map-border);
    border-radius: 3px;
}

/* Dark mode adjustments for nearby wells panel */
@media (prefers-color-scheme: dark) {
    .depth-shallow {
        background: rgba(21, 101, 192, 0.2);
        color: #64b5f6;
    }

    .depth-medium {
        background: rgba(46, 125, 50, 0.2);
        color: #81c784;
    }

    .depth-deep {
        background: rgba(239, 108, 0, 0.2);
        color: #ffb74d;
    }

    .depth-very-deep {
        background: rgba(198, 40, 40, 0.2);
        color: #e57373;
    }

    /* Dark mode close button */
    #mapSidePanel .map-panel-close {
        background: rgba(148, 163, 184, 0.1);
    }

    #mapSidePanel .map-panel-close:hover {
        background: rgba(239, 68, 68, 0.2);
    }

    /* Dark mode scrollbar */
    #mapSidePanel::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.3);
    }

    #mapSidePanel::-webkit-scrollbar-thumb:hover {
        background: rgba(148, 163, 184, 0.5);
    }
}
