:root
{
    --color-bg: #f8f8f8;
    --color-bg-border: rgba(0,0,0,0.4);
    --color-highlight: #ffffff;
    --color-shape-panel: #fafdff;
    --color-settings-panel: #fafaff;
    --color-header: #313131;
}

*, *::before, *::after
{
    box-sizing: border-box;
}

body, html, div, input, button, h1, h2, h3, p
{
    font-family: "Inter", sans-serif;
}

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

#container
{
    position:relative;
    display:flex;
    height:100%;
    width:100%;
}

#map
{
    flex:1 1 auto;
    height:100%;
    transition: width 0.15s ease;
    min-width: 0;
    position: relative;
}

#sidebar
{
    width: 0%;
    background: var(--color-bg);
    height:100%;
    overflow:hidden;
    transition: width 0.15s ease;
    box-sizing:border-box;
    padding:0;
    display: flex;
    flex-direction: column;

    border-left: 1.2px solid var(--color-bg-border);
    position: relative; 
}

#sidebarButton
{
    position: absolute;
    top: 50%;
    right: 0%;
    z-index: 3000;
    background: var(--color-bg);

    border-right: 8px solid transparent;
    border-left: 1.2px solid var(--color-bg-border);
    border-top: 1.2px solid var(--color-bg-border);
    border-bottom: 1.2px solid var(--color-bg-border);

    padding: 8px 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: right 0.15s ease;
    transform: translate(8%, -50%);
    display:flex;
    align-items:center;
    justify-content:center;
    width:56px;
    height:196px;
    font-size:16px;
    line-height:1;

}



.sidebar-inner
{
    display: flex;
    flex-direction: column;

    flex: 1 1 auto;
    min-height: 0;

    overflow: hidden;

    padding: 0;
}

/* map search overlay */
#map-search {
    position: absolute;
    top: 188px;
    left: 10px;
    width: 260px;
    z-index: 3000;
}
/* input styling */
#searchBox {
    width: 100%;
    padding: 6px 10px;
    background: #f7f7f7;
    border: 2px solid #bebebe;
    border-radius: 4px;
    font-family: "Inter", Arial, sans-serif;
}

/* dropdown */
#searchResults {
    margin-top: 4px;
    overflow-y: auto;

    background: #f7f7f7;
    border: 2px solid #bebebe;
    border-radius: 4px;

    display: none;
}

.search-result-item {
    font-family: inherit;
    font-size: 14px;
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1.2px solid #eee;
    background: #f7f7f7;
    transition: background 0.2s ease;
}

.search-result-item:hover {
    background: #cdd6e9;
}

/* Zoom control container */
.leaflet-control-zoom a
{
    transition: background 0.2s, transform 0.2s;
    
}
.leaflet-control-zoom a:hover
{
    background-color: var(--color-highlight);
}

.leaflet-control {
    scale: 100%;
}

.shape-item
{
    margin-bottom: 8px;
    background: #ffffff;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: background-color 0.1s ease;
    border: 1.2px solid var(--color-bg-border);
}

.shape-header
{
    padding: 8px 10px;
    font-weight: 500;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.05);
    transition: background-color 0.1s ease;
}

.shape-color
{
    width: 13px;
    height: 13px;
    border-radius: 4px;
}

.shape-details
{
    position: relative;
    padding: 0 10px;
    font-size: 14px;
    overflow: hidden;

    max-height: 0px;
    opacity: 0;
    background: rgba(0, 0, 0, 0.00);

    transition:
        background-color 0.1s ease,
        max-height 0.1s ease,
        opacity 0.1s ease,
        padding 0.1s ease;
}

.shape-delete
{
    position: absolute;
    top: 12px;
    right: 10px;

    border: none;
    background: none;

    font-size: 28px;
    font-weight: 400;
    line-height: 1;

    cursor: pointer;

    opacity: 1;
    color: #000000;

    transition: opacity 0.12s ease, color 0.12s ease, scale 0.12s ease;
}

.shape-delete:hover
{
    background: #ebebeb;
}


