/* ==========================================================================
   sinluz.app — Google Maps Dark Mobile UI Experience
   ========================================================================== */

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

:root {
  /* Google Maps Dark Colors */
  --g-bg-base: #121316;
  --g-surface: #1e2026;
  --g-surface-elevated: #282a33;
  --g-surface-glass: rgba(30, 32, 38, 0.82);
  --g-border: rgba(255, 255, 255, 0.1);
  --g-border-focus: rgba(255, 255, 255, 0.25);
  
  /* Status Colors */
  --status-normal: #00ff88;
  --status-normal-glow: rgba(0, 255, 136, 0.35);
  --status-fluctuacion: #ffb800;
  --status-fluctuacion-glow: rgba(255, 184, 0, 0.35);
  --status-corte: #ff2d55;
  --status-corte-glow: rgba(255, 45, 85, 0.45);
  
  /* Google Blue & Accent */
  --g-blue: #8ab4f8;
  --g-blue-bg: rgba(138, 180, 248, 0.15);
  --accent-cyan: #00d2ff;
  
  /* Text */
  --text-primary: #f1f3f4;
  --text-secondary: #9aa0a6;
  --text-muted: #5f6368;

  /* Elevation */
  --shadow-gmap: 0 4px 18px rgba(0, 0, 0, 0.45);
  --shadow-sheet: 0 -8px 28px rgba(0, 0, 0, 0.6);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-full: 9999px;
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html, body {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  background-color: var(--g-bg-base);
  font-family: var(--font-sans);
  color: var(--text-primary);
}

/* ==========================================================================
   Full Bleed Map Canvas
   ========================================================================== */

#map {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 1;
  background-color: #121316;
}

/* Leaflet touch and controls tweak */
.leaflet-control-zoom,
.leaflet-control-attribution {
  display: none !important;
}

/* ==========================================================================
   Top Google Maps Floating Search Bar & Pills
   ========================================================================== */

.gmaps-top-container {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.gmaps-search-bar {
  pointer-events: auto;
  height: 48px;
  background: var(--g-surface-elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--g-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-gmap);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
}

.search-app-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff2d55 0%, #ff9500 50%, #00ff88 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.search-app-icon svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

.gmaps-search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.92rem;
  font-family: var(--font-sans);
  outline: none;
}

.gmaps-search-bar input::placeholder {
  color: var(--text-secondary);
}

.search-live-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: rgba(0, 255, 136, 0.12);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--status-normal);
  flex-shrink: 0;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-normal);
  animation: pulse-dot 1.5s infinite;
}

/* Horizontal Filter Chips (Like Google Maps) */
.gmaps-chips-scroll {
  pointer-events: auto;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 2px 6px 2px;
}

.gmaps-chips-scroll::-webkit-scrollbar {
  display: none;
}

.g-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--g-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--g-border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  cursor: pointer;
  transition: var(--transition-fast);
}

.g-chip:active {
  transform: scale(0.95);
}

.g-chip.active {
  background: var(--g-blue-bg);
  border-color: var(--g-blue);
  color: var(--g-blue);
}

.g-chip .chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.g-chip .chip-dot.corte { background: var(--status-corte); box-shadow: 0 0 6px var(--status-corte); }
.g-chip .chip-dot.fluctuacion { background: var(--status-fluctuacion); box-shadow: 0 0 6px var(--status-fluctuacion); }
.g-chip .chip-dot.normal { background: var(--status-normal); box-shadow: 0 0 6px var(--status-normal); }

/* ==========================================================================
   Google Maps Floating Action Controls (Right Side)
   ========================================================================== */

.gmaps-fab-column {
  position: absolute;
  right: 14px;
  bottom: calc(140px + env(safe-area-inset-bottom));
  z-index: 990;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.g-circle-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--g-surface-elevated);
  backdrop-filter: blur(16px);
  border: 1px solid var(--g-border);
  box-shadow: var(--shadow-gmap);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
}

.g-circle-btn:active {
  transform: scale(0.92);
}

