:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --bg-glass-dark: rgba(30, 41, 59, 0.85);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --shadow-premium: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body,
html {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

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

/* Force MapLibre GL canvas to stay below Leaflet overlay/marker panes */
.maplibregl-map,
.maplibregl-canvas-container,
.maplibregl-canvas {
    pointer-events: none !important;
}

/* UI Overlay */
.ui-overlay {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

#add-btn-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

.fab {
    width: 64px;
    height: 64px;
    border-radius: 32px;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: var(--shadow-premium);
    cursor: pointer;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.top-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    padding: 12px 16px;
    border-radius: 20px;
    box-shadow: var(--shadow-premium);
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.blue-cross {
    font-size: 24px;
    color: var(--primary);
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.fab:hover {
    transform: scale(1.05);
    background: var(--primary-hover);
}

.fab:active {
    transform: scale(0.95);
}

.auth-info {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-login-small {
    background: var(--primary);
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-login-small:hover {
    background: var(--primary-hover);
}

/* Pin Placement Mode */
.pin-placement-center {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -100%);
    /* Bottom of pin at center */
    z-index: 999;
    pointer-events: none;
    transition: var(--transition);
}

.pin-placement-center img {
    width: 32px;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

/* User Location Blue Dot */
.user-location-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.blue-dot {
    width: 14px;
    height: 14px;
    background: #3b82f6;
    border: 2px solid white;
    border-radius: 50%;
    position: relative;
    z-index: 2;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

.pulse {
    position: absolute;
    width: 300%;
    height: 300%;
    background: rgba(59, 130, 246, 0.4);
    border-radius: 50%;
    top: -100%;
    left: -100%;
    animation: pulse-animation 2s infinite ease-out;
    z-index: 1;
}

@keyframes pulse-animation {
    0% {
        transform: scale(0.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* Bearing Cone for Direction */
.bearing-cone {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    background: conic-gradient(from -30deg at 50% 50%, rgba(59, 130, 246, 0.4) 0deg, rgba(59, 130, 246, 0) 60deg);
    border-radius: 50%;
    z-index: 1;
    pointer-events: none;
    transform-origin: center;
}

/* Hide Zoom Controls on Mobile */
@media (max-width: 768px) {
    .leaflet-control-zoom {
        display: none !important;
    }
}

.hidden {
    display: none !important;
}

/* Info Card / Bottom Sheet */
.info-card {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    padding: 24px;
    z-index: 1001;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

.btn-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 16px;
    background: #f1f5f9;
    color: var(--text-muted);
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.btn-close:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.card-handle {
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    margin: -12px auto 16px auto;
}

#card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

#card-note {
    font-size: 15px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 16px;
}

.meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 20px;
}

.actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    /* Space out items: stars left, button right */
    margin-left: -8px;
    /* Alignment fix: move stars left to match title text */
    margin-right: -8px;
    /* Alignment fix: move button right to match 'X' button */
}

/* Aggregated Rating Display */
.rating-display {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: -6px;
    margin-bottom: 12px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 400;
}

.stars-outer {
    position: relative;
    display: inline-block;
    color: #cbd5e1;
    /* Empty stars color */
    font-size: 16px;
    letter-spacing: 2px;
}

.stars-inner {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
    width: 0;
    color: var(--text-muted);
}

.stars-outer::before {
    content: "★★★★★";
}

.stars-inner::before {
    content: "★★★★★";
}

/* Star Rating Input */
.star-rating {
    display: flex;
    gap: 4px;
    width: 240px;
    justify-content: space-around;
    background: white;
    padding: 4px 8px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    transition: var(--transition);
    height: 56px;
    align-items: center;
    flex-shrink: 0;
    /* Prevent the rating area from squishing */
}

.star {
    font-size: 26px;
    color: #cbd5e1;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.star:hover,
.star.active {
    color: #f59e0b;
}

.star-rating.disabled {
    opacity: 0.6;
    pointer-events: none;
    background: #f8fafc;
}

.btn-action {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: white;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-action:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-action.delete {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    background: white;
    border: 2px solid #ef4444;
    /* Permanent red outline */
    border-radius: 12px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: var(--transition);
}

.btn-action.delete img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.btn-action.delete svg {
    pointer-events: none;
}



/* Leaflet Overrides */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-premium) !important;
    margin-right: 20px !important;
    margin-bottom: 120px !important;
}

.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    background: var(--bg-glass) !important;
    backdrop-filter: blur(8px);
    color: var(--text-main) !important;
    border: none !important;
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
}

.leaflet-bar a:first-child {
    border-radius: 12px 12px 0 0 !important;
}

.leaflet-bar a:last-child {
    border-radius: 0 0 12px 12px !important;
}

/* Loading Indicator */
.loading-indicator {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-premium);
    pointer-events: auto;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-content h3 {
    margin-bottom: 20px;
    color: var(--text-main);
}

textarea {
    width: 100%;
    height: 120px;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
    resize: none;
    font-size: 16px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.btn-primary {
    flex: 1;
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary {
    flex: 1;
    background: #f1f5f9;
    color: var(--text-muted);
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
}

/* Mobile Optimizations */
@media (max-width: 640px) {
    .fab {
        width: 56px;
        height: 56px;
    }

    .ui-overlay {
        bottom: 30px;
    }
}