/* ===== FEATURE TABLE DOCK =====
   Bottom-docked, tabbed attribute table. Positioned against the viewport, the
   same convention #layer-switcher uses (.content-container has no `position`,
   so absolute resolves to the initial containing block).
   z-index 1002: above #layer-switcher (1000) and .floating-control (1001),
   below the modal/backdrop layer (9998+). */

#feature-dock {
    position: absolute;
    left: 370px; /* sidebar 70 + layer switcher 300 */
    right: 0;
    bottom: 0;
    z-index: 1002;
    height: 300px;
    background: #fff;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Work Sans', sans-serif;
    transition: left 0.2s ease;
}

/* Layer switcher hidden -> dock extends to the sidebar edge */
#feature-dock.switcher-hidden {
    left: 70px;
}

#feature-dock.collapsed {
    height: 40px !important;
}

/* ----- Resize handle ----- */
.fd-resize {
    height: 6px;
    flex-shrink: 0;
    cursor: ns-resize;
    background: #f0f0f0;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fd-resize:hover,
.fd-resize.resizing {
    background: #B5D6F4;
}

.fd-resize-grip {
    width: 36px;
    height: 3px;
    border-radius: 2px;
    background: #bbb;
}

.fd-resize:hover .fd-resize-grip {
    background: #0E69B5;
}

/* Prevents text selection while dragging the resize handle */
body.fd-resizing {
    user-select: none;
    cursor: ns-resize;
}

/* ----- Tab strip ----- */
.fd-tabs {
    display: flex;
    align-items: stretch;
    background: #F0F0F0;
    border-bottom: 1px solid #ccc;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.fd-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    border: none;
    background: transparent;
    color: #818181;
    cursor: pointer;
    font-family: 'Work Sans', sans-serif;
    font-size: 13px;
    font-weight: 500;
    border-top: 3px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
}

.fd-tab i {
    font-size: 12px;
}

.fd-tab.active {
    background: #fff;
    color: #333;
    border-top-color: #0E69B5;
}

.fd-tab-count {
    background: #e0e0e0;
    color: #666;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 600;
}

.fd-tab.active .fd-tab-count {
    background: #B5D6F4;
    color: #0E69B5;
}

.fd-tab-close {
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 11px;
    padding: 2px 3px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
}

.fd-tab-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.08);
}

.fd-tabs-spacer {
    flex: 1;
    min-width: 12px;
}

.fd-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 8px;
    flex-shrink: 0;
}

.fd-icon-btn {
    background: transparent;
    border: none;
    color: #818181;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fd-icon-btn:hover {
    background: #e0e0e0;
    color: #333;
}

/* ----- Filter chips ----- */
.fd-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 14px;
    background: #f8f8f8;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.fd-filters-icon {
    color: #818181;
    font-size: 12px;
    margin-right: 2px;
}

.fd-filters-empty {
    font-size: 12px;
    color: #999;
}

.fd-chip-wrap {
    position: relative;
}

.fd-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 4px 10px;
    background: #E4F0FA;
    border: 1px solid #B5D6F4;
    border-radius: 14px;
    font-size: 12px;
    color: #0E69B5;
    cursor: pointer;
}

.fd-chip:hover {
    background: #d6e8f7;
}

.fd-chip.editing {
    background: #0E69B5;
    color: #fff;
    border-color: #0E69B5;
}

