/* Reset and Base */
* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

:root {
  --primary: #EEB66F;
  --primary-dark: #78503B;
  --secondary: #94a3b8;
  --background: #1C2226;
  --surface: #123243;
  --text: #f1f5f9;
  --text-muted: #b0b6bd;
  --border: #334155;
  --success: #22c55e;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

.container { 
  max-width: 1400px; 
  margin: 0 auto; 
  padding: 20px; 
}

/* Header */
header {
  background: var(--surface);
  padding: 20px 24px;
  border-radius: 8px;
  margin-bottom: 16px;
  box-shadow: var(--card-shadow);
}

h1 { 
  color: var(--text); 
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 4px;
}

.subtitle { 
  color: var(--text-muted); 
  font-size: 14px; 
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--background);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

/* Stats Row */
.stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-pill {
  background: var(--surface);
  padding: 10px 16px;
  border-radius: 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

/* Filter Controls Bar */
.filter-controls-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  flex-wrap: wrap;
}

.filter-toggle-group {
  display: flex;
  align-items: center;
}

/* Confidence Slider */
.confidence-slider-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 200px;
}

.confidence-slider-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.confidence-slider-group input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #475569;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.confidence-slider-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}

.confidence-slider-group input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--primary-dark);
}

.confidence-slider-group input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.confidence-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  min-width: 32px;
  text-align: center;
}

/* Legacy support */
.filter-toggle-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  flex-wrap: wrap;
}

.toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  flex-shrink: 0;
}

.toggle-btn.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.2);
}

.toggle-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.toggle-btn.active .toggle-indicator {
  background: var(--primary);
}

.filter-hint {
  font-size: 13px;
  color: var(--text-muted);
}

/* Inline Active Filters */
.active-filters-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  margin-left: 8px;
}

.active-filters-inline .filter-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 12px;
  font-size: 12px;
}

.filter-card-name {
  font-weight: 600;
  color: var(--primary);
}

.filter-card-value {
  color: var(--text);
}

.filter-card-remove {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
  margin-left: 2px;
}

.filter-card-remove:hover {
  color: #dc2626;
}

.results-count {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: auto;
}

/* Main Layout */
/* Charts & Filter Layout (New) */
.charts-filter-layout {
  margin-bottom: 16px;
}

.filter-dropdowns {
  display: flex;
  gap: 20px;
  justify-content: center;
  background: var(--surface);
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  margin-bottom: 16px;
}

/* Filter Grid Layout - 3 columns side by side */
.filter-grid-layout {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* Filter panels with dropdown and chart */
.filter-panel {
  display: flex;
  flex-direction: column;
}

/* Inline filter dropdown at top of panel */
.filter-dropdown-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.filter-dropdown-inline label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  white-space: nowrap;
}

.filter-dropdown-inline select {
  flex: 1;
  min-width: 100px;
}

/* Responsive: Stack on smaller screens */
@media (max-width: 1024px) {
  .filter-grid-layout {
    grid-template-columns: 1fr 1fr;
  }
  
  .map-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .filter-grid-layout {
    grid-template-columns: 1fr;
  }
}

.chart-panel {
  background: var(--surface);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
}

.chart-header h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.chart-panel .chart-container {
  flex: 1;
  height: 300px;
  min-height: 300px;
}

/* Map panel specific styles */
.map-panel {
  display: flex;
  flex-direction: column;
}

.map-panel .chart-header {
  margin-bottom: 12px;
}

.map-panel .chart-container {
  flex: 1;
  min-height: 300px;
  height: 300px;
}

/* Plotly Map Container */
#eu-map-container {
  width: 100%;
  height: 100%;
  min-height: 280px;
  position: relative;
}

#eu-map-container .js-plotly-plot,
#eu-map-container .plotly {
  width: 100% !important;
  height: 100% !important;
}

.map-stats {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin: 8px 0;
}

.chart-clear-btn {
  margin-top: 12px;
  align-self: center;
}

.filter-dropdown-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-dropdown-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-dropdown-group select {
  min-width: 180px;
}

@media (max-width: 768px) {
  .filter-dropdowns {
    flex-direction: column;
    align-items: center;
  }
}

/* Legacy Layout (kept for compatibility) */
.main-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* Filters Panel */
.filters-panel {
  background: var(--surface);
  padding: 20px;
  border-radius: 8px;
  box-shadow: var(--card-shadow);
}

.filter-section {
  margin-bottom: 16px;
}

.filter-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.filter-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--surface);
  cursor: pointer;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-arrow {
  text-align: center;
  color: var(--text-muted);
  font-size: 20px;
  margin: 8px 0;
}

