/* ================================
   CONTROLS - FILTER & TOGGLE CONTROLS
   ================================
   Unified filter interface, toggle controls,
   info tooltips, and filter panels
   ================================ */

@import url("color_palette.css");

/* ===========================
   Tab Bar - Standardized for all tabs
   HIERARCHY: Primary tabs (panel-level) > Secondary tabs (sub-sections)
=========================== */

/* PRIMARY TABS - Top-level panel tabs (e.g., Feature Search OSM/Overture) */
.tab-bar {
  display: flex;
  border-bottom: 2px solid #e1e4e8;
  background: linear-gradient(to bottom, #ffffff, #f8f9fa);
  padding: 0;
  margin: 0;
  flex-shrink: 0;
}

.tab-button {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  font-size: var(--font-size-md);
  font-weight: 500;
  color: #586069;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  text-align: center;
}

.tab-button:hover:not(.active) {
  background-color: rgba(204, 102, 0, 0.05);
  color: var(--color-accent-orange);
}

.tab-button.active {
  color: var(--color-accent-orange);
  background-color: transparent;
  font-weight: 600;
}

.tab-button.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-accent-orange);
}

/* SECONDARY TABS - Network container tabs (Graph/Timeline) */
.tab-headers,
ul.tab-headers {
  list-style: none !important;
  display: flex !important;
  margin: 0 !important;
  padding: 0 !important;
  border-bottom: 2px solid #d1d5db !important;
  background: #f3f4f6 !important;
  flex-shrink: 0;
}

.tab-headers li {
  padding: 8px 16px !important;
  cursor: pointer !important;
  border-bottom: 2px solid transparent !important;
  font-size: var(--font-size-md) !important;
  font-weight: 500 !important;
  color: #6b7280 !important;
  transition: all 0.2s ease !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  white-space: nowrap !important;
  background: transparent !important;
}

.tab-headers li:hover:not(.active) {
  background-color: rgba(204, 102, 0, 0.05) !important;
  color: var(--color-accent-orange) !important;
}

.tab-headers li.active {
  color: var(--color-accent-orange) !important;
  border-bottom: 2px solid var(--color-accent-orange) !important;
  font-weight: 600 !important;
}

/* TERTIARY TABS - Network main tabs (Network 1, Network 2, etc.) */
#network-main-tabs {
  list-style: none !important;
  display: flex !important;
  margin: 0 !important;
  padding: 0 !important;
  border-bottom: 2px solid #e5e7eb !important;
  background: #f9fafb !important;
  overflow-x: auto !important;
  flex-shrink: 0;
}

#network-main-tabs li {
  padding: 10px 16px !important;
  cursor: pointer !important;
  border-bottom: 3px solid transparent !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  white-space: nowrap !important;
  transition: all 0.2s !important;
  font-size: var(--font-size-md) !important;
  font-weight: 500 !important;
  color: #6b7280 !important;
  background: transparent !important;
}

#network-main-tabs li:hover:not(.active) {
  background-color: rgba(204, 102, 0, 0.05) !important;
  color: var(--color-accent-orange) !important;
}

#network-main-tabs li.active {
  color: var(--color-accent-orange) !important;
  border-bottom: 3px solid var(--color-accent-orange) !important;
  font-weight: 600 !important;
  background: rgba(204, 102, 0, 0.03) !important;
}

/* Tab content container */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .tab-button {
    padding: 6px 10px;
    font-size: var(--font-size-md);
  }
}

/* ===========================
   Dynamic Data Source Tabs
=========================== */
.data-source-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px;
  background: #f0f0f0;
  border-bottom: 2px solid #ddd;
  min-height: 40px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
}

.data-source-tab {
  position: relative;
  padding: 8px 30px 8px 12px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  font-size: var(--font-size-md);
  color: #333;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.data-source-tab:hover {
  background: #f8f8f8;
  border-color: #999;
}

.data-source-tab.active {
  background: var(--color-accent-orange);
  color: white;
  border-color: var(--color-accent-orange);
  font-weight: 500;
}

