/* =========================
   1. Base & Layout Styles
   ========================= */
html, body {
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
}

#container {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#viewDiv {
    flex: 1;
    height: 100%;
    z-index: 1;
}

#viewDiv:focus {
    outline: none;
    border: none;
}

/* =========================
   2. Sidebar & Tab
   ========================= */
.sidebar {
    height: 100%;
    flex-shrink: 0;
    transition: flex-basis 0.3s;
    flex-basis: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    outline: 1px #e5e5e5 solid;
}

#sideContent {
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar.collapsed {
    flex-basis: 0;
}

.sidebar.collapsed #sideContent {
    display: none;
}

.actionIcon {
    --calcite-ui-icon-color: #2f2f2f;
}

.calcite-mode-dark .actionIcon {
    --calcite-ui-icon-color: rgb(255, 255, 255);
}

#actionBar {
    width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 0;
    background-color: var(--calcite-ui-foreground);
}

.custom-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    width: 60px;
    height: 52px;
    gap: 6px;
    transition: background-color 0.2s ease;
}

.custom-action:hover {
    background-color: var(--calcite-ui-foreground-hover, #eaeaea);
}

.calcite-mode-dark .custom-action:hover {
    background-color: var(--calcite-ui-foreground-hover, #424242);
}

.custom-label {
    font-size: 0.7em;
    text-align: center;
    line-height: 1;
}

.tab,
#legendTab.tab {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #615c5c;
    padding: 16px 4px;
    z-index: 2;
    margin-right: 0;
    cursor: pointer;
    transition: background 0.2s, transform 0.4s cubic-bezier(.4, 1.5, .5, 1);
    will-change: transform;
}

/* Sidebar tab (default) */
.tab {
    top: 30px;
    right: 0;
    transform: translate(100%, -50%);
    border-radius: 0 4px 4px 0;
    border-right: 1px #e5e5e5 solid;
    border-bottom: 1px #e5e5e5 solid;
    border-top: 1px #e5e5e5 solid;
}

.tab[aria-expanded="false"] calcite-icon {
    transform: rotate(180deg);
    transition: transform 0.3s ease;
}

/* Legend tab overrides */
#legendTab.tab {
    top: 78px;
    right: 425px;
    border-radius: 4px 0 0 4px;
    border-left: 1px #e5e5e5 solid;
    border-bottom: 1px #e5e5e5 solid;
    border-top: 1px #e5e5e5 solid;
    border-right: 0px;
    z-index: 3;
}

/* Legend tab collapsed position */
#legendTab[aria-expanded="false"] {
    right: 24px;
}

#legendTab.tab[aria-expanded="false"] calcite-icon {
    transform: rotate(0deg);
}

/* Disabled state */
#legendTab[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
    right: 24px;
}

#legendPanel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    max-width: 400px;
    width: fit-content;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    z-index: 2;
    transition: transform 0.4s cubic-bezier(.4, 1.5, .5, 1);
    will-change: transform;
}

/* Slide out to the right */
#legendPanel.slide-out {
    transform: translateX(110%);
}

/* Slide in (default) */
#legendPanel.slide-in {
    transform: translateX(0);
}

#legendContent {
    line-height: 15px;
    text-align: justify;
}

#legendContent.zoom-active {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.legend-entry {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
}

.legend-label {
    font-size: clamp(9px, 1.2vw, 12px);
    font-weight: 700;
    margin-top: 4px;
}

.legend-swatch {
    border: 1px solid black;
    color: black;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 26px;
    overflow: hidden;
    position: relative;
    font-weight: 700;
    flex-shrink: 0;
    width: fit-content;
}

.legend-swatch span {
    display: inline-block;
    white-space: nowrap;
    transform-origin: center center;
    font-size: 11px;
}

.legend-description {
    font-weight: 300;
    font-size: 12px;
    line-height: 14px;
}

.hide-descriptions .legend-description {
    display: none;
}

.dmuHeader {
    font-size: 13px;
    text-transform: uppercase;
    text-decoration: underline;
}

.zoomCallout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    padding: 1.5em;
    text-align: center;
    font-size: 12px;
    color: #444;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: auto;
}

/* =========================
   3. Dark/Light Mode
   ========================= */
.calcite-mode-dark .tab,
.calcite-mode-dark #legendTab.tab,
.calcite-mode-dark .splashStep,
.calcite-mode-dark #viewInfo,
.calcite-mode-dark .helpBar {
    background: #2b2b2b;
    color: #ffffff;
    border-color: #c7c7c7;
}

.calcite-mode-dark .splashStep {
    outline: 1px #7389ab solid;
}

.calcite-mode-dark .infoBar,
.calcite-mode-dark .filterIcon {
    color: #ffffff;
}

.calcite-mode-dark .shareIcon,
.calcite-mode-dark .infoIcon {
    fill: #ffffff !important;
    color: #dbdbdb !important;
}

.calcite-mode-dark .infoSection.active,
.calcite-mode-dark .helpSection.active {
    border-left: 3px #ffeb00 solid;
}

.calcite-mode-dark .infoSection.active .infoHeader,
.calcite-mode-dark .helpSection.active .infoHeader {
    background-color: #9b9a685c;
}

