/* ============================================
   GEOPETA — CLEAN UI DESIGN
   Light: White dominant
   Dark: Black dominant
   ============================================ */

/* ===== THEME VARIABLES ===== */
:root {
  /* LIGHT MODE - White dominant */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #e8e8ed;
  --bg-glass: rgba(255, 255, 255, 0.98);
  --bg-glass-strong: rgba(255, 255, 255, 1);
  --bg-card: #ffffff;
  
  --text-primary: #000000;
  --text-secondary: #3a3a3c;
  --text-muted: #8e8e93;
  
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.2);
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  
  --accent: #007AFF;
  --accent-hover: #0056b3;
  --accent-gradient: linear-gradient(135deg, #007AFF, #5856D6);
  --danger: #FF3B30;
  --success: #34C759;
  --warning: #FF9500;
  
  --fab-bg: #ffffff;
  --fab-border: rgba(0, 0, 0, 0.1);
  --map-filter: none;
}

[data-theme="dark"] {
  /* DARK MODE - Black dominant */
  --bg-primary: #000000;
  --bg-secondary: #1c1c1e;
  --bg-tertiary: #2c2c2e;
  --bg-glass: rgba(28, 28, 30, 0.98);
  --bg-glass-strong: rgba(28, 28, 30, 1);
  --bg-card: #1c1c1e;
  
  --text-primary: #ffffff;
  --text-secondary: #ebebf0;
  --text-muted: #8e8e93;
  
  --border: rgba(255, 255, 255, 0.15);
  --border-strong: rgba(255, 255, 255, 0.25);
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  
  --accent: #0A84FF;
  --accent-hover: #409CFF;
  --accent-gradient: linear-gradient(135deg, #0A84FF, #5E5CE6);
  --danger: #FF453A;
  --success: #30D158;
  --warning: #FF9F0A;
  
  --fab-bg: #1c1c1e;
  --fab-border: rgba(255, 255, 255, 0.15);
  --map-filter: none;
}

/* ===== RESET & BASE ===== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background 0.3s ease, color 0.3s ease;
}

/* ===== MAP ===== */
#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Dark map tiles for dark theme */
[data-theme="dark"] .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.85) saturate(0.2);
}

/* Remove default Leaflet controls */
.leaflet-control-zoom,
.leaflet-control-attribution {
  display: none !important;
}

/* ===== SEARCH CONTAINER ===== */
.search-container {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 480px);
  z-index: 1000;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-glass-strong);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  transition: all 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15), var(--shadow-lg);
}

.menu-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: none;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-toggle:hover {
  background: var(--bg-tertiary);
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.95rem;
  color: var(--text-primary);
  font-family: inherit;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.search-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.02);
}

.search-btn:active {
  transform: scale(0.96);
}

/* Search Results */
.search-results {
  margin-top: 8px;
  background: var(--bg-glass-strong);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  display: none;
}

.search-results.active {
  display: block;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
  border-bottom: 1px solid var(--border);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--bg-secondary);
}

.search-result-item i {
  color: var(--accent);
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.search-result-text {
  flex: 1;
  min-width: 0;
}

.search-result-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-address {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== DRAWER (Side Menu) ===== */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: min(85%, 300px);
  height: 100%;
  background: var(--bg-primary);
  z-index: 1600;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.drawer.active {
  transform: translateX(0);
}

.drawer-header {
  padding: 24px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: white;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.user-email {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.login-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--accent);
}

.login-btn.hidden {
  display: none;
}

.drawer-menu {
  padding: 12px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 14px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
  text-align: left;
}

.menu-item:hover {
  background: var(--bg-secondary);
}

.menu-item i {
  width: 22px;
  text-align: center;
  color: var(--accent);
  font-size: 1rem;
}

.menu-item .badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 700;
}

.drawer-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 16px;
}

.drawer-footer {
  margin-top: auto;
  padding: 16px 20px;
  text-align: center;
}

.version {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ===== FLOATING ACTION BUTTONS ===== */
.fab-container {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.fab {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--fab-bg);
  border: 1px solid var(--fab-border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
  color: var(--accent);
}

.fab:active {
  transform: scale(0.95);
}

.fab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.fab-divider {
  height: 1px;
  background: var(--border-strong);
  margin: 2px 6px;
}

/* ===== INFO CARD ===== */
.info-card {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 380px);
  background: var(--bg-glass-strong);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: transform 0.3s ease;
}

.info-card.hidden {
  transform: translateX(-50%) translateY(130%);
}

.info-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.info-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 0.9rem;
}

.info-card-body {
  display: flex;
  justify-content: space-around;
  padding: 14px 16px;
}

.coord-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.coord-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
}

.coord-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ===== BOTTOM SHEET ===== */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1700;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.bottom-sheet-overlay.active {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 75vh;
  background: var(--bg-primary);
  border-radius: 20px 20px 0 0;
  z-index: 1800;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.bottom-sheet.active {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 10px auto;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 14px;
  border-bottom: 1px solid var(--border);
}

.sheet-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sheet-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.sheet-content {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

/* Settings */
.setting-group {
  margin-bottom: 16px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.setting-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
}

.setting-info i {
  width: 22px;
  text-align: center;
  color: var(--accent);
}

.setting-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

.setting-select:focus {
  border-color: var(--accent);
}

/* Toggle Switch */
.switch {
  position: relative;
  width: 48px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: var(--bg-tertiary);
  border-radius: 26px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(22px);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  padding: 12px 24px;
  background: var(--text-primary);
  color: var(--bg-primary);
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  visibility: hidden;
  z-index: 2000;
  transition: all 0.3s ease;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ===== CUSTOM MARKER ===== */
.custom-marker {
  position: relative;
}

.marker-pin {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  background: var(--accent);
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  animation: markerDrop 0.3s ease;
}

.marker-pin i {
  transform: rotate(45deg);
  color: white;
  font-size: 11px;
}

@keyframes markerDrop {
  from { transform: rotate(-45deg) translateY(-16px); opacity: 0; }
  to { transform: rotate(-45deg) translateY(0); opacity: 1; }
}

/* User location */
.user-location-marker {
  position: relative;
}

.user-dot {
  width: 18px;
  height: 18px;
  background: var(--accent);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.3);
}

.user-pulse {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: rgba(0, 122, 255, 0.25);
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ===== FIT TO SCREEN BUTTON ===== */
.fit-screen-btn {
  position: absolute;
  bottom: 80px;
  right: 16px;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--fab-bg);
  border: 1px solid var(--fab-border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.2s ease;
}

.fit-screen-btn:hover {
  transform: scale(1.05);
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .search-container {
    top: 12px;
    width: calc(100% - 20px);
  }

  .fab-container {
    right: 12px;
    gap: 8px;
  }

  .fab {
    width: 42px;
    height: 42px;
  }

  .info-card {
    bottom: 12px;
    width: calc(100% - 20px);
  }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}