/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #4285f4;
  --primary-hover: #3367d6;
  --secondary-color: #5f6368;
  --danger-color: #ea4335;
  --success-color: #34a853;
  --warning-color: #fbbc04;
  --border-color: #dadce0;
  --bg-light: #f8f9fa;
  --bg-white: #ffffff;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.15);
  --sidebar-width: 320px;
  --z-modal: 1000;
  --z-toast: 2000;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-white);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 500;
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

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

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-header h1 i {
  color: var(--primary-color);
}

#toggleSidebar {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.2s;
}

#toggleSidebar:hover {
  background: var(--bg-light);
}

/* Maps List */
.maps-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}

.section-header h2, .section-header h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.maps-list-content {
  flex: 1;
  overflow-y: auto;
}

.map-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.2s;
}

.map-item:hover {
  background: var(--bg-light);
}

.map-item.active {
  background: #e8f0fe;
  border-left-color: var(--primary-color);
}

.map-item-icon {
  width: 36px;
  height: 36px;
  background: var(--primary-color);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
}

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

.map-item-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-item-description {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Layers Panel */
.layers-panel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.layers-panel.hidden {
  display: none;
}

.map-actions {
  display: flex;
  gap: 8px;
}

.layers-header {
  border-top: 1px solid var(--border-color);
}

.layers-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.layer-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.layer-item:hover {
  background: var(--bg-light);
}

.layer-item.active {
  background: #e8f0fe;
}

.layer-visibility {
  cursor: pointer;
  padding: 8px;
  margin-right: 8px;
  border-radius: 50%;
  transition: background 0.2s;
}

.layer-visibility:hover {
  background: rgba(0, 0, 0, 0.05);
}

.layer-visibility.hidden-layer i {
  color: var(--text-secondary);
  opacity: 0.4;
}

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

.layer-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-description {
  font-size: 12px;
  color: var(--text-secondary);
}

.layer-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.layer-item:hover .layer-actions {
  opacity: 1;
}

.map-info {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.map-title-input {
  width: 100%;
  font-size: 18px;
  font-weight: 500;
  border: none;
  padding: 4px 0;
  margin-bottom: 8px;
}

.map-title-input:focus {
  outline: none;
  border-bottom: 2px solid var(--primary-color);
}

.map-description-input {
  width: 100%;
  border: none;
  resize: none;
  font-size: 13px;
  color: var(--text-secondary);
  font-family: inherit;
  min-height: 40px;
}

.map-description-input:focus {
  outline: none;
}

.base-layer-selector {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.base-layer-selector label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.base-layer-selector select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: white;
}

.import-export {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

/* Map Container */
.map-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.map {
  flex: 1;
  width: 100%;
  height: 100%;
}

/* Search */
.search-container {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 400;
  width: 320px;
}

.search-box {
  display: flex;
  align-items: center;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  gap: 12px;
}

.search-box i {
  color: var(--text-secondary);
}

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 8px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
}

.search-results.hidden {
  display: none;
}

.search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
}

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

.search-result-item:hover {
  background: var(--bg-light);
}

.search-result-name {
  font-weight: 500;
  margin-bottom: 4px;
}

.search-result-address {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Map Controls Right */
.map-controls-right {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 400;
}

.map-control-btn {
  width: 40px;
  height: 40px;
  background: white;
  border: none;
  border-radius: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.map-control-btn:hover {
  background: var(--bg-light);
  color: var(--primary-color);
}

.map-control-btn.active {
  background: var(--primary-color);
  color: white;
}

/* Map Info Bar */
.map-info-bar {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 16px;
  z-index: 400;
}

.coordinates, .zoom-level {
  background: white;
  padding: 8px 12px;
  border-radius: 4px;
  box-shadow: var(--shadow);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.coordinates i, .zoom-level i {
  color: var(--text-secondary);
}

/* Buttons */
.btn-primary {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

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

.btn-secondary {
  background: white;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

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

.btn-icon {
  width: 36px;
  height: 36px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-light);
  border-color: var(--text-secondary);
}

.btn-icon.danger:hover {
  background: #feeceb;
  border-color: var(--danger-color);
  color: var(--danger-color);
}

.btn-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.2s;
}

.btn-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

.btn-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
}

.btn-clear:hover {
  color: var(--text-primary);
}

.btn-full {
  flex: 1;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 500;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

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

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

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

.help-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.share-link-box {
  display: flex;
  gap: 8px;
}

.share-link-box .form-input {
  flex: 1;
}

.input-with-button {
  display: flex;
  gap: 8px;
}

.input-with-button .form-input {
  flex: 1;
}

/* Custom Properties */
.custom-properties {
  margin-bottom: 12px;
}

.property-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.property-row input:first-child {
  flex: 1;
}

.property-row input:last-child {
  flex: 2;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #323232;
  color: white;
  padding: 12px 24px;
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

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

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

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

.toast.info {
  background: var(--primary-color);
}

/* Leaflet Overrides */
.leaflet-control-zoom {
  border: none;
  box-shadow: var(--shadow);
}

.leaflet-control-zoom a {
  background: white;
  border: none;
  color: var(--text-secondary);
}

.leaflet-control-zoom a:hover {
  color: var(--primary-color);
}

.leaflet-draw-toolbar a {
  background-color: white;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  margin-bottom: 16px;
}

/* Layer Styles */
.marker-default .leaflet-marker-icon {
  filter: hue-rotate(0deg);
}

.marker-red .leaflet-marker-icon {
  filter: hue-rotate(0deg) saturate(2);
}

.marker-blue .leaflet-marker-icon {
  filter: hue-rotate(200deg) saturate(2);
}

.marker-green .leaflet-marker-icon {
  filter: hue-rotate(100deg) saturate(2);
}

.marker-purple .leaflet-marker-icon {
  filter: hue-rotate(280deg) saturate(2);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: var(--sidebar-width);
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .search-container {
    width: calc(100% - 32px);
  }

  .map-controls-right {
    top: auto;
    bottom: 60px;
  }

  .map-info-bar {
    flex-direction: column;
    gap: 8px;
  }
}

/* POI Marker Styles */
.poi-marker-container {
  position: relative;
}

.poi-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.poi-marker-icon {
  width: 32px !important;
  height: 32px !important;
  margin-left: -16px !important;
  margin-top: -32px !important;
  font-size: 24px;
  color: #4285f4;
  filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.3));
  cursor: pointer;
  transition: transform 0.3s ease;
  position: relative;
  z-index: 10;
}

.poi-marker-icon:hover {
  transform: scale(1.15);
}

/* Custom white dot in the marker */
.poi-marker-icon::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: inset 0 0 2px rgba(0,0,0,0.1);
}

/* GPS pulsing ring effect */
.poi-marker::before {
  content: '';
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(66, 133, 244, 0.2);
  animation: gps-pulse 2s ease-out infinite;
  z-index: 1;
}

.poi-marker::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(66, 133, 244, 0.3);
  animation: gps-pulse 2s ease-out infinite 0.5s;
  z-index: 2;
}

@keyframes gps-pulse {
  0% {
    transform: scale(0.5);
    opacity: 1;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* POI Label */
.poi-label {
  background: white;
  border: 2px solid #4285f4;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  pointer-events: none;
  margin-top: 4px;
}

.poi-label-wrapper {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
}

/* ATM POI Multi-line Label */
.poi-label-multi {
  background: white;
  border: 2px solid #FF8C00;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 8px;
  color: #333;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  pointer-events: none;
  text-align: center;
  min-width: 60px;
  transform: scale(0.5);
  transform-origin: bottom center;
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0.8;
}

.poi-label-top {
  font-weight: 700;
  font-size: 9px;
  color: #FF8C00;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 1px;
  margin-bottom: 1px;
}

.poi-label-middle {
  font-weight: 500;
  font-size: 8px;
  color: #333;
  padding: 1px 0;
}

.poi-label-bottom {
  font-weight: 400;
  font-size: 7px;
  color: #666;
  border-top: 1px solid #e0e0e0;
  padding-top: 1px;
  margin-top: 1px;
}

.poi-label-fe {
  font-weight: 400;
  font-size: 6px;
  color: #999;
  border-top: 1px solid #e0e0e0;
  padding-top: 1px;
  margin-top: 1px;
  font-style: italic;
}

/* ATM Marker Container */
.poi-marker-atm .poi-label-wrapper {
  top: -40px;
  transition: top 0.3s ease;
}

.poi-marker-atm .poi-marker-icon {
  color: #FF8C00 !important;
}

/* Hover effect - zoom in label 3x */
.poi-marker-atm:hover .poi-label-wrapper {
  top: -80px;
}

.poi-marker-atm:hover .poi-label-multi {
  transform: scale(1.5);
  opacity: 1;
}

/* Custom marker for POI */
.custom-poi-marker {
  background: #ea4335;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  width: 24px;
  height: 24px;
  cursor: pointer;
}

.custom-poi-marker:hover {
  background: #d93025;
  transform: scale(1.1);
}

/* Tooltip for POI */
.leaflet-tooltip.poi-tooltip {
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #4285f4;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.leaflet-tooltip-top:before {
  border-top-color: #4285f4;
}

.leaflet-tooltip-bottom:before {
  border-bottom-color: #4285f4;
}

.leaflet-tooltip-left:before {
  border-left-color: #4285f4;
}

.leaflet-tooltip-right:before {
  border-right-color: #4285f4;
}

/* POI list item highlighting */
.poi-highlight {
  animation: pulse 1s ease-in-out;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