.checkbox-list {
  margin-top: 10px;
  max-height: 200px;
  overflow-y: auto;
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  cursor: pointer;
}

.checkbox-list input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Viz Panel */
.viz-panel {
  background: var(--surface);
  padding: 20px;
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
}

.chart-container {
  flex: 1;
  min-height: 300px;
  max-height: 350px;
  position: relative;
}

.chart-container canvas {
  max-height: 320px !important;
}

/* EU SVG Map */
.eu-map-card {
  background: var(--surface);
  padding: 16px 20px;
  border-radius: 8px;
  width: 280px;
  box-shadow: var(--card-shadow);
  margin-bottom: 16px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

/* Plotly Map Container */
#eu-map-container {
  width: 100%;
  height: 350px;
  position: relative;
  overflow: hidden;
}

#eu-map-container .js-plotly-plot,
#eu-map-container .plotly {
  width: 100% !important;
  height: 100% !important;
}

.map-stats {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* Filter Cards */
.filter-cards-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 16px;
  box-shadow: var(--card-shadow);
  min-height: 48px;
  align-items: center;
}

.filter-cards-container:empty {
  display: none;
}

.filter-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  animation: slideIn 0.3s ease;
}

.filter-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.filter-card .remove-icon {
  font-size: 14px;
  line-height: 1;
  opacity: 0.8;
}

.filter-card .remove-icon:hover {
  opacity: 1;
}

.filter-card.country-filter {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.filter-card.disease-filter {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.filter-card.ai-filter {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.filter-card.confidence-filter {
  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

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

.clear-all-filters {
  margin-left: auto;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.clear-all-filters:hover {
  background: #334155;
  color: var(--text);
}

/* Compact Map (legacy) */
.compact-map {
  height: 250px;
  width: 250px;
  border-radius: 6px;
  background: #1e293b;
}

/* Search Bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
}

.search-bar input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
}

.results-count {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Table */
.table-card {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.table-actions {
  display: flex;
  gap: 8px;
}

.table-scroll-container {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
}

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

.companies-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.companies-table th {
  background: #1e293b;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
}

.companies-table th:hover {
  background: #334155;
}

.companies-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.companies-table tr:hover {
  background: #334155;
}

/* Keyword Tags */
.keyword-tag {
  display: inline-block;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin: 1px;
  white-space: nowrap;
}

/* Tag Input Container for Modal */
.tag-input-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0f172a;
  min-height: 36px;
  cursor: text;
  margin-bottom: 4px;
}

.tag-input-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.tag-input-container .keyword-tag {
  cursor: default;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tag-input-container .keyword-tag.editable-tag {
  cursor: pointer;
}

.tag-input-container .keyword-tag.editable-tag:hover {
  background: rgba(59, 130, 246, 0.4);
}

.tag-input-container .keyword-tag .tag-text {
  cursor: text;
}

.tag-input-container .keyword-tag .remove-tag {
  cursor: pointer;
  opacity: 0.6;
  font-weight: 600;
  padding: 0 2px;
}

.tag-input-container .keyword-tag .remove-tag:hover {
  opacity: 1;
  color: #dc2626;
}

.tag-input-container .tag-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.tag-input-container .tag-add-btn:hover {
  background: rgba(59, 130, 246, 0.4);
}

.tag-input-container .tag-edit-input {
  border: none;
  background: transparent;
  padding: 0 4px;
  font-size: 12px;
  font-family: inherit;
  min-width: 60px;
  outline: none;
}

/* Responsive */
@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  
  .viz-panel {
    min-height: 300px;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 12px;
  }
  
  h1 {
    font-size: 18px;
  }
  
  .stats-row {
    flex-wrap: wrap;
  }
  
  .filter-toggle-bar {
    flex-wrap: wrap;
  }
}

/* Table Tabs */
.table-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 20px 0;
  border-bottom: 2px solid var(--border);
  background: #1e293b;
}

.table-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.table-tab:hover {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.1);
}

.table-tab-active {
  color: #60a5fa;
  border-bottom-color: #3b82f6;
  background: #0f172a;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-content {
  background: #1e293b;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  color: #f1f5f9;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.modal-close:hover {
  background: #334155;
  color: #f1f5f9;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: #0f172a;
}

/* Form Styles */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: #cbd5e1;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
  background: #0f172a;
  color: #f1f5f9;
}

.form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

/* Button variants */
.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

/* Table link */
.table-link {
  color: #60a5fa;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}
