/* CSS Variables - shadcn/ui inspired design tokens */
:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 222.2 84% 4.9%;
  --primary: 221.2 83.2% 53.3%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222.2 47.4% 11.2%;
  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96.1%;
  --accent-foreground: 222.2 47.4% 11.2%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --success: 142.1 76.2% 36.3%;
  --success-foreground: 355.7 100% 97.3%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 221.2 83.2% 53.3%;
  --radius: 0.5rem;
}

/* Reset and base styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  height: 56px;
  border-bottom: 1px solid hsl(var(--border));
  background-color: hsl(var(--card));
}

.header-left {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.header-right {
  display: flex;
  align-items: center;
}

/* User Dropdown */
.user-dropdown {
  position: relative;
}

.user-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background-color: transparent;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  transition: all 0.2s ease;
}

.user-dropdown-trigger:hover {
  background-color: hsl(var(--muted));
}

.dropdown-chevron {
  transition: transform 0.2s ease;
}

.user-dropdown:hover .dropdown-chevron {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  min-width: 200px;
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  z-index: 100;
}

.user-dropdown:hover .user-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-user-info {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.dropdown-user-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

.dropdown-user-email {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.dropdown-divider {
  height: 1px;
  background-color: hsl(var(--border));
}

.dropdown-item {
  display: block;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.dropdown-item:hover {
  background-color: hsl(var(--muted));
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: hsl(var(--primary));
}

.logo-text {
  font-weight: 600;
  font-size: 1.125rem;
}

.nav {
  display: flex;
  gap: 0.25rem;
}

.nav-link {
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: hsl(var(--foreground));
  background-color: hsl(var(--muted));
}

.nav-link.active {
  color: hsl(var(--foreground));
  background-color: hsl(var(--muted));
}

/* Main Content */
.main-content {
  flex: 1;
  overflow: hidden;
}

.content-wrapper {
  display: flex;
  height: 100%;
}

/* Left Panel */
.left-panel {
  width: 45%;
  min-width: 400px;
  max-width: 900px;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  border-right: 1px solid hsl(var(--border));
  background-color: hsl(var(--background));
}

/* Right Panel - Map */
.right-panel {
  flex: 1;
  position: relative;
}

/* Card */
.card {
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.25rem;
}

.table-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Form Section Header */
.form-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid hsl(var(--border));
}

.form-section-header svg {
  color: hsl(var(--primary));
  flex-shrink: 0;
}

.form-section-header span {
  font-weight: 600;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

.form-section-hint {
  margin-left: auto;
  font-weight: 400 !important;
  font-size: 0.75rem !important;
  color: hsl(var(--muted-foreground)) !important;
  background-color: hsl(var(--muted));
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
}

/* Form */
.search-form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.form-group {
  flex: 1;
}

.form-group-double {
  display: flex;
  gap: 0.75rem;
}

.input-pair {
  flex: 1;
}

.form-group label,
.input-pair label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

/* Input */
.input {
  width: 100%;
  height: 36px;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background-color: transparent;
  color: hsl(var(--foreground));
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input::placeholder {
  color: hsl(var(--muted-foreground));
}

.input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsla(var(--ring), 0.1);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-primary {
  height: 36px;
  padding: 0 1rem;
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover {
  background-color: hsl(221.2 83.2% 45%);
}

.btn-secondary {
  height: 36px;
  padding: 0 1rem;
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border: 1px solid hsl(var(--border));
}

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

.btn-outline {
  height: 36px;
  padding: 0 1rem;
  background-color: transparent;
  border-color: hsl(var(--input));
  color: hsl(var(--foreground));
}

.btn-outline:hover {
  background-color: hsl(var(--muted));
}

.btn-success {
  height: 36px;
  padding: 0 1rem;
  background-color: hsl(var(--success));
  color: hsl(var(--success-foreground));
}

.btn-success:hover {
  background-color: hsl(142.1 76.2% 30%);
}

.btn-ghost {
  background-color: transparent;
  color: hsl(var(--muted-foreground));
}

.btn-ghost:hover {
  background-color: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.btn-sm {
  height: 28px;
  width: 28px;
  padding: 0;
}

/* Table */
.table-container {
  flex: 1;
  overflow: auto;
}

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

.table th,
.table td {
  text-align: left;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid hsl(var(--border));
}

.table th {
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  background-color: hsl(var(--muted));
  position: sticky;
  top: 0;
}

.table tbody tr:hover {
  background-color: hsl(var(--muted));
}

.table-actions {
  display: flex;
  gap: 0.25rem;
}

.table-footer {
  padding-top: 1rem;
  border-top: 1px solid hsl(var(--border));
  margin-top: auto;
}

/* Map */
.map-container {
  height: 100%;
  position: relative;
}

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

.map-controls {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.map-toggle {
  display: flex;
  background-color: hsl(var(--card));
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.map-toggle-btn {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border: none;
  background-color: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: all 0.2s ease;
}

.map-toggle-btn:hover {
  background-color: hsl(var(--muted));
}

.map-toggle-btn.active {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

/* Mapbox popup styling */
.mapboxgl-popup-content {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-family: inherit;
}

.mapboxgl-popup-close-button {
  font-size: 1.25rem;
  padding: 0.25rem 0.5rem;
  color: hsl(var(--muted-foreground));
}

.mapboxgl-popup-close-button:hover {
  background-color: hsl(var(--muted));
}

.popup-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 220px;
  max-width: 300px;
}

.popup-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: hsl(var(--foreground));
}

.popup-address {
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
  line-height: 1.4;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid hsl(var(--border));
}

.popup-coords {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  display: flex;
  gap: 1rem;
}

.popup-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.popup-actions button {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  height: auto;
  flex: 1;
}

/* Custom marker */
.custom-marker {
  cursor: pointer;
}

/* Improved Location Popup */
.location-popup-container .mapboxgl-popup-content {
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.location-popup {
  min-width: 280px;
}

.location-popup .popup-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(221.2 83.2% 45%) 100%);
  color: white;
}

.location-popup .popup-header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

.location-popup .popup-header-icon svg {
  stroke: white;
}

.location-popup .popup-header-title {
  font-weight: 600;
  font-size: 1rem;
}

.location-popup .popup-body {
  padding: 1.25rem;
}

.location-popup .popup-coords-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.location-popup .coord-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.location-popup .coord-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.location-popup .coord-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  font-family: 'Monaco', 'Menlo', monospace;
}

.location-popup .popup-footer {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background-color: hsl(var(--muted));
  border-top: 1px solid hsl(var(--border));
}

.popup-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex: 1;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.popup-btn svg {
  flex-shrink: 0;
}

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

.popup-btn-primary:hover {
  background-color: hsl(221.2 83.2% 45%);
}

.popup-btn-secondary {
  background-color: white;
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
}

.popup-btn-secondary:hover {
  background-color: hsl(var(--muted));
}

.location-popup-container .mapboxgl-popup-close-button {
  font-size: 1.5rem;
  width: 32px;
  height: 32px;
  color: white;
  opacity: 0.8;
  right: 8px;
  top: 8px;
}

.location-popup-container .mapboxgl-popup-close-button:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

/* Responsive */
@media (max-width: 1024px) {
  .content-wrapper {
    flex-direction: column;
  }

  .left-panel {
    width: 100%;
    max-width: none;
    min-width: auto;
    height: auto;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid hsl(var(--border));
  }

  .right-panel {
    height: 50vh;
  }
}

@media (max-width: 640px) {
  .header {
    padding: 0 1rem;
  }

  .header-left {
    gap: 1rem;
  }

  .logo-text {
    display: none;
  }

  .nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }

  .left-panel {
    padding: 1rem;
  }

  .form-group-double {
    flex-direction: column;
    gap: 0.875rem;
  }
}
