/**
 * Map Layer Control Panel Styles
 *
 * Styles for the floating layer control panel on the interactive map.
 * Adapted from the 3D viewer's layer_controls.css for consistency.
 */

/* ============================================================================
   Control Panel Container
   ============================================================================ */

.map-layer-control-panel {
    position: absolute;
    bottom: 30px;
    right: 10px;
    background: rgba(30, 30, 30, 0.95);
    color: #fff;
    border-radius: 8px;
    width: 280px;
    max-width: calc(100vw - 20px);
    z-index: 1000;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

/* ============================================================================
   Panel Header
   ============================================================================ */

.map-layer-control-header {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    order: 2;  /* Place header at bottom */
}

.map-layer-control-header h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #4ECDC4;
}

.map-layer-control-header h4 i {
    margin-right: 8px;
}

.map-layer-control-header > i {
    transition: transform 0.3s ease;
    color: #888;
    transform: rotate(180deg);  /* Point up when expanded */
}

.map-layer-control-header.collapsed > i {
    transform: rotate(0deg);  /* Point down when collapsed */
}

/* ============================================================================
   Panel Body
   ============================================================================ */

.map-layer-control-body {
    padding: 12px 16px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    transition: all 0.3s ease;
    order: 1;  /* Place body above header */
}

.map-layer-control-body.collapsed {
    display: none;
}

/* ============================================================================
   Layer Sections
   ============================================================================ */

.map-layer-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.map-layer-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.map-layer-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    cursor: pointer;
}

.map-layer-section-header h5 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #e0e0e0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.map-layer-section-header h5 i {
    color: #4ECDC4;
    width: 16px;
    text-align: center;
}

.map-layer-section-header .collapse-icon {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
    color: #666;
}

.map-layer-section-header[aria-expanded="false"] .collapse-icon,
.map-layer-section-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

/* ============================================================================
   Toggle Switches (Bootstrap-style form switches)
   ============================================================================ */

.map-layer-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.map-layer-toggle label {
    font-size: 0.8rem;
    color: #ccc;
    margin: 0;
    cursor: pointer;
}

.map-layer-toggle .form-check-input {
    width: 36px;
    height: 18px;
    cursor: pointer;
    background-color: #444;
    border-color: #555;
}

.map-layer-toggle .form-check-input:checked {
    background-color: #4ECDC4;
    border-color: #4ECDC4;
}

.map-layer-toggle .form-check-input:focus {
    box-shadow: 0 0 0 0.15rem rgba(78, 205, 196, 0.25);
    border-color: #4ECDC4;
}

/* ============================================================================
   Sub-controls (shown when parent is enabled)
   ============================================================================ */

.map-layer-subcontrols {
    margin-left: 8px;
    padding-left: 12px;
    border-left: 2px solid rgba(78, 205, 196, 0.3);
    margin-top: 8px;
}

.map-layer-subcontrols.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================================================
   Color Scheme Selector (Radio buttons)
   ============================================================================ */

.map-color-scheme-group {
    margin-top: 8px;
}

.map-color-scheme-group .form-label {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 6px;
    display: block;
}

.map-color-scheme-option {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 2px;
}

.map-color-scheme-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.map-color-scheme-option input[type="radio"] {
    margin: 0 8px 0 0;
    accent-color: #4ECDC4;
    cursor: pointer;
}

.map-color-scheme-option label {
    margin: 0;
    font-size: 0.8rem;
    color: #ccc;
    cursor: pointer;
}

.map-color-scheme-option input[type="radio"]:checked + label {
    color: #4ECDC4;
}

/* ============================================================================
   Opacity Sliders
   ============================================================================ */

.map-opacity-control {
    margin-top: 8px;
}

.map-opacity-control .form-label {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.map-opacity-control .form-label .opacity-value {
    color: #4ECDC4;
    font-weight: 500;
}

.map-opacity-control .form-range {
    width: 100%;
    height: 6px;
    background: #444;
    border-radius: 3px;
    -webkit-appearance: none;
    appearance: none;
}

.map-opacity-control .form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #4ECDC4;
    border-radius: 50%;
    cursor: pointer;
}

.map-opacity-control .form-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #4ECDC4;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

/* ============================================================================
   Point Sample Layer List
   ============================================================================ */

.map-pointsample-layers {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.map-pointsample-layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.map-pointsample-layer-item .color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.map-pointsample-layer-item label {
    font-size: 0.8rem;
    color: #ccc;
    margin: 0;
    flex: 1;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================================
   Empty State
   ============================================================================ */

.map-layer-empty {
    font-size: 0.75rem;
    color: #666;
    font-style: italic;
    padding: 4px 0;
}

/* ============================================================================
   Zoom To Button
   ============================================================================ */

.map-zoom-to-btn {
    width: 100%;
    padding: 6px 12px;
    font-size: 0.75rem;
    margin-top: 8px;
    background: rgba(78, 205, 196, 0.1);
    border: 1px solid rgba(78, 205, 196, 0.3);
    color: #4ECDC4;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.map-zoom-to-btn:hover {
    background: rgba(78, 205, 196, 0.2);
    border-color: #4ECDC4;
}

.map-zoom-to-btn i {
    margin-right: 6px;
}

/* ============================================================================
   Custom Scrollbar
   ============================================================================ */

.map-layer-control-body::-webkit-scrollbar {
    width: 6px;
}

.map-layer-control-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.map-layer-control-body::-webkit-scrollbar-thumb {
    background: rgba(78, 205, 196, 0.5);
    border-radius: 3px;
}

.map-layer-control-body::-webkit-scrollbar-thumb:hover {
    background: rgba(78, 205, 196, 0.7);
}

/* ============================================================================
   Mobile Responsiveness
   ============================================================================ */

@media (max-width: 576px) {
    .map-layer-control-panel {
        bottom: 15px;
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 50vh;
    }

    /* When collapsed on mobile, make it half width to avoid overlap with legend */
    .map-layer-control-panel:has(.map-layer-control-body.collapsed) {
        left: auto;
        width: 140px;
    }

    .map-layer-control-body {
        max-height: calc(50vh - 60px);
    }
}

/* ============================================================================
   Collapse Animation
   ============================================================================ */

.map-layer-section-content {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.map-layer-section-content.collapsed {
    max-height: 0 !important;
    padding: 0;
}
