:root {
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --danger: #fb7185;
  --danger-hover: #f43f5e;
  --bg-dark: #111827;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.4);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
  --text-main: #1F2937;
  --text-muted: #6B7280;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  color: var(--text-main);
  background: var(--bg-dark);
  overflow: hidden; /* Prevent scroll on main body */
}

/* Map */
#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  transition: filter 0.5s ease;
}

#map.blurred {
  filter: blur(10px) brightness(0.7);
}

/* Glassmorphism utility */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius);
}

/* Overlays */
.overlay, .modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0s, top 0s;
}

.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  top: -100%;
  transition: opacity 0.3s ease, visibility 0s 0.3s, top 0s 0.3s;
}

.login-panel {
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  transform: translateY(0);
  transition: transform 0.3s ease;
}

.hidden .login-panel {
  transform: translateY(20px);
}

h2, h3 {
  margin-top: 0;
  color: var(--text-main);
}

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

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

input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #D1D5DB;
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.2s;
  background: rgba(255,255,255,0.9);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

input[readonly] {
  background: #F3F4F6;
  color: var(--text-muted);
}

/* Buttons */
button {
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: white;
  color: var(--text-main);
  border: 1px solid #D1D5DB;
}

.btn-secondary:hover {
  background: #F9FAFB;
}

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

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

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 10px;
  min-height: 20px;
}

/* App UI Elements */
#app-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none; /* Let clicks pass through to map */
}

#app-ui > * {
  pointer-events: auto; /* Enable clicks on UI elements */
}

/* Floating Action Buttons */
.fab-container {
  position: absolute;
  bottom: 30px;
  right: 30px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.fab {
  width: 50px;
  height: 50px;
  border-radius: 25px;
  background: var(--primary);
  color: white;
  font-size: 1.2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  padding: 0;
}

.fab:hover {
  transform: scale(1.1);
  background: var(--primary-hover);
}

#fab-logout {
  background: var(--danger);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}
#fab-logout:hover {
  background: var(--danger-hover);
}

/* Side Panel (Birthdays) */
.side-panel {
  position: absolute;
  top: 20px;
  left: 20px;
  bottom: 20px;
  width: 320px;
  max-width: calc(100vw - 120px);
  transform: translateX(0);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.side-panel.hidden {
  transform: translateX(-120%);
  opacity: 0;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.close-btn {
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  padding: 0 5px;
}

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

.panel-content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Birthday Items */
.birthday-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.5);
  border-radius: 12px;
  margin-bottom: 12px;
  transition: background 0.2s;
}

.birthday-item:hover {
  background: rgba(255,255,255,0.8);
}

.bday-photo {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  object-fit: cover;
  background: #E5E7EB;
}

.bday-info {
  flex: 1;
}

.bday-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.bday-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.bday-age {
  font-weight: 700;
  color: var(--primary);
  font-size: 1.1rem;
}

/* Modals */
.modal-content {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-content.large {
  max-width: 800px;
}

.modal-content form {
  padding: 20px;
  overflow-y: auto;
}

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

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Admin Layout */
.admin-layout {
  display: flex;
  height: 60vh;
  min-height: 400px;
}

.admin-list {
  width: 250px;
  border-right: 1px solid var(--glass-border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.admin-list ul {
  list-style: none;
  padding: 0;
  margin: 0 0 15px 0;
  flex: 1;
  overflow-y: auto;
}

.admin-list li {
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 5px;
}

.admin-list li:hover, .admin-list li.active {
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  font-weight: 500;
}

.admin-edit {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.help-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* Leaflet Customizations */
.leaflet-popup-content-wrapper {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border-radius: 12px;
  box-shadow: var(--glass-shadow);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
}

.profile-popup {
  text-align: center;
  min-width: 200px;
}

.profile-popup img {
  width: 80px;
  height: 80px;
  border-radius: 40px;
  object-fit: cover;
  margin-bottom: 10px;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.profile-popup h3 {
  margin: 0 0 5px 0;
  font-size: 1.1rem;
}

.profile-popup p {
  margin: 5px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 15px;
  justify-content: center;
}

.popup-actions a {
  text-decoration: none;
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 6px;
  background: #F3F4F6;
  color: var(--text-main);
  font-weight: 500;
  transition: background 0.2s;
}

.popup-actions a:hover {
  background: #E5E7EB;
}

.popup-actions a.waze {
  color: #05C8F0;
  background: rgba(5, 200, 240, 0.1);
}
.popup-actions a.waze:hover { background: rgba(5, 200, 240, 0.2); }

.popup-actions a.maps {
  color: #34A853;
  background: rgba(52, 168, 83, 0.1);
}
.popup-actions a.maps:hover { background: rgba(52, 168, 83, 0.2); }

.custom-leaflet-icon {
  background: transparent;
  border: none;
}
