@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=DM+Sans:wght@400;500&display=swap');

:root {
  --primary: #FF69B4;
  --primary-light: #FFB6C1;
  --secondary: #FFC0CB;
  --orange: #FF1493;
  --cream: #FFFAF0;
  --purple: #7C4DFF;
  --muted: #78909C;
  --bg: #F0F5F3;
  --surface: #FFFFFF;
  --surface-alt: #F7FAF9;
  --text: #1B2A2A;
  --text-secondary: #5A6E6E;
  --text-light: #8A9E9E;
  --border: #D4E4DF;
  --shadow-sm: 0 1px 3px rgba(0, 50, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 50, 40, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 50, 40, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

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

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
}

#root {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  line-height: 1.2;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ========== HEADER ========== */
.app-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  padding: 14px 20px;
  flex-shrink: 0;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 800px;
  margin: 0 auto;
}

.header-icon {
  font-size: 1.5rem;
}

.header-title {
  font-size: 1.25rem;
  color: white;
  letter-spacing: -0.5px;
}

.header-subtitle {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 10px;
  border-radius: 20px;
}

/* ========== TABS ========== */
.tab-bar {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: none;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  width: 60%;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

.tab-btn:hover:not(.active) {
  color: var(--text-secondary);
  background: var(--surface-alt);
}

.tab-icon {
  margin-right: 4px;
}

/* ========== MAIN ========== */
.app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ========== MAP VIEW ========== */
.map-view {
  height: 100%;
  position: relative;
}

.map-container {
  height: 100%;
  width: 100%;
  z-index: 1;
}

.map-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-light);
}

.map-loading .skeleton-pulse {
  width: 200px;
  height: 12px;
  border-radius: 6px;
}

.map-legend {
  position: absolute;
  bottom: 20px;
  left: 12px;
  right: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.legend-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.legend-items {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.legend-label {
  white-space: nowrap;
}

.location-notice {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--cream);
  color: var(--orange);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

/* Custom map marker */
.custom-marker {
  background: none !important;
  border: none !important;
}

.marker-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid white;
  transition: transform 0.2s ease;
}

.marker-dot:hover {
  transform: scale(1.3);
}

/* Map popup */
.popup-content {
  font-family: 'DM Sans', sans-serif;
  line-height: 1.5;
}

.popup-content strong {
  font-family: 'Plus Jakarta Sans', sans-serif;
  display: block;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.popup-content p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.popup-content small {
  font-size: 0.7rem;
  color: var(--text-light);
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 30, 25, 0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

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

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 1.2rem;
  color: var(--text);
}

.close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.coords-badge {
  display: inline-block;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-family: monospace;
}

/* ========== FORM ========== */
.form-label {
  display: block;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 8px;
}

.incident-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'DM Sans', sans-serif;
}

.type-card:hover {
  border-color: var(--primary-light);
  background: var(--surface-alt);
}

.type-card.selected {
  border-color: var(--primary);
  background: rgba(0, 191, 165, 0.08);
  box-shadow: 0 0 0 2px rgba(0, 191, 165, 0.15);
}

.type-icon {
  font-size: 1.5rem;
}

.type-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
}

.type-card.selected .type-label {
  color: var(--primary);
  font-weight: 600;
}

.form-textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.2s ease;
  line-height: 1.5;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 191, 165, 0.12);
}

.form-textarea::placeholder {
  color: var(--text-light);
}

.char-count {
  text-align: right;
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 4px;
  margin-bottom: 16px;
}

.submit-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

/* ========== SUCCESS ========== */
.success-modal {
  text-align: center;
  padding: 40px 24px;
  animation: slideUp 0.3s ease;
}

.success-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  animation: popIn 0.4s ease;
}

@keyframes popIn {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.success-modal h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--primary);
}

.success-modal p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ========== REPORTS LIST ========== */
.reports-list {
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 40px;
}

.stats-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.stat-card {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: center;
  min-width: 90px;
}

.stat-card.stat-total {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-color: transparent;
}

.stat-card.stat-total .stat-number,
.stat-card.stat-total .stat-label {
  color: white;
}

.stat-number {
  display: block;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-light);
  font-weight: 500;
  margin-top: 4px;
  display: block;
  white-space: nowrap;
}

/* ========== FILTERS ========== */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.filter-chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--primary-light);
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ========== REPORT CARDS ========== */
.report-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.report-card {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  animation: cardSlideIn 0.4s ease both;
}

@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.report-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-accent {
  width: 4px;
  flex-shrink: 0;
}

.card-body {
  flex: 1;
  padding: 12px 16px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}

.card-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  color: white;
  white-space: nowrap;
}

.card-time {
  font-size: 0.7rem;
  color: var(--text-light);
  white-space: nowrap;
}

.card-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.card-coords {
  font-size: 0.7rem;
  color: var(--text-light);
  font-family: monospace;
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  max-width: 280px;
  margin: 0 auto;
}

/* ========== SKELETON ========== */
.skeleton-pulse {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface-alt) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 20px;
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-line {
  height: 14px;
  width: 100%;
}

.skeleton-line-short {
  height: 12px;
  width: 40%;
}

/* ========== RESPONSIVE ========== */
@media (min-width: 641px) {
  .modal-overlay {
    align-items: center;
  }

  .modal-content {
    border-radius: var(--radius-lg);
    max-height: 80vh;
  }

  .stats-bar {
    flex-wrap: wrap;
  }

  .map-legend {
    left: 16px;
    right: auto;
    bottom: 24px;
    max-width: 420px;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 10px 16px;
  }

  .header-title {
    font-size: 1.1rem;
  }

  .reports-list {
    padding: 12px;
  }

  .incident-type-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card {
    min-width: 75px;
    padding: 8px 10px;
  }

  .stat-number {
    font-size: 1.1rem;
  }
}

@media (max-width: 360px) {
  .incident-type-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== FOCUS STYLES ========== */
.tab-btn:focus-visible,
.filter-chip:focus-visible,
.type-card:focus-visible,
.submit-btn:focus-visible,
.close-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.form-textarea:focus-visible {
  outline: none;
}

/* ========== LEAFLET OVERRIDES ========== */
.leaflet-control-zoom a {
  border-radius: var(--radius-sm) !important;
  color: var(--text) !important;
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
}

.leaflet-popup-tip {
  box-shadow: none !important;
}

.card-poster {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.map-live-status {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(0, 191, 165, 0.45);
  animation: livePulse 1.6s infinite;
}

.live-text {
  white-space: nowrap;
}

@keyframes livePulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 191, 165, 0.45);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(0, 191, 165, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(0, 191, 165, 0);
  }
}

@media (max-width: 640px) {
  .map-live-status {
    top: auto;
    bottom: 78px;
    right: 12px;
    left: 12px;
    justify-content: center;
  }
}

.export-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.export-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.export-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.export-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.export-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
}

.export-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 191, 165, 0.12);
}

.export-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.export-btn {
  padding: 9px 14px;
  border: none;
  border-radius: 20px;
  background: var(--primary);
  color: white;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.export-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.export-hint {
  font-size: 0.8rem;
  color: var(--text-light);
}

@media (max-width: 640px) {
  .export-fields {
    grid-template-columns: 1fr;
  }
}
