/* Map Measurer Modal & UI Styling */

.map-measurer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.map-measurer-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.map-measurer-window {
    width: 95vw;
    max-width: 1280px;
    height: 90vh;
    max-height: 850px;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #f4f4f5;
}

/* Header */
.map-measurer-header {
    padding: 14px 20px;
    background: #09090b;
    border-bottom: 1px solid #27272a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.map-measurer-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
}

.map-measurer-title span.badge {
    background: #ff7a00;
    color: #ffffff;
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.map-measurer-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 480px;
}

.map-measurer-search input {
    width: 100%;
    padding: 8px 12px;
    background: #18181b;
    border: 1px solid #3f3f46;
    border-radius: 6px;
    color: #ffffff;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.map-search-autocomplete-box {
    position: absolute;
    top: 100%;
    left: 0;
    right: 80px;
    background: #18181b;
    border: 1px solid #ff7a00;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.9);
    z-index: 999999;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 4px;
    display: none;
}

.map-search-suggestion-item {
    padding: 10px 14px;
    font-size: 0.85rem;
    color: #e4e4e7;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.15s ease;
}

.map-search-suggestion-item:hover {
    background: rgba(255,122,0,0.25);
    color: #ffffff;
}

.map-measurer-search input:focus {
    border-color: #ff7a00;
}

.map-measurer-search button {
    padding: 8px 14px;
    background: #ff7a00;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease;
}

.map-measurer-search button:hover {
    background: #e06c00;
}

.map-measurer-close {
    background: transparent;
    border: none;
    color: #a1a1aa;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s ease, background 0.2s ease;
}

.map-measurer-close:hover {
    color: #ffffff;
    background: #27272a;
}

/* Main Container */
.map-measurer-body {
    display: flex;
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Map area */
.map-measurer-map-container {
    flex: 1;
    position: relative;
    background: #121212;
}

#map-measurer-leaflet {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Sidebar / Controls Panel */
.map-measurer-sidebar {
    width: 320px;
    background: #09090b;
    border-left: 1px solid #27272a;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    overflow-y: auto;
}

/* Mode Selection Cards */
.map-mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.map-mode-btn {
    padding: 10px;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 8px;
    color: #a1a1aa;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.map-mode-btn.active {
    background: rgba(255, 122, 0, 0.15);
    border-color: #ff7a00;
    color: #ff7a00;
}

.map-mode-btn:hover:not(.active) {
    background: #27272a;
    color: #ffffff;
}

/* Stats Metrics Cards */
.map-metrics-panel {
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metric-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.metric-label {
    font-size: 0.82rem;
    color: #a1a1aa;
}

.metric-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
}

.metric-value.highlight {
    color: #ff7a00;
}

/* Depth / Height Control */
.depth-input-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    border-top: 1px dashed #27272a;
}

.depth-input-group label {
    font-size: 0.82rem;
    color: #a1a1aa;
}

.depth-input-group input {
    width: 70px;
    padding: 4px 8px;
    background: #09090b;
    border: 1px solid #3f3f46;
    border-radius: 4px;
    color: #ffffff;
    text-align: right;
    font-weight: 600;
    font-size: 0.88rem;
}

/* Segment list */
.segment-list-container {
    flex: 1;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    max-height: 200px;
}

.segment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    background: #09090b;
    border-radius: 4px;
    font-size: 0.8rem;
}

.segment-name {
    color: #a1a1aa;
}

.segment-length {
    color: #ffffff;
    font-weight: 600;
}

/* Actions */
.map-measurer-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.btn-measurer-primary {
    width: 100%;
    padding: 11px;
    background: #ff7a00;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s ease, transform 0.1s ease;
}

.btn-measurer-primary:hover {
    background: #e06c00;
}

.btn-measurer-primary:active {
    transform: scale(0.99);
}

.btn-measurer-secondary {
    width: 100%;
    padding: 9px;
    background: #27272a;
    color: #ffffff;
    border: 1px solid #3f3f46;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s ease;
}

.btn-measurer-secondary:hover {
    background: #3f3f46;
}

.btn-measurer-danger {
    width: 100%;
    padding: 7px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-measurer-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Map Instructions Overlay */
.map-help-tooltip {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 999;
    background: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: #d4d4d8;
    pointer-events: none;
}

/* Responsive Styles for Mobile & Tablets */
@media (max-width: 768px) {
    .map-measurer-window {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        border: none !important;
    }

    .map-measurer-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 10px 14px !important;
    }

    .map-measurer-title {
        font-size: 0.95rem !important;
        justify-content: space-between !important;
    }

    .map-measurer-search {
        max-width: 100% !important;
        width: 100% !important;
    }

    .map-measurer-body {
        flex-direction: column !important;
    }

    .map-measurer-map-container {
        height: 55% !important;
        flex: none !important;
    }

    .map-measurer-sidebar {
        width: 100% !important;
        height: 45% !important;
        border-left: none !important;
        border-top: 1px solid #27272a !important;
        padding: 12px !important;
        gap: 10px !important;
    }

    .segment-list-container {
        max-height: 90px !important;
    }
}