.delete-confirm
{
    position: absolute;
    top: 13.5px;
    right: 48px;

    display: flex;
    align-items: center;
    gap: 6px;

    background: #fff;
    border-radius: 4px;
    padding: 4px 6px;

    font-size: 14px;
    color: var(--color-header);

    opacity: 0;
    pointer-events: none;

    transition: opacity 0.08s ease, transform 0.08s ease;
    white-space: nowrap;
}

.delete-confirm button
{
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    transition: opacity 0.1s ease, color 0.1s ease;
}

.delete-confirm .confirm-yes
{
    color: #b00000;
    opacity: 60%;
}

.delete-confirm .confirm-yes:hover
{
    opacity: 100%;
    transform: scale(1.1);
}


.delete-confirm.show
{
    opacity: 1;
    pointer-events: auto;
}
.shape-item.highlight
{
    background: color-mix(in srgb, var(--shape-color) 20%, white);
}

.shape-item.highlight .shape-details
{
    background: color-mix(in srgb, var(--shape-color) 12%, white);
}

.shape-item.open .shape-details
{
    padding: 8px 10px;

    max-height: 200px;
    opacity: 1;
}

.shape-title
{
    flex: 1;
}

.shape-arrow
{
    font-size: 16px;
    transition: transform 0.1s;
}

.shape-item.open .shape-arrow
{
    transform: rotate(180deg); /* ▼ → ▲ */
}

.leaflet-interactive
{
    transition: fill-opacity 0.1s ease;
}

.sidebar-header
{
    text-align: center;
    padding: 15px 15px 0px;
}

.sidebar-header p
{
    margin: 18px;
    font-size: 14px;
    color: var(--color-header);
}

.sidebar-tabs {
    display: flex;
    width: 100%;
    margin: 18px 0 0;   /* ← no negative margins, EVER */
}

.sidebar-tabs .tab {
    flex: 1;
    padding: 8px 0;

    border: 1.2px solid var(--color-bg-border);

    cursor: pointer;
    font-size: 16px;
    font-weight: 500;

    margin: 0;

    transition: background 0.05s ease, border-color 0.05s ease;
}

/* Shapes tab is always blue-ish */
.sidebar-tabs .tab[data-tab="shapes"] {
    background: var(--color-shape-panel);
    margin-left: -2px;
}

/* Settings tab is always green-ish, shares border with Shapes */
.sidebar-tabs .tab[data-tab="settings"] {
    background: var(--color-settings-panel);
    margin-left: -2px;  /* collapse the middle border */
    margin-right: -2px;
    
}

/* Subtle hover tweaks (totally optional) */
.sidebar-tabs .tab[data-tab="shapes"]:hover {
    background: #c8d3ec;
}
.sidebar-tabs .tab[data-tab="settings"]:hover {
    background: #c7eaf0;
}

/* Active tab: same colour, just visually joined to the panel */
.sidebar-tabs .tab.active {
    border-bottom-color: transparent;
    font-weight: 600;
}


.sidebar-panels {
    flex: 1 1 auto;
    padding: 12px 15px;
    min-height: 0;
    overflow-y: auto;
    
}

/* When "Shapes" is selected */
#sidebar.mode-shapes .sidebar-panels {
    background: var(--color-shape-panel);
}

/* When "Settings" is selected */
#sidebar.mode-settings .sidebar-panels {
    background: var(--color-settings-panel);
}

#sidebarButton.mode-shapes {
    background: var(--color-shape-panel);
}

#sidebarButton.mode-settings {
    background: var(--color-settings-panel);
}

.tab-panel
{
    display: none;
    flex: 1 1 auto;
    min-height: 0;
}

.tab-panel.active
{
    display: block;
}


.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-header);
}

.empty-state p {
    margin: 8px 0;
}

.empty-state button {
    margin-top: 14px;
    padding: 6px 14px;
    font-size: 14px;
    cursor: pointer;

    background: var(--color-bg);
    border: 1.2px solid var(--color-bg-border);
    border-radius: 4px;

    transition: background 0.1s ease;
}

.empty-state button:hover {
    background: var(--color-highlight);
}

#tab-settings.active {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 100%;  
}

/* Top action bar */
.settings-actions {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    flex-shrink: 0;
}