.data-source-tab .tab-close {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  line-height: 18px;
  text-align: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
  cursor: pointer;
  font-size: var(--font-size-2xl);
  transition: background 0.2s;
}

.data-source-tab .tab-close:hover {
  background: rgba(255, 0, 0, 0.3);
}

.data-source-tab.active .tab-close {
  background: rgba(255, 255, 255, 0.3);
}

/* ===========================
   Unified Filter Interface
=========================== */
.data-layer-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.data-layer-card {
  flex: 1;
  min-width: 140px;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #f9f9f9;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.data-layer-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.data-layer-card.active {
  background: var(--color-accent-orange);
  color: white;
  border-color: var(--color-accent-orange-light);
}

.data-layer-card input[type="checkbox"] {
  position: absolute;
  top: 10px;
  right: 10px;
  transform: scale(1.2);
  cursor: pointer;
}

.data-layer-card .layer-icon {
  font-size: var(--font-size-2xl);
  margin-bottom: 8px;
  display: block;
  text-align: center;
}

.data-layer-card .layer-name {
  font-weight: 600;
  text-align: center;
  display: block;
}

.data-layer-card .filter-config-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.1);
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: var(--font-size-md);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.data-layer-card:hover .filter-config-btn {
  opacity: 1;
}

.data-layer-card.active .filter-config-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* ===========================
   Slide-out Filter Panel
=========================== */
.layer-filters-panel {
  position: fixed;
  right: -400px;
  top: 0;
  width: clamp(300px, 30vw, 500px);
  height: 100vh;
  background: white;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  transition: right 0.3s ease;
  z-index: 1050;
  overflow-y: auto;
}

.layer-filters-panel.open {
  right: 0;
}

.layer-filters-panel-header {
  background: linear-gradient(to bottom, #1a1f2e, #2a3142);
  color: white;
  padding: 20px;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 2px solid var(--color-accent-orange);
}

.layer-filters-panel-header h3 {
  margin: 0;
  font-size: var(--font-size-3xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.layer-filters-panel-close {
  background: none;
  border: none;
  color: white;
  font-size: var(--font-size-2xl);
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.layer-filters-panel-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.layer-filters-content {
  padding: 20px;
}

.filter-section {
  margin-bottom: 16px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.filter-section:last-child {
  border-bottom: none;
}

.filter-section-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: #6c757d;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Overlay for slide-out panel */
.layer-filters-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
  z-index: 1049;
}

.layer-filters-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* ===========================
   Toggle Pills
=========================== */
.toggle-pills-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border-gray-300);
  border-radius: var(--radius-sm);
  background: var(--color-white);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: var(--font-size-md);
  font-weight: 600;
  position: relative;
  user-select: none;
  box-shadow: var(--shadow-xs);
}

.toggle-pill input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-medium);
  border-radius: 3px;
  background: var(--bg-primary);
  cursor: pointer;
  position: relative;
  margin: 0;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.toggle-pill input[type="checkbox"]:checked {
  background: var(--color-accent-orange);
  border-color: var(--color-accent-orange);
}

.toggle-pill input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.toggle-pill:hover {
  border-color: var(--color-accent-orange);
  background: rgba(204, 102, 0, 0.05);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.toggle-pill:has(input[type="checkbox"]:checked) {
  background: linear-gradient(
    to right,
    rgba(204, 102, 0, 0.1),
    rgba(214, 112, 0, 0.1)
  );
  border-color: var(--color-accent-orange);
  border-left: 3px solid var(--color-accent-orange);
  padding-left: 10px;
}

.toggle-pill:has(input[type="checkbox"]:checked) span {
  color: var(--color-accent-orange);
  font-weight: 600;
}

.toggle-pill input[type="checkbox"]:hover {
  border-color: var(--color-accent-orange);
  box-shadow: 0 0 0 2px rgba(204, 102, 0, 0.1);
}

.toggle-pill span {
  font-weight: 500;
  color: var(--text-primary);
}

.toggle-pill-modern {
  padding: 8px 16px;
  border: 1px solid #d0d0d0;
  border-radius: 20px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: var(--font-size-md);
  position: relative;
}

.toggle-pill-modern input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-pill-modern:hover {
  border-color: var(--color-accent-orange);
  background: rgba(204, 102, 0, 0.05);
}

.toggle-pill-modern.checked {
  background: var(--color-accent-orange);
  color: white;
  border-color: var(--color-accent-orange);
}

/* ===========================
   Unified Controls Container
=========================== */
.unified-controls {
  padding: 20px;
  background: #fafafa;
  border-radius: 8px;
}

.unified-common-filters {
  background: white;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ===========================
   Standard Checkbox Styling
=========================== */
.standard-checkbox,
input[type="checkbox"].standard-checkbox {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-medium);
  border-radius: 3px;
  background: var(--bg-primary);
  cursor: pointer;
  position: relative;
  margin: 0;
  vertical-align: middle;
  transition: all 0.2s ease;
}

.standard-checkbox:hover,
input[type="checkbox"].standard-checkbox:hover {
  border-color: var(--color-accent-orange);
  box-shadow: 0 0 0 2px rgba(204, 102, 0, 0.1);
}

.standard-checkbox:checked,
input[type="checkbox"].standard-checkbox:checked {
  background: var(--color-accent-orange);
  border-color: var(--color-accent-orange);
}

.standard-checkbox:checked::after,
input[type="checkbox"].standard-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.standard-checkbox:focus,
input[type="checkbox"].standard-checkbox:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(204, 102, 0, 0.2);
}

.standard-checkbox:disabled,
input[type="checkbox"].standard-checkbox:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===========================
   Info Icon & Tooltip
=========================== */
.info-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 14px !important;
  height: 14px !important;
  background: transparent !important;
  color: var(--gd-text-low) !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  font-size: var(--font-size-2xs) !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  overflow: visible !important;
  margin-left: 5px !important;
  margin-top: 1px !important;
  transition: background 0.2s ease;
  border: 1px solid var(--gd-text-low) !important;
}

