/* ═══════════════════════════════════════════════════════════════
   Sidebar — Icon Rail + Flyout Panel + Right Panel Layout
   Ported from validated _playground/sidebar prototype
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   Right Panel — Unified container (analysis + flyout + rail)
   ───────────────────────────────────────────────────────────── */

.right-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: row;
    z-index: 10;
    background: #fff;
    border-left: 1px solid #e0e0e0;
}

/* Analysis content area — override absolute positioning from analysis-panel.css
   when the panel lives inside the right-panel flex container.
   analysisPanel/ui.js sets className='ap' directly on #analysis-panel,
   so we target by ID within the flex parent. */
.right-panel > #analysis-panel {
    position: relative;
    top: auto;
    bottom: auto;
    right: auto;
    left: auto;
    border: none;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* When analysis panel is hidden (no pins), collapse to zero width */
.right-panel > #analysis-panel.ap--hidden {
    width: 0 !important;  /* override inline style from ui.js */
    overflow: hidden;
}

/* ─────────────────────────────────────────────────────────────
   Icon Rail — Right column of the unified panel

   STYLE IS WORK IN PROGRESS
   ───────────────────────────────────────────────────────────── */

.sidebar-rail {
    width: 56px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px 0;
    background: linear-gradient(135deg, #4B4F47 0%, #3D5C6B 100%);
    border-left: 1px solid #e8eaed;
}

.rail-top, .rail-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.rail-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 48px;
    padding: 8px 0 4px 0;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: #5f6368;
    transition: all 0.15s;
    gap: 2px;
}

.rail-btn:hover {
    background: #f1f3f4;
    color: #1a73e8;
}

.rail-btn:hover svg {
    stroke: #445A5F;
}

.rail-btn:hover .rail-label {
    background: linear-gradient(135deg, #4B4F47 0%, #3D5C6B 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.rail-btn.active {
    background: #e8f0fe;
    color: #1a73e8;
}

.rail-btn.active svg {
    stroke: #445A5F;
}

.rail-btn.active .rail-label {
    background: linear-gradient(135deg, #4B4F47 0%, #3D5C6B 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.rail-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: whitesmoke;
}

.rail-label {
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.1px;
    line-height: 1;
    white-space: nowrap;
    color: whitesmoke;
}

/* ─────────────────────────────────────────────────────────────
   Flyout Panel — Flex child between analysis & rail.
   Expands from 0 to 300px, pushing analysis left over the map.
   ───────────────────────────────────────────────────────────── */

.sidebar-flyout {
    width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    transition: width 0.25s ease;
    flex-shrink: 0;
}

body.flyout-open .sidebar-flyout {
    width: 300px;
    border-left: 1px solid #e8eaed;
}

/* Flyout Header */
.flyout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0px 0px 10px;
    border-bottom: 1px solid #e8eaed;
    min-height: 52px;
    min-width: auto;
}

.flyout-title {
    font-size: 16px;
    font-weight: 600;
    color: #202124;
}

.flyout-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    color: #5f6368;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.flyout-close:hover {
    background: #f1f3f4;
}

/* Flyout Body */
.flyout-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    min-width: 300px;
}

.flyout-body::-webkit-scrollbar { width: 4px; }
.flyout-body::-webkit-scrollbar-track { background: transparent; }
.flyout-body::-webkit-scrollbar-thumb { background: #dadce0; border-radius: 2px; }
.flyout-body::-webkit-scrollbar-thumb:hover { background: #bdc1c6; }

/* ─────────────────────────────────────────────────────────────
   Tool Content — Shared styles for all tool panels
   ───────────────────────────────────────────────────────────── */

.tool-section {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f4;
}

.tool-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #80868b;
    margin-bottom: 8px;
}

.tool-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    color: #3c4043;
}

.tool-row-label { color: #5f6368; }
.tool-row-value { font-weight: 500; color: #202124; }

.tool-empty {
    padding: 24px 16px;
    text-align: center;
    color: #80868b;
    font-size: 13px;
}

.tool-empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
}

/* ─────────────────────────────────────────────────────────────
   Search Tool
   ───────────────────────────────────────────────────────────── */

.sb-input-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
}

.sb-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #dadce0;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

.sb-input:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26,115,232,0.15);
}

.sb-input:disabled { background: #f5f5f5; color: #999; }

.sb-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: #1a73e8;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.sb-btn:hover { background: #1557b0; }
.sb-btn:disabled { background: #dadce0; cursor: not-allowed; }

.sb-status {
    padding: 4px 16px 8px;
    font-size: 12px;
    min-height: 20px;
}

.sb-status.loading { color: #1a73e8; }
.sb-status.error { color: #c5221f; }
.sb-status.success { color: #137333; }

.sb-result {
    padding: 6px 16px 12px;
    font-size: 12px;
    color: #5f6368;
    background: #f8f9fa;
    border-bottom: 1px solid #f1f3f4;
}

/* ─────────────────────────────────────────────────────────────
   Filters Tool
   ───────────────────────────────────────────────────────────── */

.ft-controls {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    border-bottom: 1px solid #f1f3f4;
}

.ft-ctrl-btn {
    padding: 5px 10px;
    border: 1px solid #dadce0;
    border-radius: 16px;
    background: #fff;
    font-size: 11px;
    font-weight: 500;
    color: #5f6368;
    cursor: pointer;
    transition: all 0.15s;
}

.ft-ctrl-btn:hover { background: #f1f3f4; border-color: #bdc1c6; }

.ft-list {
    padding: 4px 0;
}

.ft-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.12s;
    font-size: 13px;
    color: #3c4043;
}

.ft-item:hover { background: #f8f9fa; }

.ft-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #1a73e8;
    cursor: pointer;
    flex-shrink: 0;
}

.ft-item-label { flex: 1; }

.ft-item-count {
    font-size: 11px;
    color: #999;
    font-variant-numeric: tabular-nums;
    min-width: 20px;
    text-align: right;
}

.ft-summary {
    padding: 8px 16px;
    font-size: 12px;
    color: #5f6368;
    background: #f8f9fa;
    border-bottom: 1px solid #f1f3f4;
}

.ft-empty {
    padding: 24px 16px;
    text-align: center;
    color: #80868b;
    font-size: 13px;
    font-style: italic;
}

/* ─────────────────────────────────────────────────────────────
   Analysis Tool
   ───────────────────────────────────────────────────────────── */

.at-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f4;
}

.at-toggle-label {
    font-size: 13px;
    color: #3c4043;
    font-weight: 500;
}

/* Toggle Switch (shared) */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #dadce0;
    border-radius: 10px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background: #1a73e8;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

/* ─────────────────────────────────────────────────────────────
   Settings Tool
   ───────────────────────────────────────────────────────────── */

.st-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f8f9fa;
}

.st-item-info { flex: 1; }

.st-item-label {
    font-size: 13px;
    color: #3c4043;
    font-weight: 500;
}

.st-item-desc {
    font-size: 11px;
    color: #80868b;
    margin-top: 1px;
}

.st-select {
    padding: 5px 8px;
    border: 1px solid #dadce0;
    border-radius: 6px;
    font-size: 12px;
    background: #fff;
    outline: none;
}