.settings-actions > * {
    flex: 1 1 0;
    display: flex;
    justify-content: center;
}

.settings-delete-all {
    position: relative;
}

.settings-delete-all .settings-btn {
    width: 100%;
    justify-content: center;
}

/* Main two-column area */
.settings-main {
    display: flex;
    gap: 18px;
    flex: 1 1 auto;
    min-height: 0;
}

.settings-left,
.settings-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.settings-section {
    padding: 10px 12px;
    border-radius: 4px;
    margin-bottom: 5px;
}

.settings-section h3 {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
}

.settings-btn {
    background: var(--color-bg);
    border: 1.2px solid var(--color-bg-border);
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;

    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.settings-btn:hover {
    background: var(--color-highlight);
}

.radio-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Vertical radio layout (e.g. Calculation Mode) */
.radio-group.vertical {
    flex-direction: column;
    gap: 6px;
}

/* Individual radio row */
.radio-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    font-size: 14px;
    cursor: pointer;

    padding: 2px 0;
}

.radio-option input {
    cursor: pointer;
}

/* Subtle hover for clarity */
.radio-option:hover {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 3px;
}

.unit-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.unit-options label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}

.settings-help {
    margin-top: 6px;
    font-size: 13px;
    color: var(--color-header);
    opacity: 0.85;
}


/* --- Map type preview layout --- */

.map-type-group {
    gap: 8px;
}

.map-type-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(40px, 280px);
    align-items: center;
    gap: 10px;

    padding: 6px;
    border-radius: 4px;
}

.map-type-option:hover {
    background: rgba(0, 0, 0, 0.03);
}

.map-type-label {
    font-size: 14px;
}

/* Preview box */
.map-preview {
    width: 100%;
    max-width: 280px;
    height: 92px;

    border-radius: 4px;
    border: 1.2px solid var(--color-bg-border);

    background-size: cover;
    background-position: center;
    margin-left: 20px;
}

/* CARTO Voyager preview */
.map-preview.vector1 {
    background-image: url("https://a.basemaps.cartocdn.com/rastertiles/voyager/5/17/11.png");
    background-size: cover;
    background-position: center;
}

/* OpenStreetMap preview */
.map-preview.vector2 {
    background-image: url("https://a.tile.openstreetmap.org/5/17/11.png");
    background-size: cover;
    background-position: center;
}

/* Satellite (ESRI World Imagery) */
.map-preview.satellite {
    background-image: url("https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/5/11/17");
    background-size: cover;
    background-position: center;
}

/* Terrain (ESRI Topographic) */
.map-preview.terrain {
    background-image: url("https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/5/11/17");
    background-size: cover;
    background-position: center;
}

/* Dark (CARTO Dark Matter) */
.map-preview.dark {
    background-image: url("https://a.basemaps.cartocdn.com/dark_all/5/17/11.png");
    background-size: cover;
    background-position: center;
}



/* Active state highlight */
.map-type-option input:checked + .map-type-label + .map-preview {
    outline: 2px solid var(--color-bg-border);

}


.settings-delete-all {
    display: flex;
    flex: 1 1 0;
}

.settings-action .delete-confirm {
    top: 36px;
}

.settings-action {
    flex: 1 1 0;
    display: flex;
    position: relative;
}

.settings-action .settings-btn {
    width: 100%;
}

.shape-item.open .shape-details {
    max-height: 500px;
}

.debug-grid {
    display: grid;
    grid-template-columns: 250px 1fr;
    row-gap: 5px;
    column-gap: 10px;
    white-space: nowrap;
    font-size: 14px;
    text-wrap: inherit;
}

.debug-grid b {
    font-weight: 500;
}

.simple-grid {
    display: grid;
    grid-template-columns: 100px 1fr;
    row-gap: 12px;
    column-gap: 10px;
    white-space: nowrap;
    font-size: 14px;
    text-wrap: inherit;
}

.simple-grid b {
    font-weight: 500;
}

.checkbox-row {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-top: 6px;
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}

.checkbox-option input {
    cursor: pointer;
}


/* --- Info Panel --- */

