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

/* ========== DESIGN TOKENS ========== */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --text:       #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;

  --bg:         #ffffff;
  --bg-soft:    #f9fafb;
  --bg-muted:   #f3f4f6;

  --border:     #e5e7eb;
  --border-light:#f3f4f6;

  --primary:    #0d9488;
  --primary-hover:#0f766e;
  --primary-light:#ccfbf1;
  --primary-faint:#f0fdfa;

  --accent:     #f59e0b;
  --error:      #ef4444;
  --success:    #22c55e;

  --radius:     8px;
  --radius-lg:  12px;
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
  --shadow:     0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);

  --transition: 150ms ease;
}

/* ========== RESET ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  color: var(--primary-hover);
}

img { max-width: 100%; display: block; }

/* ========== TYPOGRAPHY ========== */
h1 { font-size: 2.25rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.02em; }
h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.4; }
p  { color: var(--text-muted); }

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-light { color: var(--text-light); }

/* ========== LAYOUT ========== */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-soft);
  border-color: var(--text-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.btn-danger {
  background: var(--error);
  color: #fff;
}
.btn-danger:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.0625rem;
  border-radius: var(--radius-lg);
}

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

/* ========== FORMS ========== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 4px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

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

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

/* ========== CARDS ========== */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card-flat {
  background: var(--bg-soft);
  border: none;
}

/* ========== NAVBAR ========== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-light);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.navbar-brand img {
  width: auto;
  height: 80px;
}

/* ========== BADGE ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-error {
  background: #fee2e2;
  color: #991b1b;
}

/* ========== TOAST ========== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  background: var(--text);
  box-shadow: var(--shadow-lg);
  animation: toast-in 300ms ease;
  max-width: 380px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--error); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ========== HERO (Landing) ========== */
.hero {
  text-align: center;
  padding: 80px 24px 64px;
}

.hero h1 {
  font-size: 3rem;
  margin-bottom: 16px;
  color: var(--text);
}

.hero h1 span {
  color: var(--primary);
}

.hero p {
  font-size: 1.1875rem;
  max-width: 560px;
  margin: 0 auto 36px;
  line-height: 1.7;
}

/* ========== STEPS (Landing) ========== */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.step {
  text-align: center;
  padding: 32px 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  border: 1px solid var(--border-light);
  transition: all var(--transition);
}

.step:hover {
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.step-icon {
  font-size: 2rem;
  margin-bottom: 16px;
}

.step h3 {
  margin-bottom: 8px;
}

.step p {
  font-size: 0.875rem;
}

/* ========== SPLIT LAYOUT (Create) ========== */
.split-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  height: 100vh;
}

.split-form {
  padding: 32px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.split-map {
  position: relative;
}

/* ========== FULLSCREEN MAP ========== */
.map-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.map-fullscreen #map {
  width: 100%;
  height: 100%;
}

/* ========== MAP OVERLAYS ========== */
.map-overlay {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
}

.map-overlay > * {
  pointer-events: auto;
}

/* Project info panel (volunteer view) */
.map-info-panel {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1000;
  width: 320px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: transform 300ms ease;
}

.map-info-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-light);
}

.map-info-header h2 {
  font-size: 1.125rem;
  margin-bottom: 4px;
}

.map-info-body {
  padding: 16px 20px;
}

.map-info-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
}

/* Pin counter */
.pin-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.pin-counter-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-muted);
  border-radius: 2px;
  overflow: hidden;
}

.pin-counter-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 300ms ease;
}

/* Submit floating bar */
.submit-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease, transform 300ms ease;
}

.submit-bar.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ========== MANAGE SIDEBAR ========== */
.manage-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1000;
  width: 380px;
  height: 100vh;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

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

.manage-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.manage-sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Submission list in manage view */
.submission-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.submission-item:last-child {
  border-bottom: none;
}

.submission-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.submission-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.submission-name {
  font-weight: 500;
  font-size: 0.875rem;
}

.submission-meta {
  font-size: 0.75rem;
  color: var(--text-light);
  padding-left: 20px;
}

/* ========== PIN FORM POPUP ========== */
.pin-form-popup {
  width: 240px;
}

.pin-form-popup .form-group {
  margin-bottom: 12px;
}

.pin-form-popup .form-input,
.pin-form-popup .form-textarea {
  padding: 8px 10px;
  font-size: 0.8125rem;
}

.pin-form-popup .form-textarea {
  min-height: 48px;
}

.pin-form-popup .form-label {
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.pin-popup-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* ========== CONFIRMATION SCREEN ========== */
.confirmation {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  animation: fade-in 300ms ease;
}

.confirmation-card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: scale-in 300ms ease;
}

.confirmation-card .check-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 1.5rem;
}

.confirmation-card h2 {
  margin-bottom: 8px;
}

.confirmation-card p {
  margin-bottom: 24px;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

/* ========== BASEMAP SWITCH ========== */
.basemap-switch {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.basemap-switch button {
  padding: 8px 14px;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.basemap-switch button.active {
  background: var(--primary);
  color: #fff;
}

.basemap-switch button:not(.active):hover {
  background: var(--bg-soft);
}

/* ========== FOOTER ========== */
.footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border-light);
  font-size: 0.8125rem;
  color: var(--text-light);
}

/* ========== LINK COPY ========== */
.link-box {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.link-box input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: var(--bg-soft);
  outline: none;
}

/* ========== LOADING ========== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-light);
  font-size: 0.875rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  margin-right: 10px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-light);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .hero h1 { font-size: 2rem; }
  .hero p { font-size: 1rem; }

  .steps {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .split-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .split-form {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 24px;
  }

  .split-map {
    height: 50vh;
  }

  .map-info-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 45vh;
    overflow-y: auto;
  }

  .manage-sidebar {
    width: 100%;
    max-height: 50vh;
    height: auto;
    top: auto;
    bottom: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .submit-bar {
    left: 16px;
    right: 16px;
    transform: none;
  }

  .basemap-switch {
    right: 16px;
    top: 16px;
  }
}

/* ========== LEAFLET OVERRIDES ========== */
.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  color: var(--text) !important;
  border-bottom-color: var(--border) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-soft) !important;
}

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

.leaflet-popup-content {
  margin: 16px !important;
  font-family: var(--font) !important;
  font-size: 0.875rem !important;
  line-height: 1.5 !important;
}

.leaflet-popup-close-button {
  color: var(--text-light) !important;
  font-size: 20px !important;
  right: 8px !important;
  top: 8px !important;
}

.leaflet-container {
  font-family: var(--font) !important;
}
