/* ============================================
   FloodWatch WebGIS — Sidebar Styles
   ============================================ */

/* ---------- Sidebar Container ---------- */
.sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 800;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-base), width var(--transition-base);
    overflow: hidden;
}
.sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

.sidebar-toggle {
    position: absolute;
    top: 12px;
    right: -16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 10;
    transition: all var(--transition-fast);
    font-size: 11px;
}
.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--primary-light);
    border-color: var(--primary);
}
.sidebar.collapsed .sidebar-toggle {
    right: -48px;
}
.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* ---------- Sidebar Content ---------- */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

/* ---------- Sections ---------- */
.sidebar-section {
    margin-bottom: 2px;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
}
.section-header:hover {
    background: var(--bg-hover);
}
.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.section-title i {
    width: 18px;
    text-align: center;
    color: var(--primary);
    font-size: 14px;
}
.section-arrow {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}
.section-header.collapsed .section-arrow {
    transform: rotate(-90deg);
}
.section-body {
    padding: 0 16px 12px;
    overflow: hidden;
    transition: max-height var(--transition-base), opacity var(--transition-fast);
    max-height: 800px;
    opacity: 1;
}
.section-body.hidden {
    max-height: 0;
    opacity: 0;
    padding: 0 16px;
}

/* ---------- Layer Groups ---------- */
.layer-group {
    margin-bottom: 14px;
}
.layer-group:last-child {
    margin-bottom: 0;
}
.layer-group-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    padding-left: 2px;
}

/* ---------- Layer Items ---------- */
.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    margin-bottom: 2px;
}
.layer-item:hover {
    background: var(--bg-hover);
}
.layer-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.layer-color {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}
.layer-name {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ---------- Toggle Switch ---------- */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-input);
    border-radius: 9px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    left: 2px;
    bottom: 2px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition-fast);
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
    border-color: var(--primary);
}
.toggle-switch input:checked + .toggle-slider::before {
    background: #fff;
    transform: translateX(16px);
}

/* ---------- Filters ---------- */
.filter-group {
    margin-bottom: 16px;
}
.filter-group:last-of-type {
    margin-bottom: 12px;
}
.filter-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.filter-select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    cursor: pointer;
    transition: border-color var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}
.filter-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* Range Inputs */
.range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}
.range-input {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    text-align: center;
    width: 100%;
}
.range-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}
.range-sep {
    color: var(--text-muted);
    font-size: 14px;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 0;
}
.filter-checkbox input {
    display: none;
}
.check-mark {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-strong);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.filter-checkbox input:checked ~ .check-mark {
    background: currentColor;
    border-color: currentColor;
}
.filter-checkbox input:checked ~ .check-mark::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 9px;
    color: #fff;
}
.check-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Date Inputs */
.date-inputs {
    display: flex;
    gap: 8px;
}
.date-input {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 11px;
}
.date-input:focus {
    outline: none;
    border-color: var(--primary);
}
.date-input::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
}

/* Filter Actions */
.filter-actions {
    display: flex;
    gap: 8px;
}
.btn {
    flex: 1;
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all var(--transition-fast);
}
.btn:active {
    transform: scale(0.96);
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-dark);
}
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ---------- Legend ---------- */
.legend-group {
    margin-bottom: 14px;
}
.legend-group:last-child {
    margin-bottom: 0;
}
.legend-group-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 3px 0;
    font-size: 12px;
    color: var(--text-secondary);
}
.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}
.legend-circle {
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid var(--primary);
    background: rgba(33, 150, 243, 0.2);
}
.legend-circle.sm { width: 10px; height: 10px; }
.legend-circle.md { width: 14px; height: 14px; }
.legend-circle.lg { width: 18px; height: 18px; }
.legend-circle.xl { width: 22px; height: 22px; }

/* Gradient Legend */
.legend-gradient {
    margin-top: 4px;
}
.gradient-bar {
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(90deg, #64B5F6, #1565C0, #0D47A1, #E91E63);
}
.gradient-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-muted);
}

/* ---------- Sidebar Footer ---------- */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}
.attribution {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.6;
}
.attribution p {
    margin-bottom: 2px;
}