.info-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;
    border: 1.5px solid var(--color-bg-border);

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

    cursor: pointer;
    opacity: 0.8;
    margin-left: 4px;

    transition: background 0.15s ease, opacity 0.15s ease;
}

.info-panel {
    margin-top: 0px;
}

.info-panel-content {
    background: var(--color-bg);
    border: 1px solid var(--color-bg-border);
    border-radius: 4px;

    padding: 10px 12px;
    min-height: 230px;

    font-size: 14px;
    line-height: 1.6;
    opacity: 1;

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

    color: var(--color-header);
}

/* Placeholder style */
.info-panel-content .placeholder {
    opacity: 0.85;
    text-align: center;
    font-size: 14px;
}

/* Optional: smaller info icon inside placeholder */
.info-icon.small {
    font-size: 12px;
    width: 14px;
    height: 14px;
    line-height: 12px;
}

.info-icon:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.06);
}

/* Pinned state */
.info-icon.pinned {
    background: #cfd8ff;
    border-color: #6a78ff;
    opacity: 1;
}



/* Footer container */
.settings-footer {
    flex-shrink: 0;
    padding: 20px;
    padding-bottom: 40px;
    margin-top: auto;
    font-size: 14px;
    color: #000000;
    display: flex;
    flex-direction: column;
    gap: 14px;
    
}

/* Each subsection */
.footer-section h4 {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 600;
    opacity: 1;
    color: #202020;
}

.footer-section p {
    margin: 0;
    font-size: 14px;
    line-height: 1.35;
}

.footer-text {
    opacity: 1;
}

/* Bottom area (version + small links) */
.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding-top: 12px;
    margin-top: 12px;

    font-size: 14px;
    width: 100%;
}

.footer-links a {
    color: #000000;
    text-decoration: none;
    margin-left: 14px;
    opacity: 1;
    font-weight: 600;
}

.footer-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

.footer-version {
    opacity: 0.8;
}


.footer-privacy-text {
    margin: 0;
    opacity: 0.9;
}

.shape-pan {
    position: absolute;
    top: 48px;
    right: 9px;
    background: transparent;
    border: 1px transparent;
    border-radius: 4px;
    padding: 3px 6px;
    cursor: pointer;
    font-size: 20px;
}

.shape-pan:hover {
    background: #ebebeb;
}

.shape-details.loading {
    opacity: 0.7;
    display: flex;
    gap: 10px;
    align-items: center;
}

.loading-spinner {
    width: 14px;
    height: 14px;
    border: 3px solid #ccc;
    border-top-color: #666;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.debug-grid .debug-spacer {
    grid-column: 1 / -1;
    height: 0.4rem;
}

/* --- Onboarding Tooltip --- */

.onboarding-tooltip {
    position: absolute;
    z-index: 4000;
    pointer-events: auto;
}

.onboarding-tooltip.hidden {
    display: none;
}

.tooltip-content {
    background: #ffffff;
    border: 1.2px solid var(--color-bg-border);
    border-radius: 6px;
    padding: 10px 12px;
    width: 250px;
    height: 100px;

    font-size: 14px;
    line-height: 1.4;

    animation: slide-in-left 0.4s ease;
    position: relative;
}

.tooltip-content p {
    margin: 6px 0;
}

.tooltip-close {
    position: absolute;
    top: 4px;
    right: 6px;
    border: none;
    background: none;
    font-size: 32px;
    cursor: pointer;
    opacity: 0.6;
}

.tooltip-close:hover {
    opacity: 1;
}

.tooltip-arrow {
    position: absolute;
    left: -10px;
    top: 38px;

    width: 0;
    height: 0;

    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-right: 10px solid var(--color-bg-border);
}

.tooltip-arrow::after {
    content: "";
    position: absolute;
    left: 1px;
    top: -8px;

    width: 0;
    height: 0;

    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 9px solid #ffffff;
}

/* Gentle attention animation */
@keyframes slide-in-left {
    0% {
        transform: translateX(-12px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Optional: subtle bobbing to draw eye */
.onboarding-tooltip {
    animation: bob 2s ease-in-out infinite;
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}