.g-circle-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.g-circle-btn.locate-btn {
  color: var(--g-blue);
}

.g-circle-btn.locate-btn.active {
  background: var(--g-blue);
  color: #121316;
}

/* ==========================================================================
   Main Bottom Report FAB (Google Maps Navigation Style)
   ========================================================================== */

.gmaps-bottom-fab {
  position: absolute;
  right: 14px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #ff2d55 0%, #d91b42 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 6px 22px rgba(255, 45, 85, 0.5), 0 0 14px rgba(255, 45, 85, 0.35);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.gmaps-bottom-fab:active {
  transform: scale(0.95);
}

.gmaps-bottom-fab svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* ==========================================================================
   Google Maps Draggable Bottom Sheet (3 Snap States)
   ========================================================================== */

.gmaps-bottom-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1050;
  background: var(--g-surface-elevated);
  border-top: 1px solid var(--g-border);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-sheet);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-smooth);
  will-change: transform;
  max-height: 85vh;
  max-height: 85dvh;
}

/* Snap Positions */
.gmaps-bottom-sheet.state-peek {
  transform: translateY(calc(100% - 64px - env(safe-area-inset-bottom)));
}

.gmaps-bottom-sheet.state-half {
  transform: translateY(calc(100% - 320px - env(safe-area-inset-bottom)));
}

.gmaps-bottom-sheet.state-full {
  transform: translateY(0);
}

/* Drag Handle Bar */
.sheet-drag-handle {
  width: 100%;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  flex-shrink: 0;
}

.drag-pill {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.25);
}

/* Peek Content (Always Visible Summary) */
.sheet-peek-content {
  padding: 0 18px 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  flex-shrink: 0;
}

.peek-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.peek-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 255, 136, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.peek-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
}

.peek-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.peek-badge {
  padding: 4px 10px;
  background: rgba(0, 210, 255, 0.12);
  border: 1px solid rgba(0, 210, 255, 0.3);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

/* Sheet Expandable Scrollable Body */
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 18px calc(24px + env(safe-area-inset-bottom)) 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Selected Sector Dynamic View inside Bottom Sheet */
.selected-sector-card {
  display: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--g-border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.selected-sector-card.visible {
  display: block;
}

.sec-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sec-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
}

.sec-tag {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
}

.sec-tag.corte { background: rgba(255, 45, 85, 0.2); color: var(--status-corte); border: 1px solid var(--status-corte); }
.sec-tag.fluctuacion { background: rgba(255, 184, 0, 0.2); color: var(--status-fluctuacion); border: 1px solid var(--status-fluctuacion); }
.sec-tag.normal { background: rgba(0, 255, 136, 0.2); color: var(--status-normal); border: 1px solid var(--status-normal); }

.sec-quick-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.q-stat {
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px;
  text-align: center;
}

.q-stat .q-lbl {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.q-stat .q-val {
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #fff;
  margin-top: 2px;
}

.sec-action-btns {
  display: flex;
  gap: 10px;
}

.btn-g-action {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  border: none;
}

.btn-g-action.primary {
  background: var(--g-blue);
  color: #121316;
}

.btn-g-action.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid var(--g-border);
}

/* Sectors List Summary */
.sectors-list-heading {
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.g-sector-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--g-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
}

.g-sector-item:active {
  background: rgba(255, 255, 255, 0.08);
}

.g-sec-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.g-sec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.g-sec-dot.corte { background: var(--status-corte); }
.g-sec-dot.fluctuacion { background: var(--status-fluctuacion); }
.g-sec-dot.normal { background: var(--status-normal); }

.g-sec-title {
  font-size: 0.88rem;
  font-weight: 700;
}

.g-sec-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Google Maps 1-Click Report Modal
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--g-surface-elevated);
  border-top: 1px solid var(--g-border);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom)) 20px;
  transform: translateY(100%);
  transition: transform var(--transition-smooth);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
}