.calcite-mode-light {
    --calcite-color-text-1: #000000;
    --calcite-color-text-2: #000000;
}

.calcite-mode-dark {
    --calcite-color-text-1: #ffffff;
    --calcite-color-text-2: #ffffff;
}

/* =========================
   4. Info/Help Sections
   ========================= */
.infoHeader {
    font-size: 13px;
    padding: 2px;
    margin-bottom: 2px;
    border-radius: 4px;
    margin-left: -5px;
    margin-right: -5px;
    background: #9f9e9e4a;
    display: block;
    height: 24px;
    line-height: 24px;
    align-content: center;
}

.infoHeader:not(:first-child) {
    margin-top: 6px;
}

.infoIcon {
    cursor: pointer;
    margin-left: 2px;
    color: #9b9898;
    vertical-align: middle;
    position: relative;
    margin-top: -3px;
}

.infoSection.active,
.helpSection.active {
    opacity: 1;
    pointer-events: auto;
    border-left: 3px #8c75a3 solid;
    padding-left: 0px;
    margin-left: -10px;
}

.infoSection.active .infoHeader,
.helpSection.active .infoHeader {
    background: #baaac95c;
    margin-left: 0px;
    border-radius: 0px;
}

.infoSection.active .unitInfo,
.infoSection.active .unitDesc,
.helpSection.active .unitInfo,
.helpSection.active .unitDesc {
    margin-left: 4px;
}

.stroked {
    text-shadow:
        -1px -1px 0 #ffffffb9,
        0 -1px 0 #ffffffb9,
        1px -1px 0 #ffffffb9,
        1px 0 0 #ffffffb9,
        1px 1px 0 #ffffffb9,
        0 1px 0 #ffffffb9,
        -1px 1px 0 #ffffffb9,
        -1px 0 0 #ffffffb9;
}

.infoSection:not(.active) .stroked {
    display: none !important;
}

/* =========================
   5. Calcite/ArcGIS Components
   ========================= */
.calcite-shell-panel {
    position: relative;
}

calcite-tooltip {
    pointer-events: none;
}

calcite-action-bar,
calcite-shell-panel,
calcite-link,
calcite-action,
calcite-button,
calcite-panel {
    outline: none !important;
    --calcite-ui-focus-color: none !important;
}

.action-bg {
    --calcite-action-background-color: transparent;
    background-image: url('../images/logo.png');
    background-size: 44px;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
}

/* =========================
   6. Toolbar & Button Groups
   ========================= */
.toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    background: white;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2);
}

.button-group {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 10px;
    max-width: 375px;
    margin-left: auto;
    margin-right: auto;
}

.button-group calcite-button {
    background-color: #007ac2;
    transition: background-color 0.3s ease;
    height: 28px;
}

:root[calcite-mode="light"] {
    --calcite-button-background-color: black;
    --calcite-button-text-color: white;
}

.custom-chip {
    --calcite-chip-background-color: #FF5733;
}

button {
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
}

.button-padding.content--slotted {
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    font-weight: 400;
}

#themeToggleButton {
    z-index: 1001;
}

/* =========================
   7. Basemap Controls
   ========================= */
#basemapControls {
    position: absolute;
    bottom: 10px;
    left: 10px;
    z-index: 10;
}

#basemapControls calcite-button {
    cursor: pointer;
}

#basemapControls calcite-button.active {
    background-color: #007ac2;
    color: white;
}

#basemapControls calcite-button.inactive {
    background-color: white;
    color: black;
}

/* =========================
   8. Radio Buttons & Inputs
   ========================= */
.radio-button-group,
.infoBar {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-left: -4px;
}

calcite-radio-button {
    margin-right: -6px;
    margin-top: -2px;
    --calcite-ui-focus-color: none !important;
}

calcite-radio-button-group {
    font-weight: 500;
    text-transform: uppercase;
}

calcite-label {
    margin-right: -6px;
}

#keywordInput {
    font-size: 13px;
    max-width: 372px;
    display: none;
    margin: auto;
    padding-bottom: 2px;

}

.keyword {
    --calcite-input-actions-background-color: pink;
    --calcite-input-actions-background-color-hover: rgb(252, 159, 165);
    --calcite-input-actions-icon-color: rgb(95, 4, 4);
    --calcite-input-actions-icon-color-press: crimson;
}

#keywordChips {
    display: none;
    padding-bottom: 3px;
    text-align: center;
    --calcite-chip-text-color: black;
    --calcite-chip-corner-radius: 0px;
    --calcite-chip-background-color: #e7cf17;
    font-weight: 700;
    font-size: 11px;
}

#keywordChips .active {
    --calcite-chip-text-color: white;
    --calcite-chip-background-color: #007ac2;
}

#filterHelp {
    text-align: center;
    --calcite-chip-corner-radius: 2px;
    --calcite-chip-background-color: #f5eff5;
}

#filterHelp:hover {
    --calcite-chip-background-color: #c5b7c5;
}

.calcite-mode-dark #filterHelp {
    --calcite-chip-background-color: #312f1f;
}

