/* 
   Cundinamarca Map - Premium Style System
   Theme: Andean Emerald & Deep Glassmorphism
   Fonts: Outfit (Headings), Inter (Body)
*/

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

:root {
  /* Color Palette - Custom HSL */
  --bg-primary: #0b0f19;
  --bg-surface: rgba(17, 24, 39, 0.7);
  --bg-surface-solid: #111827;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.5);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --primary: #10b981; /* Emerald */
  --primary-glow: rgba(16, 185, 129, 0.35);
  --primary-hover: #059669;
  
  --secondary: #06b6d4; /* Cyan / Lagoon */
  --secondary-glow: rgba(6, 182, 212, 0.3);
  
  --accent: #f59e0b; /* Amber */
  --danger: #ef4444; /* Rose */
  --success: #10b981;
  
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.2);
}

/* Global Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Glassmorphism Class Utility */
.glass {
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Application Layout */
header {
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  z-index: 10;
  border-bottom: 1px solid var(--border-color);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--primary-glow) 0 0 15px;
}

.logo-icon svg {
  fill: #fff;
  width: 22px;
  height: 22px;
}

.logo-text h1 {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(to right, #ffffff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--primary);
  font-weight: 700;
  display: block;
}

nav {
  display: flex;
  gap: 8px;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  padding: 8px 16px;
  font-size: 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition-fast);
}

.nav-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary);
  border-color: rgba(16, 185, 129, 0.2);
}

/* Main Workspace */
.app-container {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Map Styling */
#map {
  flex: 1;
  height: 100%;
  width: 100%;
  z-index: 1;
  background-color: var(--bg-primary);
}

/* Leaflet Customizations to match Dark Premium Theme */
.leaflet-container {
  background: var(--bg-primary) !important;
  font-family: var(--font-body) !important;
}

.leaflet-bar {
  border: 1px solid var(--border-color) !important;
  box-shadow: var(--shadow-lg) !important;
}

.leaflet-bar a {
  background-color: var(--bg-surface-solid) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border-color) !important;
  transition: var(--transition-fast) !important;
}

.leaflet-bar a:hover {
  background-color: var(--primary) !important;
  color: white !important;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-surface-solid) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
  border-radius: 12px !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 4px !important;
}

.leaflet-popup-tip {
  background: var(--bg-surface-solid) !important;
  border-left: 1px solid var(--border-color) !important;
  border-bottom: 1px solid var(--border-color) !important;
}

/* Sidebar / Controls overlay */
.sidebar {
  width: 380px;
  position: absolute;
  top: 20px;
  left: 20px;
  bottom: 20px;
  z-index: 5;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--transition-normal);
}

.sidebar.collapsed {
  transform: translateX(-400px);
}

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

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

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Toggle buttons */
.toggle-sidebar-btn {
  position: absolute;
  left: 20px;
  top: 20px;
  z-index: 4;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  transition: var(--transition-fast);
}

.toggle-sidebar-btn:hover {
  background: var(--primary);
  box-shadow: var(--primary-glow) 0 0 10px;
}

/* Search and Filters */
.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 12px 16px 12px 42px;
  border-radius: 10px;
  color: white;
  font-family: var(--font-body);
  outline: none;
  transition: var(--transition-fast);
}

.search-box input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  fill: var(--text-secondary);
  width: 18px;
  height: 18px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.filter-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: white;
  padding: 12px 16px;
  border-radius: 10px;
  font-family: var(--font-body);
  outline: none;
  cursor: pointer;
  transition: var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%239ca3af'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
}

.filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.filter-select option {
  background-color: var(--bg-surface-solid);
  color: white;
}

