/* 
 * LEA+ Dynamic Map Stylesheets 
 * Extracted map-specific overlays, controls, and leaflet overrides.
 * Updated to match Tailwind / Flowbite Design System
 */

.leaflet-control-container .leaflet-routing-container,
.leaflet-control-container .leaflet-bar,
.leaflet-control-container .leaflet-control {
    border: none;
    box-shadow: none;
}

/* --- Search Input UI --- */
.leaflet-control-search {
    background: #111827 !important;
    border: 1px solid #1f2937 !important;
    border-radius: 0.75rem !important; /* xl rounded */
    padding: 4px !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.8), 0 8px 10px -6px rgba(0, 0, 0, 0.6) !important;
    margin-left: 20px !important;
    margin-top: 20px !important;
}

.leaflet-control-search label {
    display: none !important;
}

.leaflet-control-search .search-input {
    background: transparent !important;
    border: none !important;
    color: #fff !important;
    font-size: 0.875rem !important; /* text-sm */
    padding: 0 16px !important;
    width: 250px !important;
    height: 40px !important;
    outline: none !important;
}

.leaflet-control-search .search-input::placeholder {
    color: #6b7280 !important; /* gray-500 */
}

.search-tooltip,
ul.search-tooltip {
    background: #1f2937 !important; /* gray-800 */
    border: 1px solid #374151 !important; /* gray-700 */
    border-radius: 0.5rem !important;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5) !important;
    margin-top: 8px !important;
    padding: 0 !important;
    list-style: none !important;
    max-height: 250px !important;
    overflow-y: auto !important;
}

.search-tip,
.search-tooltip li.search-tip {
    color: #d1d5db !important; /* gray-300 */
    background: transparent !important;
    padding: 10px 16px !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: background-color 0.2s, color 0.2s !important;
    border-bottom: 1px solid #374151 !important;
    display: block !important;
}

.search-tip:last-child {
    border-bottom: none !important;
}

.search-tip:hover,
.search-tooltip li.search-tip:hover {
    background: #374151 !important; /* gray-700 */
    color: #fff !important;
}

/* --- Zoom Controls --- */
.lea-custom-map-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-left: 20px !important;
    margin-top: 20px !important;
}

.lea-zoom-btn {
    width: 44px;
    height: 44px;
    background: #111827;
    border: 1px solid #1f2937;
    border-radius: 0.5rem;
    color: #9ca3af; /* gray-400 */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.5);
    font-size: 1.1rem;
}

.lea-zoom-btn:hover {
    color: #fff;
    border-color: #3b82f6; /* blue-500 */
    background: #1f2937; /* gray-800 */
}

/* --- Drawing Controls --- */
.leaflet-custom-draw-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-right: 20px !important;
    margin-top: 20px !important;
}

.leaflet-draw-custom-container,
.leaflet-draw-action-container,
.leaflet-custom-color-picker {
    background: #111827;
    border: 1px solid #1f2937;
    border-radius: 0.75rem;
    padding: 6px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.8);
}

.leaflet-draw-custom-container,
.leaflet-draw-action-container {
    display: grid;
    grid-template-columns: 46px 46px;
    gap: 4px;
}

.leaflet-custom-color-picker {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    justify-items: center;
    padding: 10px;
}

.leaflet-custom-draw-button {
    width: 46px;
    height: 46px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.2s;
}

.leaflet-custom-draw-button:hover {
    background: #1f2937;
    color: #fff;
}

.leaflet-custom-draw-button.active {
    background: rgba(59, 130, 246, 0.15); /* blue-500 / 15% */
    border-color: #3b82f6;
    color: #3b82f6;
}

.leaflet-custom-draw-button:disabled {
    opacity: 0.2;
    pointer-events: none;
}

/* Colors */
.leaflet-color-button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.leaflet-color-button.selected {
    transform: scale(1.2);
    border-color: #fff;
    box-shadow: 0 0 15px currentColor;
    z-index: 10;
}

/* --- HUD Text Input --- */
.lea-map-hud-input-wrapper {
    position: absolute;
    background: #111827;
    border: 1px solid #3b82f6;
    border-radius: 0.5rem;
    padding: 6px;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    z-index: 1000;
}

