html,
body {
    height: 100%;
    margin: 0;
}


#filterPanel h3 {
    margin-top: 0;
}

#filterPanel label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
}

#filterPanel select,
#filterPanel input[type="range"] {
    width: 100%;
    margin-top: 4px;
}

.noUi-connect {
    background: lightblue !important;
    /* or: #add8e6 */
}

/* ===== FEATURE INFO ===== */

#featurePanel h3 {
    margin-top: 0;
}

#featurePanel table {
    width: 100%;
    border-collapse: collapse;
}

#featurePanel th {
    text-align: left;
    width: 40%;
}

#featurePanel td {
    width: 60%;
}

/* ===== CHART ===== */

#chartsContainer {
    margin-top: 10px;
}

#chartImage {
    width: 100%;
}

/* ===== BUTTON ===== */

button {
    margin-top: 8px;
    padding: 6px 10px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
}

button:hover {
    background: #0056b3;
}

.popup{
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;   /* ensures it sits above Leaflet */
}

.popupContent{
  background: white;
  padding: 20px;
  width: 420px;
  max-height: 80vh;
  overflow-y: auto;  /* allows scrolling if form grows */
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

#userEntriesTable th, 
#userEntriesTable td {
    border: 1px solid #ddd;
    padding: 4px;
    font-size: 12px;
}

#filterPanel,
#featurePanel {
    box-shadow: 0 0 8px rgba(0,0,0,0.05);
    z-index: 500;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    color: #333;
}

h3 {
    margin-bottom: 10px;
}

label {
    margin-bottom: 14px;
}

.section {
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.section h4 {
    margin-bottom: 6px;
    font-size: 13px;
    color: #666;
}

select, input, textarea {
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 6px;
    font-size: 13px;
    background: #fff;
}

select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: #007bff;
}



.card {
    background: #fafafa;
    border-radius: 8px;
    padding: 10px;
    border: 1px solid #eee;
}

#userEntriesTable th {
    background: #f0f0f0;
    font-weight: 600;
}

#userEntriesTable td {
    font-size: 12px;
}

#userEntriesTable tr:hover {
    background-color: #f5faff;
}

.popup {
  animation: fadeIn 0.2s ease;
}

.popupContent {
  animation: scaleIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0 }
  to { opacity: 1 }
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0 }
  to { transform: scale(1); opacity: 1 }
}

#chartsContainer {
    background: #fafafa;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #eee;
}


.form-row {
  margin-bottom: 10px;
}

.form-row label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-row input,
.form-row select,
.form-row textarea {
  flex: 1;
}

/* Map legend */

.map-legend {
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 14px;
    border-radius: 8px;

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);

    font-family: Arial, sans-serif;
    font-size: 12px;
    color: #333;

    min-width: 170px;
}

.legend-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 7px;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-line {
    display: inline-block;
    width: 26px;
    height: 4px;
    flex-shrink: 0;
    border-radius: 2px;
}

.legend-blue {
    background: #0000ff;
}

.legend-red {
    background: #ff0000;
}

.legend-grey {
    background: #808080;
}

/* Selected spot symbol */

.legend-selected {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 30px;
    height: 30px;

    border: 1.5px solid darkgreen;
    border-radius: 50%;

    background: rgba(0, 100, 0, 0.12);

    flex-shrink: 0;
}

.legend-selected .legend-line {
    width: 18px;
    height: 3px;
}


/* Drag handle is only used on mobile */
#detailsHandle {
    display: none;
}

@media (max-width: 900px) {

    #filterPanel .panelHeader,
    #featurePanel .panelHeader {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }

    #closeFiltersBtn,
    #closeDetailsBtn {
        display: flex;
        align-items: center;
        justify-content: center;

        flex-shrink: 0;

        width: 44px;
        height: 44px;

        background: #eeeeee;
        color: #222222;

        border: 1px solid #cccccc;
        border-radius: 50%;

        font-size: 24px;
        cursor: pointer;

        position: relative;
        z-index: 10;
    }
}


/* ======================================
   MOBILE DRAGGABLE DETAILS SHEET
   ====================================== */


@media (max-width: 900px) {

    #featurePanel {
        --sheet-compact-height: 180px;

        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;

        width: 100%;
        height: min(85dvh, 750px);
        max-height: none;

        box-sizing: border-box;
        z-index: 1000;

        background: white;
        border-radius: 18px 18px 0 0;

        overflow-y: auto;
        overscroll-behavior: contain;

        /* Hidden by default */
        transform: translateY(100%);
        visibility: hidden;

        transition:
            transform 0.3s ease,
            visibility 0.3s ease;
    }

    /* Compact preview */

    #featurePanel.open {
        transform: translateY(
            calc(100% - var(--sheet-compact-height))
        );
        visibility: visible;
    }

    /* Expanded sheet */

    #featurePanel.open.expanded {
        transform: translateY(0);
    }

    /* Drag handle */

    #detailsHandle {
        display: flex;
        align-items: center;
        justify-content: center;

        width: 100%;
        height: 32px;
        min-height: 32px;

        padding: 0;
        margin: 0;

        border: none;
        background: white;

        cursor: grab;
        touch-action: none;

        position: sticky;
        top: 0;
        z-index: 5;
    }

    #detailsHandle:active {
        cursor: grabbing;
    }

    .handleBar {
        display: block;

        width: 42px;
        height: 5px;

        border-radius: 10px;
        background: #a0a0a0;
    }

    /* Keep heading visible */

    #featurePanel .panelHeader {
        position: sticky;
        top: 32px;
        z-index: 4;

        background: white;
        margin-bottom: 12px;
    }

    /* Disable animation while dragging */

    #featurePanel.dragging {
        transition: none;
    }

    /* Accessibility */

    @media (prefers-reduced-motion: reduce) {
        #featurePanel {
            transition: none;
        }
    }
}