.fd-chip-remove {
    border: none;
    background: rgba(14, 105, 181, 0.12);
    color: inherit;
    cursor: pointer;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

.fd-chip.editing .fd-chip-remove {
    background: rgba(255, 255, 255, 0.25);
}

.fd-chip-add {
    border: 1px dashed #B5D6F4;
    background: transparent;
    color: #0E69B5;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 14px;
    font-weight: 600;
    font-family: 'Work Sans', sans-serif;
}

.fd-chip-add:hover {
    background: #E4F0FA;
}

/* Disabled once every attribute carries a condition, or at the shared cap. The
   :hover rule above would otherwise still light the button up. */
.fd-chip-add:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.fd-chip-add:disabled:hover {
    background: transparent;
}

.fd-filters-clear {
    margin-left: 4px;
    border: none;
    background: transparent;
    color: #999;
    cursor: pointer;
    font-size: 12px;
    text-decoration: underline;
    font-family: 'Work Sans', sans-serif;
}

.fd-filters-clear:hover {
    color: #666;
}

/* ----- Inline chip editor ----- */
.fd-chip-editor {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 40;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 320px;
}

.fd-chip-editor-row {
    display: flex;
    gap: 5px;
}

.fd-chip-editor select {
    font-size: 12px;
    padding: 5px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #333;
    min-width: 0;
    font-family: 'Work Sans', sans-serif;
}

.fd-chip-editor .fd-editor-field {
    flex: 2;
}

.fd-chip-editor .fd-editor-operator {
    flex: 1;
    min-width: 60px;
}

.fd-chip-editor .fd-editor-value {
    flex: 2;
    min-width: 0;
    display: flex;
}

/* Multi-value checkbox dropdown inside the chip editor — match the 12px selects */
.fd-chip-editor .filter-value-trigger {
    font-size: 12px;
    padding: 5px 6px;
    border-radius: 4px;
    font-family: 'Work Sans', sans-serif;
}

.fd-chip-editor .filter-value-panel {
    z-index: 50;
}

.fd-chip-editor .filter-value-option {
    font-size: 12px;
    font-family: 'Work Sans', sans-serif;
}

/* Typeahead layout inside the chip editor — match the 12px selects. font-family
   needs no override: .filter-value-input inherits and #feature-dock sets Work Sans. */
.fd-chip-editor .filter-value-box {
    font-size: 12px;
    padding: 3px 4px;
    border-radius: 4px;
}

.fd-chip-editor .filter-value-input {
    font-size: 12px;
}

.fd-chip-editor .filter-value-chip {
    font-size: 11px;
}

/* Also covers the pre-existing "no values" line, which was stuck at 11px here. */
.fd-chip-editor .filter-value-empty {
    font-size: 12px;
}

.fd-chip-editor-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.fd-editor-apply,
.fd-editor-delete {
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
    cursor: pointer;
    background: #fff;
    color: #333;
    font-family: 'Work Sans', sans-serif;
}

.fd-editor-apply {
    background: #0E69B5;
    color: #fff;
    border-color: #0E69B5;
}

.fd-editor-delete {
    color: #c0392b;
}

/* ----- Toolbar (count + export) ----- */
.fd-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    padding: 6px 14px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.fd-count {
    font-size: 12px;
    color: #666;
}

.fd-export {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #ccc;
    background: #fff;
    color: #333;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Work Sans', sans-serif;
}

.fd-export:hover {
    background: #f0f0f0;
}

.fd-export:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ----- Selection bar (left side of the toolbar) ----- */
.fd-selection {
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #0E69B5;
}

.fd-selection strong {
    font-weight: 600;
}

.fd-selection-btn {
    border: none;
    background: transparent;
    color: #0E69B5;
    cursor: pointer;
    font-size: 12px;
    text-decoration: underline;
    padding: 0;
    font-family: 'Work Sans', sans-serif;
}

.fd-selection-btn:hover {
    color: #0d5c9e;
}

/* ----- Per-layer highlight colour ----- */
.fd-highlight {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #818181;
    cursor: pointer;
}

.fd-highlight-input {
    width: 26px;
    height: 20px;
    padding: 0;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: none;
    cursor: pointer;
}

/* Browsers wrap the swatch in padded chrome; strip it so the control reads as
   a plain colour chip rather than a button. */
.fd-highlight-input::-webkit-color-swatch-wrapper { padding: 0; }
.fd-highlight-input::-webkit-color-swatch { border: none; border-radius: 2px; }
.fd-highlight-input::-moz-color-swatch { border: none; border-radius: 2px; }

.fd-highlight-input:focus-visible {
    outline: 2px solid #0E69B5;
    outline-offset: 1px;
}

/* ----- Spatial export menu ----- */
.fd-export-wrap {
    position: relative;
    display: inline-flex;
}

/* Fixed, not absolute: #feature-dock is overflow:hidden, so an absolutely
   positioned menu gets clipped by the dock's top edge (and by its bottom edge
   if opened downward on a short dock). Coordinates are set by positionExportMenu(). */
.fd-export-menu {
    position: fixed;
    top: -9999px;
    left: -9999px;
    z-index: 1100;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    padding: 4px;
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.fd-export-menu-item {
    border: none;
    background: transparent;
    color: #333;
    cursor: pointer;
    font-size: 13px;
    font-family: 'Work Sans', sans-serif;
    text-align: left;
    padding: 8px 12px;
    border-radius: 4px;
    white-space: nowrap;
}

.fd-export-menu-item:hover {
    background: #E4F0FA;
    color: #0E69B5;
}

/* ----- Table ----- */
.fd-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    position: relative;
    display: flex;
    flex-direction: column;
}

.fd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.fd-table thead th {
    position: sticky;
    top: 0;
    background: #f2f2f2;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid #ddd;
    color: #555;
    font-weight: 600;
    white-space: nowrap;
    z-index: 2;
}

/* Two pinned leading columns: checkbox (left 0) then zoom (left 34px). */
.fd-table th.fd-col-check,
.fd-table td.fd-col-check {
    position: sticky;
    left: 0;
    width: 34px;
    padding: 4px 6px;
    text-align: center;
}

.fd-table th.fd-col-zoom,
.fd-table td.fd-col-zoom {
    position: sticky;
    left: 34px;
    width: 34px;
    padding: 4px 6px;
}

.fd-table thead th.fd-col-check,
.fd-table thead th.fd-col-zoom {
    background: #f2f2f2;
    z-index: 3;
}

.fd-table tbody td.fd-col-check,
.fd-table tbody td.fd-col-zoom {
    background: #fff;
    z-index: 1;
}

.fd-table tbody tr:nth-child(even) td.fd-col-check,
.fd-table tbody tr:nth-child(even) td.fd-col-zoom {
    background: #fafafa;
}

.fd-table td.fd-col-check input[type="checkbox"],
.fd-table th.fd-col-check input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.fd-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #eee;
    color: #333;
    white-space: nowrap;
}

