/* Tema base AgroPortal (estética tipo Navixy se completa en M5) */
:root {
  --ap-bg: #f4f6f8;
  --ap-sidebar: #2b3a4a;
  --ap-accent: #1e88e5;
  --ap-text: #263238;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--ap-bg);
  color: var(--ap-text);
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #fff;
  padding: 2rem 2.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
  color: var(--ap-accent);
  text-align: center;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}
.login-card input {
  padding: 0.5rem;
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  font-size: 1rem;
}
.login-card button {
  padding: 0.6rem;
  background: var(--ap-accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
}
.login-card button:hover { filter: brightness(1.1); }
.login-card .error { color: #c62828; margin: 0; font-size: 0.9rem; }

/* Layout tipo Navixy: sidebar de íconos + topbar + contenido */
.app-shell { display: flex; height: 100vh; }

.ap-sidebar {
  width: 68px;
  flex-shrink: 0;
  background: var(--ap-sidebar);
  color: #cfd8dc;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
}
.ap-sidebar-logo { font-size: 1.6rem; margin-bottom: 1rem; }
.ap-sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; width: 100%; flex: 1; }
.ap-sidebar-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.5rem 0.25rem;
  color: #cfd8dc;
  text-decoration: none;
  font-size: 0.65rem;
  border-left: 3px solid transparent;
}
.ap-sidebar-nav a .ico { font-size: 1.25rem; }
.ap-sidebar-nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.ap-sidebar-nav a.active { background: rgba(255, 255, 255, 0.12); border-left-color: var(--ap-accent); color: #fff; }
.ap-sidebar-logout { margin-top: auto; }
.ap-sidebar-logout button {
  background: none;
  border: 1px solid #546e7a;
  color: #cfd8dc;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
}

.ap-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.ap-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}
.ap-org-select select {
  padding: 0.3rem 0.5rem;
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  font-size: 0.85rem;
}
.ap-user { margin-left: auto; font-size: 0.85rem; color: #607d8b; }

.ap-content { flex: 1; overflow: auto; }

.page { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
.page h1 { margin-top: 0; }
.ap-content > h1, .ap-content > h2, .ap-content > .ap-card, .ap-content > .ap-table, .ap-content > .ap-form, .ap-content > p {
  max-width: 1100px;
  margin-left: 1.5rem;
  margin-right: 1.5rem;
}
.ap-content > h1:first-child { margin-top: 1.25rem; }

/* Monitoreo: mapa en tiempo real + lista de vehículos */
.monitor-layout { display: flex; height: 100%; }
.vehicle-list {
  width: 280px;
  flex-shrink: 0;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid #e0e0e0;
}
.monitor-map-wrap { flex: 1; position: relative; }
.monitor-map { position: absolute; inset: 0; }

.track-panel {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
  padding: 0.5rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}
.track-panel input[type="date"] {
  padding: 0.25rem 0.4rem;
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  font-size: 0.85rem;
}
.track-panel button {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--ap-accent);
  background: #fff;
  color: var(--ap-accent);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}
.track-panel button:hover:not(:disabled) { background: var(--ap-accent); color: #fff; }
.track-panel button:disabled { opacity: 0.5; cursor: default; }

.vehicle-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid #eceff1;
  cursor: pointer;
}
.vehicle-card:hover { background: #f5f7f8; }
.vehicle-card-info { display: flex; flex-direction: column; line-height: 1.25; }
.vehicle-card-info small { color: #78909c; }
.vehicle-list .empty { padding: 1rem; color: #78909c; font-size: 0.85rem; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-trabajando { background: #2e7d32; }
.dot-transito { background: #1565c0; }
.dot-ralenti { background: #f9a825; }
.dot-detenido { background: #757575; }

.vehicle-marker-arrow {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 16px solid #757575;
}

.ap-card {
  background: #fff;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.ap-table { width: 100%; border-collapse: collapse; margin: 0.5rem 0 1rem; }
.ap-table th, .ap-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.9rem;
}
.ap-table th { color: #607d8b; font-weight: 600; }

.ap-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-bottom: 1.5rem; }
.ap-form-inline { margin: 0.75rem 0 0; }
.ap-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; color: #455a64; }
.ap-form input, .ap-form select {
  padding: 0.4rem 0.5rem;
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  font-size: 0.9rem;
}
.ap-form button {
  padding: 0.45rem 0.9rem;
  background: var(--ap-accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.ap-form button:hover { filter: brightness(1.1); }

.ap-inline-delete { display: inline-block; margin-left: 0.75rem; }
.ap-btn-danger {
  padding: 0.25rem 0.6rem;
  background: #fff;
  color: #c62828;
  border: 1px solid #c62828;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}
.ap-btn-danger:hover { background: #c62828; color: #fff; }
