/**
 * Road Incidents Module - Professional Light Theme
 * Clean, polished, and readable.
 */

:root {
  --im-primary: #2563eb;       /* Professional Blue */
  --im-danger: #ef4444;        /* Alert Red */
  --im-bg-surface: #ffffff;    /* Pure White */
  --im-bg-subtle: #f8fafc;     /* Very Light Grey */
  --im-border: #e2e8f0;        /* Light Border */
  --im-text-main: #1e293b;     /* Dark Slate */
  --im-text-muted: #64748b;    /* Muted Slate */
  --im-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --im-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --im-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Incidents Button - Floating Action Button (FAB) style */
.incidents-trigger-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--im-danger);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.5); /* Soft colored shadow */
  z-index: 1000;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.incidents-trigger-btn:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 20px 25px -5px rgba(239, 68, 68, 0.4);
}

/* Modal Overlay */
.incidents-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4); /* Dimmed backdrop */
  backdrop-filter: blur(4px);        /* Modern blur effect */
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.incidents-modal-overlay.open {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

/* Modal Container */
.incidents-modal {
  background: var(--im-bg-surface);
  border-radius: 12px;
  width: 100%;
  max-width: 900px;
  height: 95vh;
  /* max-height: 800px; */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--im-shadow-lg);
  border: 1px solid var(--im-border);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--im-text-main);
}

/* Modal Header */
.incidents-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--im-bg-surface);
  border-bottom: 1px solid var(--im-border);
}

.incidents-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--im-text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.incidents-modal-header h2 i {
  color: var(--im-danger);
}

.incidents-close-btn {
  background: none;
  border: none;
  color: var(--im-text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.incidents-close-btn:hover {
  background: var(--im-bg-subtle);
  color: var(--im-text-main);
}

/* Modal Body */
.incidents-modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--im-bg-subtle);
}

/* Tab Navigation - Clean Line Style */
.incidents-tabs {
  display: flex;
  background: var(--im-bg-surface);
  border-bottom: 1px solid var(--im-border);
  padding: 0 24px;
}

.incidents-tab {
  padding: 14px 20px;
  background: none;
  border: none;
  color: var(--im-text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.incidents-tab:hover {
  color: var(--im-primary);
  background: var(--im-bg-subtle);
}

.incidents-tab.active {
  color: var(--im-primary);
  border-bottom-color: var(--im-primary);
}

/* Tab Content */
.incidents-tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
}

.incidents-tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Allow Google Places dropdown */
.pac-container {
  z-index: 20000 !important;
  box-shadow: var(--im-shadow-lg) !important;
  border-radius: 8px !important;
  border: 1px solid var(--im-border) !important;
  font-family: inherit !important;
}

/* Map Container */
.incidents-map-container {
  flex: 1;
  min-height: 350px;
  position: relative;
}

#incidents-map {
  width: 100%;
  height: 100%;
}

/* Map Legend */
.incidents-map-legend {
  position: absolute;
  bottom: 24px;
  left: 10px;
  background: rgba(255, 255, 255, 0.95);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--im-text-main);
  box-shadow: var(--im-shadow-sm);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--im-border);
}

/* Report Panel */
.incidents-report-panel {
  background: var(--im-bg-surface);
  padding: 20px 24px;
  border-top: 1px solid var(--im-border);
  box-shadow: 0 -4px 6px -1px rgba(0,0,0,0.05);
}

.incidents-report-instruction {
  color: var(--im-text-muted);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons Grid */
.incidents-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.incident-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 0px;
  background: var(--im-bg-surface);
  border: 1px solid var(--im-border);
  border-radius: 8px;
  color: var(--im-text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--im-shadow-sm);
}

.incident-type-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--im-shadow-md);
  border-color: #cbd5e1;
  color: var(--im-text-main);
}

.incident-type-btn i {
  font-size: 24px;
  margin-bottom: 4px;
}