.gps-status-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--g-blue-bg);
  border: 1px solid rgba(138, 180, 248, 0.3);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.gps-pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--g-blue);
  box-shadow: 0 0 10px var(--g-blue);
  animation: pulse-dot 1.5s infinite;
}

.gps-info .gps-title {
  font-size: 0.68rem;
  color: var(--g-blue);
  font-weight: 700;
  text-transform: uppercase;
}

.gps-info .gps-sector-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
}

.report-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.btn-report {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--g-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.btn-report:active {
  transform: scale(0.98);
}

.btn-report.corte {
  background: linear-gradient(90deg, rgba(255, 45, 85, 0.25) 0%, rgba(255, 45, 85, 0.05) 100%);
  border-color: rgba(255, 45, 85, 0.45);
}

.btn-report.fluctuacion {
  background: linear-gradient(90deg, rgba(255, 184, 0, 0.25) 0%, rgba(255, 184, 0, 0.05) 100%);
  border-color: rgba(255, 184, 0, 0.45);
}

.btn-report.normal {
  background: linear-gradient(90deg, rgba(0, 255, 136, 0.25) 0%, rgba(0, 255, 136, 0.05) 100%);
  border-color: rgba(0, 255, 136, 0.45);
}

.report-emoji {
  font-size: 1.4rem;
}

.report-btn-text .title {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
}

.report-btn-text .sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Toast */
.toast {
  position: fixed;
  top: calc(70px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 3000;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  background: var(--g-surface-elevated);
  border: 1px solid var(--g-border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.7);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-smooth);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast.success { border-color: var(--status-normal); }
.toast.error { border-color: var(--status-corte); }

/* Pulsating user GPS location marker in Leaflet */
.user-gps-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1a73e8;
  border: 3px solid #ffffff;
  box-shadow: 0 0 10px rgba(26, 115, 232, 0.8);
  position: relative;
}

.user-gps-marker::after {
  content: '';
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  border-radius: 50%;
  background: rgba(26, 115, 232, 0.35);
  animation: gps-wave 2s infinite;
}

@keyframes gps-wave {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ==========================================================================
   Onboarding Splash Survey (Instant 1-Tap Entry)
   ========================================================================== */

.onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(10, 11, 15, 0.88);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.onboarding-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.onboarding-card {
  width: 100%;
  max-width: 440px;
  background: var(--g-surface-elevated);
  border: 1px solid var(--g-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 210, 255, 0.2);
  padding: 28px 22px;
  text-align: center;
  transform: scale(0.92) translateY(20px);
  transition: transform var(--transition-smooth);
}

.onboarding-overlay.active .onboarding-card {
  transform: scale(1) translateY(0);
}

.onboarding-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px auto;
  border-radius: 16px;
  background: linear-gradient(135deg, #ff2d55 0%, #ff9500 50%, #00ff88 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px rgba(255, 45, 85, 0.5);
}

.onboarding-logo svg {
  width: 30px;
  height: 30px;
  fill: #fff;
}

.onboarding-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.onboarding-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 22px;
  line-height: 1.4;
}

.onboarding-gps-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--g-blue-bg);
  border: 1px solid rgba(138, 180, 248, 0.3);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--g-blue);
  margin-bottom: 20px;
}

.onboarding-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.btn-onboarding {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

.btn-onboarding:active {
  transform: scale(0.97);
}

.btn-onboarding.sin-luz {
  background: linear-gradient(135deg, #ff2d55 0%, #d91b42 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(255, 45, 85, 0.4);
}

.btn-onboarding.fluctuacion {
  background: linear-gradient(135deg, #ffb800 0%, #d97706 100%);
  color: #121316;
  box-shadow: 0 6px 20px rgba(255, 184, 0, 0.3);
}

.btn-onboarding.con-luz {
  background: linear-gradient(135deg, #00ff88 0%, #059669 100%);
  color: #121316;
  box-shadow: 0 6px 20px rgba(0, 255, 136, 0.3);
}

.btn-onboarding-skip {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 6px;
  transition: color var(--transition-fast);
}

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