:root {
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

calcite-shell {
    height: 100vh;
    width: 100%;
}

calcite-shell::part(content) {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.main-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

#mapviewDiv {
    flex: 1 1 auto;
    min-height: 300px;
    width: 100%;
    position: relative;
    padding-top: 0;
}

#navbarSearchContainer {
    width: 280px;
    max-width: 100%;
    min-width: 220px;
}

#navbarSearchContainer arcgis-search {
    width: 100%;
}

#navbarSearchContainer .esri-search {
    border-radius: 0px;
    padding: 0px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.calcite-navigation__content-end {
    gap: 0.5rem;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    max-width: 100%;
    min-width: 0;
    row-gap: 0.25rem;
    column-gap: 0.75rem;
}

.nav-links calcite-menu {
    width: 100%;
    flex-wrap: wrap;
    column-gap: 0.75rem;
}

.mobile-search-slot {
    display: none;
    padding: 0.25rem 1rem 0.5rem;
    background: #f8f9fa;
}

.mobile-search-slot arcgis-search {
    width: 100%;
}

.mobile-search-slot .esri-search {
    border-radius: 0px;
    padding: 0px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.mobile-nav-menu {
    display: none;
}

.mobile-nav-menu calcite-button {
    --calcite-color-text-1: #19405B;
    font-size: 1.5rem;
    --calcite-font-size-0: 1.5rem;
}

.mobile-nav-menu calcite-button::part(icon) {
    width: 32px;
    height: 32px;
}

calcite-navigation {
    --calcite-color-foreground-1: #f8f9fa;
    --calcite-internal-navigation-padding: 0;
    position: relative;
    z-index: 5;
}

calcite-navigation::part(content) {
    overflow: visible;
}

.calcite-navigation__content-start {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: visible;
}

calcite-dropdown.mobile-nav-menu {
    z-index: 10;
}

@media (max-width: 1200px) {
    html, body {
        height: 100%;
        overflow: hidden;
    }

    calcite-shell {
        height: 100dvh;
        overflow: hidden;
    }

    calcite-shell::part(content) {
        height: auto;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    calcite-navigation::part(content) {
        overflow: visible;
    }

    .main-content {
        min-height: 0;
        height: auto;
        flex: 1 1 auto;
        overflow: hidden;
    }

    #mapviewDiv {
        min-height: 0;
        height: auto;
        flex: 1 1 auto;
    }

    .desktop-search {
        display: none;
    }

    .mobile-search-slot {
        display: block;
    }

    .nav-links {
        display: none;
    }

    .mobile-nav-menu {
        display: flex;
    }

    .desktop-auth-action {
        display: none;
    }
}

calcite-menu {
    --calcite-color-foreground-1: #f8f9fa;
}

/* Splash Panel - Overlay Style */
.splash-overlay-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 700px;
    max-height: 65vh;
    z-index: 9999;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

.splash-overlay-panel::part(content-container) {
    overflow-y: hidden;
}

.splash-overlay-panel::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

.splash-overlay-panel[hidden] {
    display: none;
}

.splash-content {
    padding: 1.5rem;
    line-height: 1.6;
    font-size: 0.95rem;
    overflow: visible;
}

.splash-content h3:first-child {
    margin-top: 0;
}

.splash-content p {
    margin-bottom: 1rem;
}

.splash-content ul,
.splash-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.splash-content li {
    margin-bottom: 0.5rem;
}

.splash-overlay-panel::part(footer) {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--calcite-color-border-1);
}

@media (max-width: 900px) {
    calcite-shell-panel#coalMinesToolsPanel {
        --calcite-shell-panel-width: 280px;
    }
}

/* Mobile bottom sheet for tool panels */
#mobileBottomSheet {
    --calcite-sheet-scrim-background-color: transparent;
    --calcite-sheet-scrim-background: transparent;
    --calcite-scrim-background: transparent;
    z-index: 9;
    pointer-events: none;
}

#mobileBottomSheet::part(scrim) {
    background: transparent !important;
    pointer-events: none;
}

#mobileBottomSheet::part(content) {
    pointer-events: auto;
}

#mobileBottomSheet calcite-panel {
    height: 100%;
    pointer-events: auto;
}

#mobileBottomSheet .panel-content-wrap {
    padding: 0.75rem;
    overflow-y: auto;
}

/* Mobile bottom action bar */
.mobile-action-bar-host {
    display: none;
}

/* Prevent iOS automatic text size adjustment that causes zoom on focus */
html { -webkit-text-size-adjust: 100%; }

/* Ensure inputs are at least 16px on small screens so mobile browsers won't zoom on focus */
@media (max-width: 600px) {
    #navbarSearchContainer input,
    #mobileSearchHost input,
    .esri-search__input,
    input[type="search"],
    input[type="text"],
    textarea,
    select {
        font-size: 16px !important;
        line-height: 1.2;
    }
}

/* Left tools action bar */
calcite-shell-panel#coalMinesToolsPanel {
    --calcite-shell-panel-width: 550px;
    z-index: 8;
}