/* Specific button colors on icon */
.incident-type-btn.roadblock i { color: #f97316; }
.incident-type-btn.protest i { color: #ef4444; }
.incident-type-btn.violence i { color: #dc2626; }
.incident-type-btn.object i { color: #fbbf24; }
.incident-type-btn.accident i { color: #3b82f6; }
.incident-type-btn.other i { color: #8b5cf6; }

/* List View */
.incidents-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--im-bg-subtle);
}

.incidents-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Incident Card */
.incident-card {
  background: var(--im-bg-surface);
  border: 1px solid var(--im-border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  gap: 16px;
  transition: all 0.2s;
  box-shadow: var(--im-shadow-sm);
}

.incident-card:hover {
  box-shadow: var(--im-shadow-md);
  border-color: #cbd5e1;
}

/* Verified High Confidence Style */
.incident-card.high-confidence {
  border-left: 4px solid #fbbf24;
  background: linear-gradient(to right, #fffbeb, #ffffff);
}

.incident-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  position: relative;
}

/* Soft backgrounds for icons */
.incident-icon.roadblock { background: #ffedd5; color: #f97316; }
.incident-icon.protest { background: #fee2e2; color: #ef4444; }
.incident-icon.violence { background: #fef2f2; color: #dc2626; }
.incident-icon.object { background: #fef3c7; color: #d97706; }
.incident-icon.accident { background: #dbeafe; color: #3b82f6; }
.incident-icon.other { background: #f3e8ff; color: #7c3aed; }

.incident-info {
  flex: 1;
  min-width: 0;
}

.incident-type-label {
  font-weight: 700;
  color: var(--im-text-main);
  font-size: 15px;
  margin-bottom: 6px;
  text-transform: capitalize;
  display: flex;
  align-items: center;
  gap: 8px;
}

.incident-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--im-text-muted);
  flex-wrap: wrap;
}

.incident-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.incident-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 100px;
}

/* Action Buttons */
.incident-vote-btn, 
.incident-locate-btn,
.incident-dispute-btn {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.incident-vote-btn {
  background: #ecfdf5;
  border: 1px solid #d1fae5;
  color: #059669;
}

.incident-vote-btn:hover {
  background: #d1fae5;
  border-color: #a7f3d0;
}

.incident-vote-btn.disabled {
  background: var(--im-bg-subtle);
  border-color: var(--im-border);
  color: var(--im-text-muted);
  cursor: default;
}

.incident-dispute-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--im-text-muted);
}

.incident-dispute-btn:hover {
  background: #fef2f2;
  color: var(--im-danger);
}

.incident-locate-btn {
  background: #eff6ff;
  border: 1px solid #dbeafe;
  color: #2563eb;
}

.incident-locate-btn:hover {
  background: #dbeafe;
}

/* Badge */
.verified-badge {
  background: #f59e0b;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Route Planning Tab */
.incidents-route-card {
  background: var(--im-bg-surface);
  border-bottom: 1px solid var(--im-border);
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 6px -4px rgba(0,0,0,0.1);
  z-index: 10;
}

.incidents-route-map {
  width: 100%;
  height: 250px;
  background: var(--im-bg-subtle);
  border-bottom: 1px solid var(--im-border);
}

.incidents-route-field label {
  display: block;
  color: var(--im-text-main);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

/* Inputs */
.incidents-route-autocomplete,
.incidents-route-fallback {
  width: 100%;
  background: var(--im-bg-surface);
  border: 1px solid var(--im-border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--im-text-main);
  font-size: 14px;
  transition: border 0.2s;
  box-sizing: border-box;
}

.incidents-route-autocomplete::part(input) {
  /* For Google Places Element if used */
  background: transparent;
  color: var(--im-text-main);
  padding: 0;
  border: none;
}

.incidents-route-autocomplete:focus,
.incidents-route-autocomplete[type="text"]:focus,
.incidents-route-fallback:focus {
  outline: none;
  border-color: var(--im-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.incidents-route-input-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.incidents-route-btn {
  background: var(--im-primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: background 0.2s;
}

.incidents-route-btn:hover {
  background: #1d4ed8;
}

.incidents-route-hint {
  color: var(--im-text-muted);
  font-size: 12px;
  margin-top: 6px;
}

.incidents-route-results {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  background: var(--im-bg-subtle);
}

.incidents-route-empty {
  text-align: center;
  color: var(--im-text-muted);
  padding: 40px 20px;
  background: var(--im-bg-surface);
  border-radius: 8px;
  border: 1px dashed var(--im-border);
}

.incidents-route-empty i {
  display: block;
  font-size: 32px;
  margin-bottom: 12px;
  color: #cbd5e1;
}

.incidents-route-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--im-bg-surface);
  border: 1px solid var(--im-border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--im-shadow-sm);
}

.incidents-route-title {
  font-weight: 700;
  color: var(--im-text-main);
  font-size: 14px;
}

.incidents-route-meta {
  color: var(--im-text-muted);
  font-size: 13px;
}

.incidents-route-length {
  color: var(--im-primary);
  font-weight: 700;
  font-size: 16px;
}

.incidents-route-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  background: var(--im-bg-surface);
  border: 1px solid var(--im-border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 10px;
  transition: all 0.2s;
}

.incidents-route-item:hover {
  border-color: #cbd5e1;
  box-shadow: var(--im-shadow-sm);
}

.incidents-route-line {
  color: var(--im-text-main);
  font-weight: 600;
  font-size: 14px;
}

.incidents-route-focus {
  background: transparent;
  color: var(--im-text-muted);
  border: 1px solid var(--im-border);
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.incidents-route-focus:hover {
  border-color: var(--im-primary);
  color: var(--im-primary);
  background: #eff6ff;
}

/* Toast */
.incidents-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1f2937;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 10001;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--im-shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
}

.incidents-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

.incidents-toast.error {
  background: #991b1b;
}

/* Pin Placement */
.incidents-pin-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -100%);
  z-index: 1000;
  pointer-events: none;
  font-size: 40px;
  color: var(--im-danger);
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
  transition: transform 0.15s ease;
}

.incidents-pin-marker.bounce {
  animation: pinBounce 0.3s ease;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pinBounce {
  0%, 100% { transform: translate(-50%, -100%); }
  50% { transform: translate(-50%, -120%); }
}

/* InfoWindow Customization (Reset Google Styles) */
.gm-style .gm-style-iw-c {
  padding: 0 !important;
  border-radius: 8px !important;
  box-shadow: var(--im-shadow-lg) !important;
}

.incident-info-window {
  padding: 16px;
  color: var(--im-text-main);
  min-width: 200px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.incident-info-window h4 {
  margin: 0 0 10px 0;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.incident-info-window .meta {
  color: var(--im-text-muted);
  font-size: 13px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.incident-info-window .meta i {
  width: 16px;
  text-align: center;
}

.info-window-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--im-border);
}

.info-window-actions button {
  flex: 1;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--im-border);
  background: white;
  cursor: pointer;
  font-weight: 500;
  font-size: 12px;
}

.info-window-actions .vote-btn {
  background: var(--im-primary);
  color: white;
  border: none;
}

.info-window-actions .vote-btn:hover {
  background: #1d4ed8;
}

/* Responsive */
@media (max-width: 768px) {
  .incidents-modal {
    height: 95vh;
    border-radius: 12px 12px 0 0;
    margin-top: auto;
    max-height: none;
  }
  
  .incidents-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  
  .incidents-trigger-btn {
    bottom: 80px; /* Above standard bottom navs */
  }

  .incident-card {
    flex-direction: column;
  }
  
  .incident-actions {
    flex-direction: row;
    width: 100%;
  }
  
  .incident-actions button {
    flex: 1;
  }
}