/* List items styling */
.location-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.location-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.location-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.location-card.selected {
  background: rgba(16, 185, 129, 0.08);
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.location-card h3 {
  font-size: 0.95rem;
  color: white;
  font-family: var(--font-heading);
}

.location-card .municipio-tag {
  font-size: 0.75rem;
  background: rgba(6, 182, 212, 0.15);
  color: var(--secondary);
  padding: 2px 8px;
  border-radius: 4px;
  align-self: flex-start;
  font-weight: 600;
}

.location-card .type-tag {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.no-results {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Detail Card Overlay */
.detail-overlay {
  position: absolute;
  right: 20px;
  top: 20px;
  bottom: 20px;
  width: 420px;
  z-index: 5;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(450px);
  transition: transform var(--transition-normal);
}

.detail-overlay.active {
  transform: translateX(0);
}

.detail-image {
  width: 100%;
  height: 200px;
  background-size: cover;
  background-position: center;
  position: relative;
  background-color: rgba(255, 255, 255, 0.05);
}

.detail-image-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.1));
  color: var(--primary);
  font-family: var(--font-heading);
  gap: 8px;
}

.detail-image-fallback svg {
  width: 48px;
  height: 48px;
  fill: currentColor;
}

.detail-header {
  padding: 1.5rem;
  position: relative;
  border-bottom: 1px solid var(--border-color);
}

.close-detail-btn {
  position: absolute;
  right: 1.5rem;
  top: 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  transition: var(--transition-fast);
}

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

.detail-tags {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.detail-header h2 {
  font-size: 1.5rem;
  line-height: 1.2;
  margin-bottom: 4px;
}

.detail-municipio {
  color: var(--secondary);
  font-weight: 600;
  font-size: 0.9rem;
}

.detail-body {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.detail-description {
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 0.95rem;
}

.detail-meta-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 8px;
}

.detail-meta-item svg {
  width: 18px;
  height: 18px;
  fill: var(--primary);
  flex-shrink: 0;
}

.detail-meta-item div {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.detail-meta-item span {
  font-weight: 500;
  color: var(--text-primary);
  display: block;
}

/* Admin Dashboard layout */
.admin-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  gap: 1.5rem;
  overflow-y: auto;
}

.admin-main-section {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1.5rem;
  height: 520px;
}

@media (max-width: 1024px) {
  .admin-main-section {
    grid-template-columns: 1fr;
    height: auto;
  }
  .admin-main-section #map {
    height: 400px;
  }
}

.admin-map-container {
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border-color);
}

.map-helper-tip {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 6px 16px;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 500;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-lg);
}

.admin-form-panel {
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  height: 100%;
  overflow-y: auto;
}

.admin-form-panel h2 {
  font-size: 1.3rem;
  color: white;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: span 2;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.form-group input, .form-group textarea, .form-group select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  font-family: var(--font-body);
  outline: none;
  transition: var(--transition-fast);
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.07);
}

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

.btn-row {
  display: flex;
  gap: 12px;
  margin-top: auto;
}

.btn {
  flex: 1;
  padding: 12px 20px;
  border-radius: 8px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  box-shadow: var(--primary-glow) 0 4px 14px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--primary-glow) 0 6px 20px;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

/* Database Table Section */
.admin-table-section {
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.table-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-header-row h2 {
  font-size: 1.3rem;
}

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

.table-container {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 16px;
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

.table-actions-cell {
  display: flex;
  gap: 6px;
}

.action-icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition-fast);
}

.action-icon-btn:hover {
  color: white;
}

.action-icon-btn.edit:hover {
  background: var(--primary);
  border-color: var(--primary);
}

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

.action-icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Custom Marker Styling in Leaflet */
.custom-marker {
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-pin {
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  background: var(--primary);
  position: absolute;
  transform: rotate(-45deg);
  left: 50%;
  top: 50%;
  margin: -15px 0 0 -15px;
  box-shadow: 0 0 10px var(--primary-glow);
  border: 2px solid white;
  transition: var(--transition-fast);
}

.marker-pin::after {
  content: '';
  width: 14px;
  height: 14px;
  margin: 6px 0 0 6px;
  background: #0b0f19;
  position: absolute;
  border-radius: 50%;
}

.custom-marker:hover .marker-pin {
  background: var(--secondary);
  transform: rotate(-45deg) scale(1.15);
  box-shadow: 0 0 15px var(--secondary-glow);
}

.marker-shadow {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  width: 12px;
  height: 4px;
  position: absolute;
  bottom: -2px;
  left: 50%;
  margin-left: -6px;
  filter: blur(1px);
}

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

.toast {
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-color);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.info {
  border-left: 4px solid var(--secondary);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