.fd-table tbody tr {
    cursor: pointer;
}

.fd-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.fd-table tbody tr:hover {
    background: #f7f9fb;
}

.fd-table tbody tr.selected {
    background: #B5D6F4;
}

.fd-table tbody tr.selected:hover {
    background: #a8cdf0;
}

.fd-table tbody tr.selected td.fd-col-check {
    background: #B5D6F4;
    box-shadow: inset 3px 0 0 #0E69B5;
}

.fd-table tbody tr.selected td.fd-col-zoom {
    background: #B5D6F4;
}

.fd-zoom-btn {
    border: none;
    background: transparent;
    color: #818181;
    cursor: pointer;
    width: 22px;
    height: 22px;
    border-radius: 4px;
}

.fd-zoom-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #0E69B5;
}

.fd-table tbody tr.selected .fd-zoom-btn {
    color: #0E69B5;
}

/* ----- Pager ----- */
.fd-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 7px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    font-size: 12px;
    color: #555;
}

.fd-pager-btn {
    border: none;
    background: transparent;
    color: #0E69B5;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    font-size: 12px;
}

.fd-pager-btn:hover:not(:disabled) {
    background: #E4F0FA;
}

.fd-pager-btn:disabled {
    color: #ccc;
    cursor: not-allowed;
}

/* ----- State messages ----- */
.fd-message {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #888;
    font-size: 13px;
    padding: 20px;
    text-align: center;
}

.fd-message i {
    font-size: 26px;
    opacity: 0.4;
}

.fd-message button {
    border: 1px solid #0E69B5;
    background: #fff;
    color: #0E69B5;
    cursor: pointer;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Work Sans', sans-serif;
}

.fd-message button:hover {
    background: #E4F0FA;
}

/* ----- Loading skeleton ----- */
.fd-skel-bar {
    height: 12px;
    border-radius: 3px;
    background: linear-gradient(90deg, #eee 25%, #f6f6f6 37%, #eee 63%);
    background-size: 400% 100%;
    animation: fd-skel 1.3s ease infinite;
}

@keyframes fd-skel {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
    .fd-skel-bar { animation: none; }
    #feature-dock { transition: none; }
}

/* ----- Layer-row table button (lives in the layer switcher) ----- */
.table-layer-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    min-width: 28px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    border-radius: 3px;
    flex-shrink: 0;
    color: #818181;
}

.table-layer-btn.active {
    color: #0E69B5;
}

/* Focus visibility, matching the app's existing convention */
#feature-dock button:focus-visible,
#feature-dock select:focus-visible,
#feature-dock tr:focus-visible,
.table-layer-btn:focus-visible {
    outline: 2px solid #0E69B5;
    outline-offset: 1px;
}

.fd-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
