/* =============================================================================
   Table drawer styles — slides up from the bottom of #mapContainer when an
   analysis result has detail-mode features. mapRenderer.js mounts an Esri
   FeatureTable widget inside #mapTableContainer.

   Layout: the drawer lives INSIDE #mapContainer (not as a sibling) so that
   when the user fullscreens the map element, the drawer is carried along
   with it. The drawer absolute-positions at the bottom of #mapContainer
   via z-index over the Esri map surface.

     #mapContainer (position: relative — positioning context)
       .esri-view-root        — Esri's map surface, fills the container
       #mapTableDrawer        — absolute, bottom: 0, left: 0, right: 0
         .panel-table-drawer-handle  (top edge drag handle)
         .panel-table-drawer-header
         #mapTableContainer (Esri FeatureTable mounts here)

   When #mapTableDrawer is [hidden], it's display:none. When visible, it
   claims a fixed initial height anchored to the bottom of the map, and
   the Esri map handles the partial occlusion naturally — controls
   reflow above it, the map stays interactive in the visible area.
============================================================================= */

/* Make #mapContainer a positioning context so the absolute-positioned drawer
   anchors to it. Without position:relative on the parent, the drawer would
   anchor to the nearest positioned ancestor — usually the side panel — and
   ignore fullscreen entirely. */
#mapContainer {
    position: relative;
}

.panel-table-drawer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    /* Sit above the Esri map surface and its controls. Esri's zoom widget
       z-index is around 1; bumping the drawer to 10 keeps it firmly on top
       without interfering with overlay popups (which use much higher z). */
    z-index: 10;

    /* Initial drawer height. The drag handle on the top edge lets users
       resize between ~120px (just header) and the full map height. */
    height: 280px;
    min-height: 120px;
    max-height: 80%;

    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--panel-border, #e1e5eb);
    background: var(--panel-bg, #fafbfc);
    overflow: hidden;
    /* Shadow above the drawer to lift it visually off the map. */
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

.panel-table-drawer[hidden] {
    display: none !important;
}

.panel-table-drawer-handle {
    flex: 0 0 6px;
    cursor: ns-resize;
    background: transparent;
    border-bottom: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.panel-table-drawer-handle:hover,
.panel-table-drawer-handle.dragging {
    background: var(--accent-hover, #d0e3f7);
    border-bottom-color: var(--accent, #4da6ff);
}

.panel-table-drawer-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-bottom: 1px solid var(--panel-border, #e1e5eb);
    background: var(--panel-header-bg, #f4f6f9);
    font-size: 13px;
    user-select: none;
}

.panel-table-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    position: relative;
    background: var(--panel-bg, #fff);
}

/* Make Esri's FeatureTable widget fill the host fully. The widget mounts
   inside .panel-table-widget-host (a fresh div created per turn — see
   mountFeatureTable in mapRenderer.js for why a new node is needed each
   time), which itself fills #mapTableContainer 100%. Without this the
   widget defaults to its intrinsic ~400px height and renders clipped. */
.panel-table-container .panel-table-widget-host,
.panel-table-widget-host .esri-feature-table,
.panel-table-container .esri-feature-table {
    height: 100% !important;
    width: 100% !important;
}

/* Dark-mode support — pick up the existing app's dark-mode root vars
   if defined, otherwise fall back to manual dark colors. */
body.dark-mode .panel-table-drawer {
    background: var(--panel-bg-dark, #1f2429);
    border-top-color: var(--panel-border-dark, #2d343a);
}

body.dark-mode .panel-table-drawer-header {
    background: var(--panel-header-bg-dark, #262b31);
    border-bottom-color: var(--panel-border-dark, #2d343a);
}

body.dark-mode .panel-table-container {
    background: var(--panel-bg-dark, #1f2429);
}
