/* ============================================================
   Sistema de Alertamiento Carretero — Centro de Mando
   Dark-mode command center with glassmorphism design
   ============================================================ */

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border-glass: rgba(255, 255, 255, 0.08);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-red: #ef4444;
  --accent-orange: #f97316;
  --accent-blue: #3b82f6;
  --accent-yellow: #eab308;
  --accent-green: #22c55e;
  --accent-purple: #a855f7;
  --accent-cyan: #06b6d4;
  --shadow-glow: 0 0 30px rgba(6, 182, 212, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* ── Header ───────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-glass);
  backdrop-filter: blur(20px);
  z-index: 1000;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-icon {
  font-size: 28px;
  line-height: 1;
}

.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.4) drop-shadow(0 0 8px rgba(239, 68, 68, 0.6)); }
}

.header-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-yellow);
  transition: var(--transition);
}

.status-dot.connected {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  animation: dotPulse 2s infinite;
}

.status-dot.disconnected {
  background: var(--accent-red);
}

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

/* ── Main Layout ─────────────────────────────────────── */
.main-layout {
  display: flex;
  height: calc(100vh - 65px);
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 300px;
  min-width: 300px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-glass);
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 4px;
}

/* ── Stats Grid ──────────────────────────────────────── */
.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  transition: var(--transition);
}

.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.stat-total { border-left: 3px solid var(--accent-cyan); }
.stat-app { border-left: 3px solid var(--accent-green); }
.stat-twitter { border-left: 3px solid var(--accent-blue); }

.stat-icon {
  font-size: 22px;
  line-height: 1;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* ── Legend Card ─────────────────────────────────────── */
.legend-card, .activity-card {
  padding: 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
}

.legend-title, .activity-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Activity Card ───────────────────────────────────── */
.activity-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.activity-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.activity-list::-webkit-scrollbar {
  width: 3px;
}

.activity-list::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 3px;
}

.activity-empty {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--accent-cyan);
  font-size: 12px;
  animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.activity-item-icon {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1.4;
}

.activity-item-text {
  color: var(--text-secondary);
  line-height: 1.4;
}

.activity-item-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Test Button ─────────────────────────────────────── */
.btn-test {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--radius);
  color: var(--accent-cyan);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.02em;
}

.btn-test:hover {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.25), rgba(168, 85, 247, 0.25));
  border-color: rgba(6, 182, 212, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.2);
}

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

/* ── Map ─────────────────────────────────────────────── */
.map-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.map-container {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Override Leaflet tile background for dark mode */
.leaflet-container {
  background: #1a1d2e !important;
}

/* Custom Leaflet popup */
.leaflet-popup-content-wrapper {
  background: rgba(17, 24, 39, 0.95) !important;
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
  color: var(--text-primary) !important;
}

.leaflet-popup-tip {
  background: rgba(17, 24, 39, 0.95) !important;
  border: 1px solid var(--border-glass) !important;
}

.leaflet-popup-content {
  margin: 14px 16px !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 13px;
  line-height: 1.5;
}

.popup-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-glass);
}

.popup-icon {
  font-size: 20px;
}

.popup-title {
  font-weight: 700;
  font-size: 14px;
  text-transform: capitalize;
}

.popup-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 10px;
  margin-left: auto;
}

.popup-badge.app {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.popup-badge.twitter {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.popup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.popup-row-label {
  color: var(--text-muted);
  font-weight: 500;
}

.popup-photo {
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  border: 1px solid var(--border-glass);
}

.popup-description {
  margin-top: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Toast Notifications ─────────────────────────────── */
.toast-container {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: rgba(17, 24, 39, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-left: 3px solid var(--accent-cyan);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.5s cubic-bezier(0.22, 1, 0.36, 1),
             toastOut 0.4s ease-in forwards;
  animation-delay: 0s, 4s;
  pointer-events: auto;
}

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

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

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

/* ── Custom Marker Styles ────────────────────────────── */
.marker-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  border: 2px solid rgba(255,255,255,0.3);
  transition: transform 0.3s ease;
}

.marker-pin:hover {
  transform: rotate(-45deg) scale(1.2);
}

.marker-pin-inner {
  transform: rotate(45deg);
  font-size: 16px;
  line-height: 1;
}

.marker-new {
  animation: markerBounce 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes markerBounce {
  0% { transform: rotate(-45deg) scale(0); }
  60% { transform: rotate(-45deg) scale(1.3); }
  100% { transform: rotate(-45deg) scale(1); }
}

.marker-pulse-ring {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: markerPulseRing 2s ease-out infinite;
  opacity: 0;
}

@keyframes markerPulseRing {
  0% { width: 36px; height: 36px; opacity: 0.6; }
  100% { width: 80px; height: 80px; opacity: 0; }
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .header-subtitle {
    display: none;
  }

  .header-title {
    font-size: 15px;
  }
}
