/**
 * TideTrack Frontend - Map Styles
 * Leaflet map container and custom overlays
 */

/* ============================================
   MAP CONTAINER
   ============================================ */

.map-container {
    /* Prevent long-press context menu on touch devices */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    position: absolute;
    top: 0;
    left: var(--panel-width);
    right: 0;
    bottom: 0;
    transition: left var(--transition-base);
    z-index: 1;
}

.left-panel.collapsed~.map-container {
    left: 0;
}

#map {
    width: 100%;
    height: 100%;
}

/* ============================================
   LEAFLET CUSTOMIZATIONS
   ============================================ */

/* Zoom controls */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a {
    background-color: white !important;
    color: var(--color-text-primary) !important;
    border: none !important;
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
    font-size: var(--text-xl) !important;
}

.leaflet-control-zoom a:hover {
    background-color: var(--color-primary) !important;
    color: white !important;
}

/* Attribution */
.leaflet-control-attribution {
    background-color: rgba(255, 255, 255, 0.8) !important;
    font-size: var(--text-xs) !important;
    padding: var(--space-1) var(--space-2) !important;
}

/* Scale */
.leaflet-control-scale {
    background-color: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid var(--color-bg-medium) !important;
    border-radius: var(--radius-sm) !important;
    padding: var(--space-1) var(--space-2) !important;
    font-size: var(--text-xs) !important;
}

/* ============================================
   CUSTOM MAP CONTROLS
   ============================================ */

.map-controls {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    z-index: 400;
}

.map-control-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
    border: none;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--text-lg);
    color: var(--color-text-primary);
}

.map-control-btn:hover {
    background-color: var(--color-primary);
    color: white;
}

.map-control-btn:active {
    transform: scale(0.95);
}

/* ============================================
   MOUSE COORDINATES DISPLAY
   ============================================ */

.mouse-coords {
    position: absolute;
    top: var(--space-4);
    left: 52px;
    background-color: rgba(0, 0, 0, 0.75);
    color: white;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
    font-family: 'Roboto Mono', monospace;
    font-weight: var(--font-medium);
    z-index: 400;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

/* ============================================
   WIND DATA INFO
   ============================================ */

.wind-data-info {
    position: absolute;
    top: var(--space-4);
    left: var(--space-4);
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: var(--space-3);
    min-width: 250px;
    z-index: 400;
    font-size: var(--text-sm);
}

.wind-data-info.hidden {
    display: none;
}

.wind-data-info__title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-1);
    color: var(--color-text-primary);
}

.wind-data-info__location {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    font-family: 'Roboto Mono', monospace;
    margin-bottom: var(--space-2);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--color-bg-medium);
}

.wind-data-info__coords {
    display: block;
}

.wind-data-info__section {
    background-color: rgba(0, 119, 190, 0.05);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
    margin-bottom: var(--space-2);
}

.wind-data-info__divider {
    height: 1px;
    background-color: var(--color-bg-medium);
    margin: var(--space-2) 0;
}

.wind-data-info__item {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-1);
    line-height: 1.5;
}

.wind-data-info__item:last-child {
    margin-bottom: 0;
}

.wind-data-info__label {
    color: var(--color-text-secondary);
    font-weight: var(--font-medium);
}

.wind-data-info__value {
    color: var(--color-text-primary);
    font-weight: var(--font-semibold);
    text-align: right;
}

.wind-data-info__value--highlight {
    color: var(--color-primary);
    font-size: var(--text-base);
}

/* ============================================
   CURRENT DATA INFO
   ============================================ */

.current-data-info {
    position: absolute;
    top: var(--space-4);
    left: var(--space-4);
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: var(--space-3);
    min-width: 250px;
    z-index: 400;
    font-size: var(--text-sm);
}

.current-data-info.hidden {
    display: none;
}

.current-data-info__title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-1);
    color: var(--color-text-primary);
}

.current-data-info__location {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    font-family: 'Roboto Mono', monospace;
    margin-bottom: var(--space-2);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--color-bg-medium);
}

.current-data-info__coords {
    display: block;
}

.current-data-info__section {
    background-color: rgba(13, 71, 161, 0.05);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
    margin-bottom: var(--space-2);
}

.current-data-info__divider {
    height: 1px;
    background-color: var(--color-bg-medium);
    margin: var(--space-2) 0;
}

.current-data-info__item {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-1);
    line-height: 1.5;
}

.current-data-info__item:last-child {
    margin-bottom: 0;
}

.current-data-info__label {
    color: var(--color-text-secondary);
    font-weight: var(--font-medium);
}

.current-data-info__value {
    color: var(--color-text-primary);
    font-weight: var(--font-semibold);
    text-align: right;
}

.current-data-info__value--highlight {
    color: #0D47A1;
    font-size: var(--text-base);
}

/* ============================================
   MAP LEGENDS
   ============================================ */

.map-legends {
    position: absolute;
    bottom: var(--space-4);
    left: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    z-index: 400;
    pointer-events: none;
}

.map-legend {
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: var(--space-3);
    min-width: 150px;
    pointer-events: auto;
}

.map-legend.hidden {
    display: none;
}

