/* ============================================================
   BAP2026 — Estilos principales  (mobile-first)
   ============================================================ */

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

:root {
  --primary:      #1a73e8;
  --primary-dark: #1558b0;
  --danger:       #d32f2f;
  --danger-light: #ffebee;
  --warning:      #f57c00;
  --success:      #2e7d32;
  --bg:           #f5f6fa;
  --surface:      #ffffff;
  --border:       #e0e0e0;
  --text:         #212121;
  --text-secondary: #616161;
  --sidebar-w:    240px;
  --header-h:     56px;
  --radius:       8px;
  --shadow:       0 1px 4px rgba(0,0,0,.12);
  --shadow-md:    0 4px 12px rgba(0,0,0,.15);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

button { cursor: pointer; font-family: inherit; }

/* ── Layout ───────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #1e2a3a;
  color: #e0e6f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transform: translateX(-100%);
  transition: transform .25s ease;
}
.sidebar.open { transform: translateX(0); }

.sidebar-logo {
  padding: 18px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .5px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #b0bec5;
  font-size: .9375rem;
  transition: background .15s, color .15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
}
.nav-item.active { border-left: 3px solid var(--primary); }
.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
}
.nav-section-title {
  padding: 16px 20px 4px;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #546e7a;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem;
  color: #78909c;
}
.sidebar-footer .operador-name { color: #e0e6f0; font-weight: 600; }

/* ── Header ───────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 90;
  box-shadow: var(--shadow);
}
.btn-menu {
  background: none; border: none;
  padding: 6px; border-radius: 6px;
  color: var(--text-secondary);
  font-size: 1.3rem;
  line-height: 1;
}
.btn-menu:hover { background: var(--bg); }

.header-title { font-size: 1rem; font-weight: 600; flex: 1; }

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

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-top: var(--header-h);
  padding: 20px 16px;
  min-width: 0;
}

/* ── Overlay ──────────────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}
.overlay.visible { display: block; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
}
.card-title { font-size: 1rem; font-weight: 600; }

/* ── Stats strip ──────────────────────────────────────────── */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-secondary); margin-top: 4px; }
.stat-card.danger  .stat-value { color: var(--danger); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.success .stat-value { color: var(--success); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-success   { background: var(--success);  color: #fff; }
.btn-outline   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 5px; color: var(--text-secondary); }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .95rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,.12); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-secondary);
  white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafa; }

/* ── Badges / Pills ───────────────────────────────────────── */
.badge-pill {
  display: inline-flex; align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-danger  { background: var(--danger-light); color: var(--danger); }
.badge-success { background: #e8f5e9; color: var(--success); }
.badge-warning { background: #fff3e0; color: var(--warning); }
.badge-info    { background: #e3f2fd; color: #1565c0; }

/* ── Alarm list item ──────────────────────────────────────── */
.alarm-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border-left: 4px solid var(--danger);
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  animation: slideIn .2s ease;
}
.alarm-item.atendida { border-left-color: var(--border); opacity: .65; }
.alarm-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--danger-light);
  color: var(--danger);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.alarm-item.atendida .alarm-icon { background: var(--bg); color: var(--text-secondary); }
.alarm-body { flex: 1; min-width: 0; }
.alarm-title { font-weight: 600; font-size: .95rem; }
.alarm-subtitle { font-size: .8rem; color: var(--text-secondary); margin-top: 2px; }
.alarm-time { font-size: .75rem; color: var(--text-secondary); white-space: nowrap; }

/* ── Person card ──────────────────────────────────────────── */
.person-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.person-card:hover { box-shadow: var(--shadow-md); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem;
  flex-shrink: 0;
}
.person-name { font-weight: 600; font-size: .95rem; }
.person-meta { font-size: .78rem; color: var(--text-secondary); }
.person-time { font-size: .73rem; color: var(--text-secondary); margin-left: auto; white-space: nowrap; }

/* ── Filters bar ──────────────────────────────────────────── */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 14px;
}
.filters-bar .form-control { max-width: 180px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-backdrop.visible { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%; max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}
.modal.modal-wide { max-width: 820px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-body  { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.btn-close {
  background: none; border: none; font-size: 1.3rem;
  color: var(--text-secondary); padding: 2px 6px; border-radius: 4px;
}
.btn-close:hover { background: var(--bg); }

/* ── Toast ────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 20px; right: 16px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #323232; color: #fff;
  padding: 12px 18px; border-radius: var(--radius);
  font-size: .9rem; max-width: 320px;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
  display: flex; align-items: center; gap: 10px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ── Map placeholder ──────────────────────────────────────── */
#map {
  width: 100%; height: 400px;
  border-radius: var(--radius);
  background: #e9ecef;
  border: 1px solid var(--border);
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 16px;
  color: var(--text-secondary);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* ── Loading spinner ──────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 24px auto;
}

/* ── Login page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e2a3a 0%, #1a73e8 100%);
  padding: 16px;
}
.login-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 36px 28px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
  font-size: 1.4rem; font-weight: 700; color: var(--primary);
}
.login-logo span { display: block; font-size: .85rem; font-weight: 400; color: var(--text-secondary); margin-top: 4px; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.page-btn {
  padding: 6px 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 4px;
  font-size: .85rem;
  cursor: pointer;
  transition: background .12s;
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Animations ───────────────────────────────────────────── */
@keyframes slideIn  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes modalIn  { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes spin     { to { transform: rotate(360deg); } }

/* ── Desktop breakpoint ───────────────────────────────────── */
@media (min-width: 768px) {
  .sidebar { transform: translateX(0); position: fixed; }
  .main-content { margin-left: var(--sidebar-w); padding: 24px 28px; }
  .header { left: var(--sidebar-w); }
  .btn-menu { display: none; }
  .overlay { display: none !important; }
  .form-row { grid-template-columns: 1fr 1fr; }
  #map { height: 520px; }
}

@media (min-width: 1200px) {
  .stats-strip { grid-template-columns: repeat(4, 1fr); }
}

button#btnLogout {
    color: var(--border);
}

button#btnLogout:hover {
    color: var(--text);
}

#modalAlarma .modal.modal-wide {
    width: 75vw;
}