.info-icon:hover {
  background: transparent !important;
  border-color: var(--gd-text-hi) !important;
  color: var(--gd-text-hi) !important;
}

.info-tooltip {
  position: fixed !important;
  display: block !important;
  background: rgba(30, 30, 30, 0.95);
  color: white;
  padding: 12px 16px;
  border-radius: 6px;
  max-width: clamp(200px, 20vw, 350px);
  font-size: var(--font-size-md);
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

.info-tooltip-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: var(--font-size-lg);
}

.info-tooltip-text {
  opacity: 0.9;
}

/* Long, list-based hints: cap height and scroll so the popup never
   overruns the viewport (createPopup clamps the top edge upward). */
.info-tooltip.ai-hints-tooltip {
  max-height: 60vh;
  overflow-y: auto;
}

.info-tooltip.ai-hints-tooltip .info-tooltip-text b {
  display: block;
  margin: 10px 0 4px;
  opacity: 1;
}

.info-tooltip.ai-hints-tooltip .info-tooltip-text b:first-child {
  margin-top: 0;
}

.info-tooltip.ai-hints-tooltip .info-tooltip-text ul {
  margin: 0;
  padding-inline-start: 16px;
}

.info-tooltip.ai-hints-tooltip .info-tooltip-text li {
  margin-bottom: 3px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ===========================
   General Layer Toggles
=========================== */
#general-layer-toggles {
  font-family: var(--gd-font-sans);
}

#general-layer-toggles h4,
#general-layer-toggles h5 {
  margin: 0;
  padding: 0;
}

#general-layer-toggles button.action-button {
  width: 100%;
  margin: 2px 0;
}

/* ===========================
   Analytics Container
=========================== */
#analytics-container .panel-content {
  overflow-y: auto;
  box-sizing: border-box;
  max-height: calc(100vh - 40px);
}
