/* GPS Transportes Bahamonde — Estilos */

:root {
  --color-primary:  #1a3a5c;
  --color-accent:   #e67e22;
  --color-moving:   #27ae60;
  --color-stopped:  #f39c12;
  --color-offline:  #e74c3c;
  --color-apagado:  #7f8c8d;
  --sidebar-width:  320px;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0f1923;
  color: #ecf0f1;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Navbar ─────────────────────────────────────────────── */
.navbar-gps {
  background: var(--color-primary);
  padding: 0 1rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 2px solid var(--color-accent);
  flex-shrink: 0;
  z-index: 1000;
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: .5rem;
  white-space: nowrap;
}

.navbar-brand span { color: var(--color-accent); }

.navbar-gps .ms-auto { margin-left: auto; }

.btn-nav {
  background: rgba(255,255,255,.12);
  border: none;
  color: #fff;
  padding: .35rem .8rem;
  border-radius: 6px;
  font-size: .85rem;
  cursor: pointer;
  transition: background .2s;
  display: flex;
  align-items: center;
  gap: .4rem;
  text-decoration: none;
}

.btn-nav:hover { background: rgba(255,255,255,.22); color: #fff; }

.badge-alerta {
  background: var(--color-offline);
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: .75rem;
  font-weight: 700;
}

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

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: #132030;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1e3448;
  flex-shrink: 0;
  transition: width .3s;
}

.sidebar-header {
  padding: .8rem 1rem;
  border-bottom: 1px solid #1e3448;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.sidebar-title {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #7f9bb3;
  font-weight: 600;
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  background: #0f1923;
  border: 1px solid #1e3448;
  border-radius: 6px;
  color: #ecf0f1;
  padding: .45rem .8rem .45rem 2.2rem;
  font-size: .875rem;
  outline: none;
  transition: border-color .2s;
}

.search-box input:focus { border-color: var(--color-accent); }

.search-box .icon {
  position: absolute;
  left: .65rem;
  top: 50%;
  transform: translateY(-50%);
  color: #7f9bb3;
  font-size: .85rem;
}

/* Filtros estado */
.filter-tabs {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
}

.filter-tab {
  font-size: .72rem;
  padding: .2rem .55rem;
  border-radius: 20px;
  border: 1px solid #1e3448;
  background: transparent;
  color: #7f9bb3;
  cursor: pointer;
  transition: all .2s;
}

.filter-tab.active, .filter-tab:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-accent);
}

/* Lista de camiones */
.camion-list {
  flex: 1;
  overflow-y: auto;
  padding: .5rem;
}