#coalMinesToolsPanel calcite-action-bar {
    border-right: 1px solid #d9dde3;
}

#coalMinesToolsPanel calcite-panel {
    position: absolute;
    inset: 0;
}

#coalMinesToolsPanel calcite-panel::part(content-container) {
    overflow: auto;
}

#coalMinesToolsPanel .panel-content-wrap {
    padding: 0.5rem;
}

.panel-content-wrap {
    padding: 1rem;
    overflow-y: auto;
    height: 100%;
}

/* Map components */
arcgis-search {
    width: 100%;
}

arcgis-layer-list,
arcgis-legend {
    width: 100%;
}

arcgis-area-measurement-2d,
arcgis-distance-measurement-2d {
    width: 100%;
}

arcgis-print {
    width: 100%;
}

/* Measure panel */
.measure-section {
    margin-bottom: 1.5rem;
}

.measure-section-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.measure-section-desc {
    font-size: 0.875rem;
    color: #6a6a6a;
    margin-bottom: 0.75rem;
}

.measure-divider {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 1.5rem 0;
}

/* Search panel sections */
.search-section-heading {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.search-section-desc {
    font-size: 0.875rem;
    color: #6a6a6a;
    margin-bottom: 0.75rem;
}

.search-divider {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 1.5rem 0;
}

#searchResultsList {
    display: none;
    margin-top: 0.5rem;
}

#searchResultsListContent calcite-list-item {
    cursor: pointer;
}

/* Mine name search results */
#namesResults {
    max-height: 320px;
    overflow: auto;
    margin-top: 0.5rem;
}

#namesResults calcite-list-item {
    cursor: pointer;
}

/* Dark mode support */
.calcite-mode-dark calcite-navigation {
    --calcite-color-foreground-1: #2b2b2b;
}

.calcite-mode-dark calcite-menu {
    --calcite-color-foreground-1: #2b2b2b;
}

.calcite-mode-dark .mobile-search-slot {
    background: #2b2b2b;
}

.calcite-mode-dark #navbarSearchContainer .esri-search,
.calcite-mode-dark .mobile-search-slot .esri-search {
    background: #333;
}

.calcite-mode-dark #coalMinesToolsPanel calcite-action-bar {
    border-right-color: #444;
}

.calcite-mode-dark .measure-section-desc {
    color: #b0b0b0;
}

.calcite-mode-dark .measure-divider {
    border-top-color: #404040;
}

.calcite-mode-dark .search-section-desc {
    color: #b0b0b0;
}

.calcite-mode-dark .search-divider {
    border-top-color: #404040;
}

/* Hide locate button in search */
#arcgisSearch .esri-search__locate-button {
    display: none !important;
}

/* Popup table styling */
.esri-popup__main-container {
    max-width: 400px;
}

.mine-popup table {
    width: 100%;
    font-size: 0.9rem;
    border-collapse: collapse;
}

.mine-popup td,
.mine-popup th {
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.mine-popup th {
    font-weight: 500;
    color: #4a4a4a;
    width: 45%;
}

.mine-popup tr:last-child td,
.mine-popup tr:last-child th {
    border-bottom: none;
}

.esri-popup__content a {
    color: #007ac2;
    text-decoration: none;
}

.esri-popup__content a:hover {
    text-decoration: underline;
}

/* Splash responsive sizing */
@media (max-width: 767px) {
    .splash-overlay-panel {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        max-width: 100%;
        top: 0;
        left: 0;
        transform: none;
    }

    .splash-overlay-panel::part(content-container) {
        max-height: calc(100vh - 120px);
        max-height: calc(100dvh - 120px);
    }

    .splash-content {
        padding: 1rem;
    }
}

@media (min-width: 768px) {
    .splash-overlay-panel {
        width: 70%;
    }
}

@media (min-width: 1024px) {
    .splash-overlay-panel {
        width: 60%;
        max-width: 650px;
    }
}

/* Dark mode splash */
.calcite-mode-dark .splash-overlay-panel::before {
    background: rgba(0, 0, 0, 0.75);
}

@media (max-width: 900px) {
    /* Reduce shell height to make room for the fixed bottom action bar */
    calcite-shell {
        height: calc(100dvh - 50px);
    }

    .mobile-action-bar-host {
        display: flex;
        justify-content: center;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 50px;
        z-index: 8;
        background: var(--calcite-color-foreground-1, #fff);
        border-top: 1px solid var(--calcite-color-border-3, #d4d4d4);
    }

    .mobile-action-bar-host calcite-action-bar {
        width: auto;
    }

    /* Hide the shell panel on mobile — action bar is at the bottom, panels open in sheet */
    calcite-shell-panel#coalMinesToolsPanel {
        display: none;
    }
}

.calcite-mode-dark .mobile-action-bar-host {
    background: var(--calcite-color-foreground-1, #2b2b2b);
    border-top-color: var(--calcite-color-border-3, #444);
}
