.advanced-widgets-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

.widgets-header {
  margin-bottom: 3rem;
}

.widgets-header .header-content {
  text-align: center;
  padding: 2rem 0;
}

.widgets-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary, #1a1a1a);
}

.widgets-header .subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary, #666);
  margin: 0;
}

.widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

.widget-card {
  background: var(--bg-primary, white);
  border: 1px solid var(--border-color, #ddd);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  overflow: hidden;
}

.widget-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border-color: var(--primary-color, #c41e3a);
}

.widget-card.refreshing {
  opacity: 0.7;
  pointer-events: none;
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color, #ddd);
  background: linear-gradient(135deg, #f5f5f5 0%, #fafafa 100%);
}

.widget-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary, #1a1a1a);
}

.widget-controls {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(0, 0, 0, 0.05);
  transform: scale(1.1);
}

.btn-icon:active {
  transform: scale(0.95);
}

.widget-body {
  padding: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-primary, #1a1a1a);
  font-size: 0.95rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 4px;
  font-size: 0.95rem;
  background: var(--bg-primary, white);
  color: var(--text-primary, #1a1a1a);
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color, #c41e3a);
  box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.column-selector,
.metric-selector {
  background: var(--bg-secondary, #f9f9f9);
  padding: 1rem;
  border-radius: 4px;
  border: 1px solid var(--border-color, #ddd);
}

.metric-selector label {
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
  font-weight: 400;
  cursor: pointer;
}

.metric-selector label input {
  margin-right: 0.75rem;
  cursor: pointer;
}

.metric-selector label:hover {
  color: var(--primary-color, #c41e3a);
}

.table-preview {
  margin: 1.5rem 0;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table thead {
  background: var(--bg-secondary, #f9f9f9);
  border-bottom: 2px solid var(--border-color, #ddd);
}

.data-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary, #1a1a1a);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-color, #ddd);
  transition: background 0.2s ease;
}

.data-table tbody tr:hover {
  background: var(--bg-secondary, #f9f9f9);
}

.data-table td {
  padding: 1rem;
  color: var(--text-secondary, #666);
}

.badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
}

.badge-success {
  background: rgba(76, 175, 80, 0.15);
  color: #4caf50;
}

.badge-warning {
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color, #ddd);
}

.pagination-info {
  color: var(--text-secondary, #666);
  font-size: 0.95rem;
}

.btn {
  padding: 0.625rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-primary:hover {
  background: #a01830;
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-secondary, #f0f0f0);
  color: var(--text-primary, #1a1a1a);
  border: 1px solid var(--border-color, #ddd);
}

.btn-secondary:hover {
  background: #e8e8e8;
}

.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

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

.map-preview {
  margin: 1.5rem 0;
  background: var(--bg-secondary, #f9f9f9);
  border-radius: 4px;
  overflow: hidden;
}

.map-placeholder {
  position: relative;
  width: 100%;
  padding-bottom: 66.67%;
}

.world-map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.map-legend {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.95);
  position: absolute;
  bottom: 10px;
  right: 10px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.legend-color {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.metric-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin: 1.5rem 0;
}

.metric-display {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f5f5f5 0%, #fafafa 100%);
  border-radius: 8px;
}

.metric-icon {
  font-size: 2.5rem;
}

.metric-content {
  flex: 1;
}

.metric-label {
  font-size: 0.95rem;
  color: var(--text-secondary, #666);
  margin-bottom: 0.5rem;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color, #c41e3a);
  margin-bottom: 0.5rem;
}

.metric-comparison {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.trend-up {
  color: #4caf50;
  font-weight: 500;
}

.metric-target {
  color: var(--text-secondary, #666);
}

.metric-gauge {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gauge-progress {
  height: 20px;
  background: var(--bg-secondary, #f0f0f0);
  border-radius: 10px;
  overflow: hidden;
}

.gauge-bar {
  height: 100%;
  background: linear-gradient(90deg, #4caf50 0%, #ffc107 50%, #ff9800 100%);
  transition: width 0.5s ease;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-secondary, #666);
  font-weight: 500;
}

.timeseries-preview {
  margin: 1.5rem 0;
  background: var(--bg-secondary, #f9f9f9);
  border-radius: 4px;
  padding: 1rem;
}

.timeseries-chart {
  width: 100%;
  height: auto;
  margin-bottom: 1rem;
}

.timeseries-legend {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
}

.widget-documentation {
  background: var(--bg-secondary, #f9f9f9);
  border: 1px solid var(--border-color, #ddd);
  border-radius: 8px;
  padding: 2rem;
  margin-top: 3rem;
}

.widget-documentation h3 {
  margin-top: 0;
  color: var(--text-primary, #1a1a1a);
}

.widget-documentation ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.widget-documentation li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color, #ddd);
  color: var(--text-secondary, #666);
}

.widget-documentation li:last-child {
  border-bottom: none;
}

.widget-documentation strong {
  color: var(--text-primary, #1a1a1a);
}

@media (max-width: 768px) {
  .advanced-widgets-container {
    padding: 1rem;
  }

  .widgets-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .metric-preview {
    grid-template-columns: 1fr;
  }

  .widgets-header h1 {
    font-size: 2rem;
  }

  .widget-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .widget-controls {
    width: 100%;
    justify-content: flex-end;
  }

  .timeseries-legend {
    flex-direction: column;
    gap: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .widget-card,
  .form-control,
  .btn,
  .btn-icon,
  .gauge-bar {
    transition: none;
  }
}

@media (prefers-color-scheme: dark) {
  .advanced-widgets-container {
    --bg-primary: #1e1e1e;
    --bg-secondary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #444;
  }

  .widget-header {
    background: linear-gradient(135deg, #333 0%, #2a2a2a 100%);
  }

  .widget-card:hover {
    box-shadow: 0 4px 16px rgba(196, 30, 58, 0.3);
  }

  .map-legend {
    background: rgba(0, 0, 0, 0.9);
  }

  .metric-display {
    background: linear-gradient(135deg, #2d2d2d 0%, #333 100%);
  }
}