.map-legend__title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-2);
    color: var(--color-text-primary);
}

.map-legend__items {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
}

.legend-item__color {
    width: 20px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-item__label {
    color: var(--color-text-primary);
}

/* Wind Legend Colors */
.legend-item__color.wind-light {
    background-color: var(--color-wind-light);
}

.legend-item__color.wind-moderate {
    background-color: var(--color-wind-moderate);
}

.legend-item__color.wind-strong {
    background-color: var(--color-wind-strong);
}

.legend-item__color.wind-very-strong {
    background-color: var(--color-wind-very-strong);
}

.legend-item__color.wind-severe {
    background-color: var(--color-wind-severe);
}

/* Current Legend Colors */
.legend-item__color.current-very-light {
    background-color: var(--color-current-very-light);
}

.legend-item__color.current-light {
    background-color: var(--color-current-light);
}

.legend-item__color.current-medium {
    background-color: var(--color-current-medium);
}

.legend-item__color.current-moderate {
    background-color: var(--color-current-moderate);
}

.legend-item__color.current-strong {
    background-color: var(--color-current-strong);
}

.legend-item__color.current-very-strong {
    background-color: var(--color-current-very-strong);
}

/* ============================================
   CUSTOM MARKERS
   ============================================ */

.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: white;
    border: 3px solid;
    box-shadow: var(--shadow-md);
    font-weight: var(--font-bold);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.custom-marker:hover {
    transform: scale(1.1);
}

.custom-marker.start {
    border-color: var(--color-success);
    color: var(--color-success);
}

.custom-marker.end {
    border-color: var(--color-error);
    color: var(--color-error);
}

.custom-marker.waypoint {
    width: 28px;
    height: 28px;
    border-width: 2px;
    border-color: #F39C12;
    color: #F39C12;
    font-size: 12px;
    background-color: white;
}

.custom-marker.route-waypoint {
    width: 12px;
    height: 12px;
    border-width: 2px;
    border-color: var(--color-primary);
    background-color: var(--color-primary);
}

.gate-arrow {
    color: #FF9800;
    font-size: 14px;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

/* ============================================
   TOOLTIPS
   ============================================ */

.leaflet-tooltip {
    background-color: rgba(0, 0, 0, 0.8) !important;
    border: none !important;
    border-radius: var(--radius-sm) !important;
    padding: var(--space-2) var(--space-3) !important;
    color: white !important;
    font-size: var(--text-sm) !important;
    box-shadow: var(--shadow-lg) !important;
}

.leaflet-tooltip::before {
    border-top-color: rgba(0, 0, 0, 0.8) !important;
}

.tooltip-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.tooltip-content__title {
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-1);
}

.tooltip-content__item {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    font-size: var(--text-xs);
}

.tooltip-content__label {
    color: rgba(255, 255, 255, 0.7);
}

.tooltip-content__value {
    font-weight: var(--font-medium);
}

/* ============================================
   POPUPS
   ============================================ */

.leaflet-popup-content-wrapper {
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-lg) !important;
}

.leaflet-popup-content {
    margin: var(--space-3) !important;
    font-size: var(--text-sm) !important;
}

.popup-content {
    min-width: 200px;
}

.popup-content__title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    margin-bottom: var(--space-2);
    color: var(--color-text-primary);
}

.popup-content__details {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.popup-detail {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-sm);
}

.popup-detail__label {
    color: var(--color-text-secondary);
}

.popup-detail__value {
    font-weight: var(--font-medium);
    color: var(--color-text-primary);
}

/* ============================================
   CANVAS LAYERS
   ============================================ */

.wind-layer-canvas,
.current-layer-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 200;
}

/* ============================================
   ROUTE VISUALIZATION
   ============================================ */

.route-polyline {
    stroke-width: 4px;
    stroke-opacity: 0.8;
    fill: none;
}

.route-polyline.good {
    stroke: var(--color-route-good);
}

.route-polyline.moderate {
    stroke: var(--color-route-moderate);
}

.route-polyline.challenging {
    stroke: var(--color-route-challenging);
}

.route-polyline.difficult {
    stroke: var(--color-route-difficult);
}

/* ============================================
   LOADING OVERLAY FOR MAP
   ============================================ */

.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.95);
    padding: var(--space-6);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xl);
    text-align: center;
    z-index: 1000;
}

.map-loading__spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-bg-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto var(--space-3);
}

.map-loading__text {
    font-size: var(--text-base);
    color: var(--color-text-primary);
}

/* ============================================
   CLICK INDICATOR
   ============================================ */

.click-indicator {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-primary);
    border-radius: 50%;
    pointer-events: none;
    animation: pulse 0.5s ease-out;
    z-index: 1000;
}

@keyframes pulse {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* ============================================
   CROSSHAIR CURSOR
   ============================================ */

.map-container.selecting-point {
    cursor: crosshair;
}

.map-container.selecting-point #map {
    cursor: crosshair;
}

/* ============================================
   LOCATION DOT (GPS)
   ============================================ */

.location-dot {
    width: 18px;
    height: 18px;
    background-color: #4285F4;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(66, 133, 244, 0.6);
}
