:root {
  --bg-primary: #0f141c;
  --bg-secondary: #18202c;
  --bg-card: #1f2a3a;
  --border-color: #2b3a4f;
  --border: #2b3a4f;
  
  --text-main: #f0f4f8;
  --text: #f0f4f8;
  --text-muted: #94a3b8;
  
  --accent-cyan: #00e5ff;
  --cyan: #00e5ff;
  --accent-green: #00e676;   /* Radio en espera / online */
  --accent-orange: #ff9100;  /* Transmitiendo */
  --accent-red: #ff1744;     /* Alerta SOS */
  --accent-blue: #2979ff;
  
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'Chakra Petch', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* =========================================
   Barra Superior / Topbar
   ========================================= */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 20px;
  height: 60px;
}

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

.logo-icon {
  font-size: 28px;
}

.logo-text h1 {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-main);
}

.subtitle {
  font-size: 11px;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-family: var(--font-mono);
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #718096;
}

.status-indicator.online {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.status-indicator.offline {
  background-color: var(--accent-red);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.btn-action {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.clock {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(0, 229, 255, 0.08);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid rgba(0, 229, 255, 0.2);
}

/* =========================================
   Layout Principal
   ========================================= */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* =========================================
   Sidebar / Panel Lateral
   ========================================= */
.sidebar {
  width: 360px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  overflow: hidden;
  height: 100%;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
}

.card h2 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.channel-selector-wrapper select {
  width: 100%;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
}

.channel-selector-wrapper select:focus {
  border-color: var(--accent-cyan);
}

/* Botón PTT de Despacho Compacto */
.ptt-dispatch-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 4px;
}

.btn-ptt-dispatch {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, #ff5252 0%, #b71c1c 100%);
  border: 3.5px solid #ff8a80;
  box-shadow: 0 0 15px rgba(255, 82, 82, 0.4);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.btn-ptt-dispatch:active, .btn-ptt-dispatch.active {
  transform: scale(0.94);
  background: radial-gradient(circle, #00e676 0%, #1b5e20 100%);
  border-color: #69f0ae;
  box-shadow: 0 0 22px rgba(0, 230, 118, 0.7);
}

.btn-ptt-dispatch.receiving {
  background: radial-gradient(circle, #0284c7 0%, #0369a1 100%) !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.9) !important;
  animation: pulse-receiving 0.8s infinite alternate;
}

@keyframes pulse-receiving {
  0% { transform: scale(1); box-shadow: 0 0 12px rgba(56, 189, 248, 0.5); }
  100% { transform: scale(1.04); box-shadow: 0 0 25px rgba(56, 189, 248, 1); }
}

.ptt-inner-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.ptt-icon {
  font-size: 24px;
  line-height: 1;
}

.ptt-text {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  margin-top: 2px;
}

.ptt-hint {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
}

/* Flota de Radios Ampliada */
.fleet-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding: 10px 12px;
}

.fleet-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.fleet-filter input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}

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

.radio-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.radio-card:hover {
  border-color: var(--accent-cyan);
  background: #151d28;
}

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

.radio-name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: #fff;
}

.radio-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.radio-badge.idle {
  background: rgba(0, 230, 118, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(0, 230, 118, 0.3);
}

.radio-badge.tx {
  background: rgba(255, 145, 0, 0.2);
  color: var(--accent-orange);
  border: 1px solid rgba(255, 145, 0, 0.4);
  animation: pulse-orange 1s infinite alternate;
}

.radio-badge.sos {
  background: rgba(255, 23, 68, 0.3);
  color: #fff;
  border: 1px solid var(--accent-red);
  animation: pulse-red 0.5s infinite alternate;
}

.radio-badge.suspended {
  background: rgba(255, 23, 68, 0.2);
  color: #ff5252;
  border: 1px solid rgba(255, 23, 68, 0.5);
}

.radio-badge.offline {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.radio-card.suspended {
  opacity: 0.7;
  border-left: 3px solid #ff1744;
}

.btn-history {
  display: inline-block;
  margin-top: 6px;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: var(--accent-cyan);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-history:hover {
  background: rgba(0, 229, 255, 0.25);
  color: #fff;
}

.radio-card-body {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.radio-channel {
  color: var(--accent-cyan);
}

.radio-battery {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* =========================================
   Área de Contenido / Mapa
   ========================================= */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.sos-banner {
  background: linear-gradient(90deg, #b71c1c, #d50000);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  animation: blink-bg 1s infinite alternate;
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(255, 23, 68, 0.4);
}

.sos-banner.hidden {
  display: none;
}

.sos-icon {
  font-size: 26px;
}

.sos-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.sos-info strong {
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 1px;
}

.sos-actions {
  display: flex;
  gap: 10px;
}

.btn-sos-locate {
  background: #fff;
  color: #b71c1c;
  border: none;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-sos-dismiss {
  background: rgba(0,0,0,0.3);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
}

/* Mapa */
.map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background: #111;
}

.map-overlay-controls {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 999;
  display: flex;
  gap: 8px;
}

.btn-overlay {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: all 0.2s;
}

.btn-overlay:hover {
  background: var(--border-color);
  color: var(--accent-cyan);
}

/* Panel de Registro Inferior */
.event-log-panel {
  height: 140px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 8px 15px;
}

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

.log-header h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
  letter-spacing: 1px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
}

.btn-text:hover {
  color: #fff;
}

.log-list {
  flex: 1;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-item {
  display: flex;
  gap: 12px;
  padding: 2px 0;
}

.log-time {
  color: var(--text-muted);
}

.log-item.info .log-msg { color: #81d4fa; }
.log-item.tx .log-msg { color: var(--accent-orange); }
.log-item.sos .log-msg { color: var(--accent-red); font-weight: 700; }

/* Animaciones */
@keyframes pulse-orange {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.05); opacity: 1; }
}

@keyframes pulse-red {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

@keyframes blink-bg {
  0% { background: #b71c1c; }
  100% { background: #d50000; }
}

.leaflet-radio-icon {
  background: transparent !important;
  border: none !important;
}