.calcite-mode-dark #filterHelp:hover {
    --calcite-chip-background-color: #24221c;
    ;
}

calcite-chip {
    padding-left: 2px;
    padding-right: 2px;
    cursor: pointer;
    pointer-events: auto;
    padding-top: 2px;
    max-width: 385px;
}

calcite-chip:hover {
    --calcite-chip-background-color: #cab725;
}

/* =========================
   9. Info/Help/ID Bars
   ========================= */
.splashStep {
    font-size: 16px;
    font-weight: 700;
    background: #c3d1dd;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    text-align: center;
    vertical-align: middle;
}

.infoBar {
    font-size: 11px;
    max-height: 36px;
    margin-top: -4px;
    color: #000000;
    text-align: center;
    padding: 4px;
    font-weight: 700;
}

#clearInfo {
    padding: 3px;
    color: #9b9898;
    cursor: pointer;
}

.locMarker {
    fill: #007AC2;
    width: 16px;
    height: 16px;
    margin-bottom: 2px;
}

.idBar,
.helpBar {
    display: flex;
    flex-direction: column;
    padding: 10px;
    line-height: 20px;
    font-size: 12px;
    padding-top: 0px;
}

.helpBar {
    max-width: 375px;
    margin-right: auto;
    margin-left: auto;
    background: #ffffff;
    border-radius: 8px;
    padding: 11px;
}

.helpGifs {
    max-width: 100%;
    width: 100%;
    height: auto;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    justify-content: center;
    border-radius: 3px;
    box-shadow: 2px 2px 5px #8b8b8bcc;
}

/* =========================
   10. Dialogs & Loaders
   ========================= */
#ngs-dialog,
#help-dialog {
    --calcite-dialog-size-y: calc(100% - 40px);
    --calcite-dialog-footer-space: 40px;
    --calcite-ui-focus-color: none !important;
}

#share-dialog,
#settings-dialog {
    --calcite-ui-focus-color: none !important;
}

calcite-button:focus,
calcite-input:focus {
    outline: none !important;
}

#loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#loader:not([active]) {
    display: none;
}

/* =========================
   11. Map/Widget Info & Scale
   ========================= */
#viewInfo {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ffffffa3;
    z-index: 10;
    font-weight: 700;
    font-size: 12px;
    border-radius: 4px;
    text-align: center;
    min-width: 200px;
}

#viewInfo .coords {
    display: block;
    font-size: 10px;
    line-height: 14px;
}

.scale {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
}

.esri-scale-bar__bar-container {
    font-size: 10px;
}

.esri-scale-bar__line {
    background-color: transparent;
}

.esri-component.esri-scale-bar.esri-widget,
.esri-scale-bar.esri-widget {
    background-color: #ffffffc2;
    padding: 7px;
    border-radius: 4px;
}

.calcite-mode-dark .esri-component.esri-scale-bar.esri-widget,
.esri-scale-bar.esri-widget {
    background-color: #000000d1;
}

.scale,
.calcite-mode-dark .scale {
    background: none;
}

/* =========================
   12. ArcGIS/Calcite UI Tweaks
   ========================= */
.esri-ui-top-left {
    left: 15px;
}

.esri-ui .esri-attribution {
    display: none;
}

.esri-view .esri-view-surface--inset-outline:focus::after,
button:focus,
calcite-action,
.button:focus {
    outline: none !important;
}

calcite-button:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
    --calcite-ui-focus-color: transparent;
}

calcite-button {
    --calcite-ui-focus-color: transparent;
    --calcite-color-focus: transparent;
}

.esri-view .esri-view-surface--touch-none:focus::after {
    outline: none !important;
}

.esri-search__input,
.esri-view-width-less-than-small .esri-search__input {
    font-size: 12px;
    font-weight: 700;
    font-family: 'Avenir Next';
}

body.legend-expanded .esri-search, body.legend-expanded .esri-scale-bar {
    margin-right: 400px !important;
}

body.legend-expanded #viewInfo {
    left: calc(50% - 200px);
}

/* =========================
   13. Miscellaneous
   ========================= */

calcite-slider {
    padding-right: 4px;
    padding-left: 4px;
}

/* =========================
   14. Responsive/Media Queries
   ========================= */
@media (max-width: 870px) {
    #viewInfo {
        display: none;
    }

    #legendPanel, #toggleLegendAction, #legendTab {
        display: none !important;
    }
}

@media (max-width: 600px) {
    #container {
        flex-direction: column-reverse;
    }

    .sidebar {
        width: 100%;
        height: 50vh;
        flex-basis: 50vh;
        flex-shrink: 0;
        position: relative;
    }

    .sidebar.collapsed {
        flex-basis: 0;
        height: 0;
    }

    #intro {
        text-align: center;
    }

    #viewInfo,
    #actionBar,
    #basemapControls,
    .introText {
        display: none;
    }

    .esri-ui-top-left {
        top: 0px;
    }

    .tab {
        position: absolute !important;
        top: -37px !important;
        right: 8px !important;
        left: auto !important;
        transform: rotate(270deg);
        border-radius: 0px;
        z-index: 10;
        margin: 0;
    }
}