/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    background-color: #f8fafc;
}

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

/* Custom Marker Styles */
.custom-div-icon {
    background: transparent !important;
    border: none !important;
}

/* Swimmer Letter Markers */
.letter-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #ffffff;
    font-weight: 700;
    font-size: 16px;
    border: 3px solid #ffffff;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    position: relative;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
}

/* Pointer arrow under the letter marker */
.letter-marker::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 5px 0;
    border-style: solid;
    border-color: var(--marker-color) transparent transparent transparent;
    display: block;
    width: 0;
}

/* Landmark (Start/Finish) Markers */
.landmark-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #ffffff;
    font-weight: 700;
    font-size: 14px;
    border: 2px solid #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    position: relative;
    user-select: none;
}

.landmark-marker::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px 4px 0;
    border-style: solid;
    border-color: var(--marker-color) transparent transparent transparent;
    display: block;
    width: 0;
}

/* Hover effect for all custom markers */
.letter-marker:hover, .landmark-marker:hover {
    transform: scale(1.15);
    z-index: 1000 !important;
}

/* Map Overlay Controls */
.map-control-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; /* Let clicks pass through except on children */
}

.map-btn {
    pointer-events: auto; /* Re-enable pointer events for buttons */
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(15, 23, 42, 0.08);
    color: #0f172a;
    padding: 10px 16px;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    transition: all 0.2s ease;
}

.map-btn:hover {
    background: rgba(241, 245, 249, 0.95);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px -2px rgba(15, 23, 42, 0.08), 0 3px 7px -3px rgba(15, 23, 42, 0.08);
    border-color: rgba(15, 23, 42, 0.15);
}

.map-btn:active {
    transform: translateY(1px);
}

.map-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Authentication Modal Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(241, 245, 249, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.4s ease;
}

.auth-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Glassmorphic Modal Card */
.auth-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.12);
    border-radius: 24px;
    width: 90%;
    max-width: 420px;
    padding: 32px;
    color: #0f172a;
    text-align: center;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-overlay.fade-out .auth-card {
    transform: scale(0.9);
}

.auth-logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #3b82f6 0%, #0d9488 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 16px -4px rgba(59, 130, 246, 0.5);
}

.auth-logo svg {
    width: 28px;
    height: 28px;
    fill: #ffffff;
}

.auth-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #0f172a, #334155);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-description {
    font-size: 14px;
    color: #475569;
    margin-bottom: 24px;
    line-height: 1.5;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.input-label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-field {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 12px;
    padding: 12px 16px;
    color: #0f172a;
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
}

.input-field:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
    background: #ffffff;
}

.auth-error {
    color: #f87171;
    font-size: 13px;
    margin-top: 8px;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.auth-error.visible {
    opacity: 1;
}

.btn-submit {
    background: linear-gradient(135deg, #2563eb 0%, #0284c7 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-family: inherit;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-submit:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #0369a1 100%);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.btn-submit:active {
    transform: translateY(1px);
}

/* Customizing Leaflet Popup styling to match modern UI */
.leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #0f172a !important;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px !important;
    box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.1) !important;
}

.leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.leaflet-popup-content {
    font-family: 'Outfit', sans-serif !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
    margin: 12px 16px !important;
}

.leaflet-container a.leaflet-popup-close-button {
    color: #64748b !important;
    padding: 6px 8px 0 0 !important;
}

.leaflet-container a.leaflet-popup-close-button:hover {
    color: #0f172a !important;
}

/* Swimmer distance connection lines & labels */
.custom-distance-label-icon {
    background: transparent !important;
    border: none !important;
}

.swimmer-marker-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    width: 160px;
    height: 64px;
}

.distance-bubble {
    font-family: 'Outfit', sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: var(--swimmer-color);
    background: #ffffff;
    border: 1px solid var(--swimmer-color);
    padding: 2px 8px;
    border-radius: 8px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
    pointer-events: none;
    margin-bottom: 6px;
}

.refresh-status {
    position: absolute;
    bottom: 12px;
    left: 80px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(15, 23, 42, 0.08);
    color: #475569;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
    pointer-events: none;
    display: none;
}

/* User location marker styling */
.user-location-marker {
    width: 14px;
    height: 14px;
    background-color: #3b82f6;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.8);
    position: relative;
}

.user-location-marker::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: rgba(59, 130, 246, 0.4);
    animation: user-pulse 1.8s infinite ease-in-out;
    z-index: -1;
}

@keyframes user-pulse {
    0% {
        transform: scale(0.6);
        opacity: 1;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}