.lea-map-hud-input-wrapper input {
    background: transparent !important;
    border: none !important;
    color: #fff !important;
    outline: none !important;
    font-size: 0.875rem !important;
    padding: 0 8px !important;
    width: 200px !important;
}

.lea-shape-label-prompt input {
    background: #1f2937 !important;
    border: 1px solid #3b82f6 !important;
    color: #fff !important;
    border-radius: 0.375rem !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8) !important;
    outline: none !important;
    font-size: 0.75rem !important;
    padding: 0 10px !important;
    height: 30px !important;
    width: 200px !important;
}

/* --- HUD Labels on Map --- */
.lea-map-text-wrapper {
    background: transparent !important;
    border: none !important;
}

/* New flat label - the divIcon itself IS the styled box */
.lea-hud-label {
    background: #111827;
    border: 1px solid #374151;
    color: #f3f4f6;
    padding: 0 10px;
    border-radius: 0.375rem;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    /* Single-line centering: the only method html2canvas renders 1:1 */
    height: 26px;
    line-height: 26px;
    display: block;
}

/* Circular icon marker */
.lea-marker-icon {
    width: 24px !important;
    height: 24px !important;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    color: white;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3b82f6; /* default - overridden inline */
}

/* Legacy - kept for backward compat */
.lea-hud-tooltip {
    background: #111827;
    border: 1px solid #374151;
    color: #f3f4f6;
    padding: 6px 10px;
    border-radius: 0.375rem;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    line-height: 1.4;
}

/* Compact Labels for Shapes */
.lea-compact-label {
    background: #111827 !important;
    border: 1px solid #374151 !important;
    color: #f3f4f6 !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    padding: 0 8px !important;
    border-radius: 0.25rem !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5) !important;
    white-space: nowrap !important;
    height: 22px !important;
    line-height: 22px !important;
    display: block !important;
}

/* Inherit map arrow directions but paint them dark gray */
.leaflet-tooltip-right.lea-compact-label::before { border-right-color: #111827 !important; }
.leaflet-tooltip-left.lea-compact-label::before { border-left-color: #111827 !important; }
.leaflet-tooltip-top.lea-compact-label::before { border-top-color: #111827 !important; }
.leaflet-tooltip-bottom.lea-compact-label::before { border-bottom-color: #111827 !important; }

/* --- Legend --- */
.lea-map-legend {
    background: #111827;
    border: 1px solid #1f2937;
    border-radius: 0.75rem;
    padding: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
    display: none;
    margin-bottom: 20px !important;
    margin-left: 20px !important;
    min-width: 250px;
    min-height: 100px;
    resize: both;
    overflow: hidden; 
    position: relative;
    user-select: none;
}

/* Better visible resizer icon */
.lea-map-legend::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, transparent 50%, #3b82f6 50%);
    border-radius: 0 0 0.75rem 0;
    pointer-events: none; /* Let the native resizer behind it handle clicks */
    opacity: 0.8;
}

.lea-map-legend .legend-title {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: #3b82f6; /* Blue title to indicate grab area */
    margin-bottom: 12px;
    border-bottom: 1px solid #374151;
    padding-bottom: 8px;
    text-transform: uppercase;
    width: 100%;
    line-height: 1.2;
}

.lea-legend-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 20px;
    align-items: flex-start;
}

.lea-map-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    color: #e5e7eb;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1;
}

.lea-map-legend .legend-shape-icon {
    display: block;
    line-height: 0;
}

.lea-map-legend .legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

/* --- Dark Popup overrides --- */
.lea-dark-popup .leaflet-popup-content-wrapper {
    background: transparent !important;
    color: #fff !important;
    padding: 0 !important;
    border-radius: 0.75rem !important;
    box-shadow: none !important;
}

.lea-dark-popup .leaflet-popup-content {
    margin: 0 !important;
    width: auto !important;
}

.lea-dark-popup .leaflet-popup-tip {
    background: #111827 !important;
}

.lea-dark-popup .leaflet-popup-close-button {
    display: none !important;
}