.camion-list::-webkit-scrollbar { width: 4px; }
.camion-list::-webkit-scrollbar-track { background: transparent; }
.camion-list::-webkit-scrollbar-thumb { background: #1e3448; border-radius: 2px; }

.camion-card {
  background: #0f1923;
  border: 1px solid #1e3448;
  border-left: 4px solid #1e3448;
  border-radius: 6px;
  padding: .65rem .8rem;
  margin-bottom: .4rem;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: .7rem;
}

.camion-card:hover { border-color: var(--color-accent); background: #132030; }
.camion-card.activo { border-color: var(--color-accent); background: #1a2d40; }

.camion-card.estado-movimiento { border-left-color: var(--color-moving); }
.camion-card.estado-detenido   { border-left-color: var(--color-stopped); }
.camion-card.estado-offline    { border-left-color: var(--color-offline); }
.camion-card.estado-apagado    { border-left-color: var(--color-apagado); }

.camion-icon {
  font-size: 1.4rem;
  width: 2rem;
  text-align: center;
  flex-shrink: 0;
}

.camion-info { flex: 1; min-width: 0; }

.camion-nombre {
  font-weight: 600;
  font-size: .875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.camion-patente {
  font-size: .75rem;
  color: #7f9bb3;
  font-family: monospace;
}

.camion-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .15rem;
  font-size: .72rem;
  flex-shrink: 0;
}

.estado-badge {
  padding: .15rem .45rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: .68rem;
  text-transform: uppercase;
}

.badge-movimiento { background: #1d5c38; color: #2ecc71; }
.badge-detenido   { background: #5c3d0a; color: #f39c12; }
.badge-offline    { background: #5c1a1a; color: #e74c3c; }
.badge-apagado    { background: #2a2a2a; color: #7f8c8d; }

.velocidad-txt { color: #7f9bb3; }

/* Contador en sidebar */
.sidebar-footer {
  padding: .6rem 1rem;
  border-top: 1px solid #1e3448;
  font-size: .75rem;
  color: #7f9bb3;
  display: flex;
  justify-content: space-between;
}

/* ── Mapa ────────────────────────────────────────────────── */
#mapa {
  flex: 1;
  height: 100%;
}

/* ── Panel detalle camión (popup lateral) ───────────────── */
.panel-detalle {
  position: absolute;
  right: 1rem;
  top: 4rem;
  width: 280px;
  background: #132030;
  border: 1px solid var(--color-accent);
  border-radius: 10px;
  padding: 1rem;
  z-index: 900;
  display: none;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}

.panel-detalle.visible { display: block; }

.panel-detalle h3 {
  font-size: .95rem;
  margin-bottom: .6rem;
  color: var(--color-accent);
}

.detalle-row {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  padding: .25rem 0;
  border-bottom: 1px solid #1e3448;
}

.detalle-row:last-child { border-bottom: none; }
.detalle-label { color: #7f9bb3; }
.detalle-valor { font-weight: 600; color: #ecf0f1; }

.btn-detalle {
  display: block;
  width: 100%;
  margin-top: .7rem;
  padding: .4rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: .8rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.btn-detalle:hover { background: #d35400; color: #fff; }
.btn-cerrar-panel {
  float: right;
  background: none;
  border: none;
  color: #7f9bb3;
  cursor: pointer;
  font-size: 1rem;
}

/* ── Barra de estado inferior ───────────────────────────── */
.statusbar {
  background: #0a1420;
  border-top: 1px solid #1e3448;
  padding: .3rem 1rem;
  font-size: .72rem;
  color: #7f9bb3;
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-shrink: 0;
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: .3rem;
}
.dot-ok      { background: var(--color-moving); }
.dot-warning { background: var(--color-stopped); }
.dot-error   { background: var(--color-offline); }

/* ── Marcador personalizado en Leaflet ───────────────────── */
.marker-camion {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255,255,255,.4);
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}

.marker-camion .inner { transform: rotate(45deg); }

.marker-movimiento { background: var(--color-moving); }
.marker-detenido   { background: var(--color-stopped); }
.marker-offline    { background: var(--color-offline); }
.marker-apagado    { background: var(--color-apagado); }

/* ── Modal historial / KMZ ────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.visible { display: flex; }

.modal-box {
  background: #132030;
  border: 1px solid var(--color-accent);
  border-radius: 12px;
  padding: 1.5rem;
  width: 420px;
  max-width: 95vw;
}

.modal-box h2 { font-size: 1rem; margin-bottom: 1rem; color: var(--color-accent); }

.form-group { margin-bottom: .8rem; }
.form-group label { display: block; font-size: .8rem; color: #7f9bb3; margin-bottom: .3rem; }
.form-group input[type=date] {
  width: 100%;
  background: #0f1923;
  border: 1px solid #1e3448;
  border-radius: 6px;
  color: #ecf0f1;
  padding: .45rem .8rem;
  font-size: .875rem;
}

.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.btn-primary { background: var(--color-accent); color: #fff; border: none; padding: .5rem 1.2rem; border-radius: 6px; cursor: pointer; font-size: .85rem; }
.btn-secondary { background: #1e3448; color: #ecf0f1; border: none; padding: .5rem 1.2rem; border-radius: 6px; cursor: pointer; font-size: .85rem; }

/* ── Animación pulso para marcadores en movimiento ─────── */
@keyframes pulso {
  0%, 100% { box-shadow: 0 2px 8px rgba(39,174,96,.4); }
  50%       { box-shadow: 0 2px 20px rgba(39,174,96,.8); }
}
.marker-movimiento { animation: pulso 2s infinite; }

/* ── Responsive básico ────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: 220px; border-right: none; border-bottom: 1px solid #1e3448; }
  .main-layout { flex-direction: column; }
  #mapa { min-height: calc(100vh - 52px - 220px - 24px); }
  .panel-detalle { width: calc(100% - 2rem); right: 1rem; }
}