/* ======================================
   NEW TOP BAR + OVERLAY MENUS
   ====================================== */

:root {
    --topbar-height: 56px;
}


/* Main application layout */

#mainLayout {
    position: relative;
    display: block;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}


/* ======================================
   TOP BAR
   ====================================== */

#topBar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;

    height: var(--topbar-height);
    box-sizing: border-box;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 16px;

    background: white;
    border-bottom: 1px solid #ddd;

    z-index: 1300;
}


#topBar .topBarBtn {
    margin: 0;

    padding: 9px 14px;

    background: transparent;
    color: #222;

    border: none;
    border-radius: 6px;

    font-size: 15px;
    font-weight: 600;

    cursor: pointer;
}


#topBar .topBarBtn:hover {
    background: #f2f2f2;
}


/* ======================================
   MAP
   ====================================== */

#map {
    position: absolute;

    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;

    width: 100%;
    height: auto;

    z-index: 1;
}


/* ======================================
   FILTER MENU
   ====================================== */

#filterPanel {
    position: absolute;

    top: var(--topbar-height);
    left: 0;

    width: min(360px, 90vw);
    height: calc(100% - var(--topbar-height));

    box-sizing: border-box;

    padding: 16px;

    background: white;
    border-right: 1px solid #ddd;

    overflow-y: auto;
    overscroll-behavior: contain;

    z-index: 1200;

    transform: translateX(-100%);
    visibility: hidden;

    transition:
        transform 0.25s ease,
        visibility 0.25s ease;
}


#filterPanel.open {
    transform: translateX(0);
    visibility: visible;
}


/* ======================================
   LOGIN / ACCOUNT MENU
   ====================================== */

#authPanel {
    position: absolute;

    top: var(--topbar-height);
    right: 0;

    width: min(360px, 90vw);
    max-height: calc(100% - var(--topbar-height));

    box-sizing: border-box;

    padding: 16px;

    background: white;
    border-left: 1px solid #ddd;

    overflow-y: auto;
    overscroll-behavior: contain;

    z-index: 1200;

    transform: translateX(100%);
    visibility: hidden;

    transition:
        transform 0.25s ease,
        visibility 0.25s ease;
}


#authPanel.open {
    transform: translateX(0);
    visibility: visible;
}


/* Authentication controls */

#authPanel input {
    box-sizing: border-box;
    width: 100%;
    margin-top: 5px;
    margin-bottom: 8px;
}


/* ======================================
   FEATURE / DETAILS PANEL
   ====================================== */

/*
   Desktop details panel remains on the right.
*/

#featurePanel {
    position: absolute;

    top: var(--topbar-height);
    right: 0;
    bottom: 0;

    width: 360px;
    height: auto;

    box-sizing: border-box;
    padding: 16px;

    background: white;
    border-left: 1px solid #e5e5e5;

    overflow-y: auto;

    z-index: 1000;
}


/* ======================================
   MOBILE
   ====================================== */


@media (max-width: 900px) {

    #topBar {
        padding-left: 12px;
        padding-right: 12px;
    }

    .siteIntro {
        min-width: 0;
        flex: 1;
    }

    .siteIntro h3 {
        margin: 0;
        font-size: 16px;
        line-height: 1.2;
    }

    .topBarActions {
        display: flex;
        flex-direction: row;
        align-items: center;
        flex-shrink: 0;
        gap: 2px;
        margin-left: 8px;
    }

    #topBar .topBarBtn {
        padding: 8px 7px;
        font-size: 14px;
        white-space: nowrap;
    }


    #filterPanel,
    #authPanel {
        width: min(90vw, 360px);
    }


    /*
       Keep the existing mobile details sheet.
       Override the desktop positioning above.
    */

    #featurePanel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;

        width: 100%;
        height: min(85dvh, 750px);
    }


    /*
       The legend no longer needs the old
       mobile filter-button offset.
    */

    .leaflet-top.leaflet-left {
        top: 0;
    }
}

/* ======================================
   DESKTOP DETAILS PANEL
   Show only after selecting a spot
   ====================================== */

@media (min-width: 901px) {

    #featurePanel {
        transform: translateX(100%);
        visibility: hidden;

        transition:
            transform 0.25s ease,
            visibility 0.25s ease;
    }

    #featurePanel.open {
        transform: translateX(0);
        visibility: visible;
    }
}

.filterHint {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f5f5f5;
    border-radius: 6px;
    color: #555;
    font-size: 13px;
    line-height: 1.4;
}

.spot-count-control {
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
}