/* ===== CSS Design System — Bitácora de Vigilancia ===== */
:root {
  --bg-base: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface2: #273548;
  --bg-input: #334155;
  --border: #475569;
  --border-light: #3b4a60;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #14b8a6;
  --accent-hover: #2dd4bf;
  --accent-glow: rgba(20, 184, 166, 0.15);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --purple: #8b5cf6;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.25);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --transition: 0.2s ease;
  --sidebar-width: 250px;
  --topbar-height: 56px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== LOGIN ===== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { width: 100%; max-width: 420px; padding: 1rem; }
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.login-logo {
  text-align: center; font-size: 3rem; color: var(--accent); margin-bottom: 0.5rem;
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { text-shadow: 0 0 10px var(--accent-glow); }
  50% { text-shadow: 0 0 25px var(--accent-glow), 0 0 50px var(--accent-glow); }
}
.login-title { text-align: center; font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.login-subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-form .form-group { margin-bottom: 1.2rem; }
.login-footer { text-align: center; color: var(--text-muted); font-size: 0.8rem; margin-top: 1.5rem; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-brand {
  padding: 1.25rem 1.5rem;
  font-size: 1.25rem; font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 0.75rem;
}
.sidebar-brand i { font-size: 1.5rem; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.75rem 0; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 1.5rem;
  color: var(--text-secondary);
  font-size: 0.9rem; font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.nav-item:hover { color: var(--text); background: var(--bg-surface2); }
.nav-item.active {
  color: var(--accent); background: var(--accent-glow);
  border-left-color: var(--accent);
}
.nav-item i { width: 20px; text-align: center; font-size: 0.95rem; }
.nav-group-label {
  padding: 1rem 1.5rem 0.4rem;
  font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
}
.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--text-secondary); font-size: 0.85rem;
}

/* ===== TOPBAR (mobile) ===== */
.topbar {
  display: none; position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  padding: 0 1rem;
  align-items: center; justify-content: space-between;
  z-index: 90;
}
.menu-toggle {
  background: none; border: none; color: var(--text); font-size: 1.25rem; cursor: pointer;
  padding: 0.5rem; border-radius: var(--radius-sm); transition: background var(--transition);
}
.menu-toggle:hover { background: var(--bg-surface2); }
.topbar-brand { font-weight: 700; color: var(--accent); display: flex; align-items: center; gap: 0.5rem; }
.topbar-user { color: var(--text-secondary); font-size: 0.85rem; }
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 95;
}
.sidebar-overlay.active { display: block; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 1.5rem 2rem;
  min-height: 100vh;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}
.page-header h1 {
  font-size: 1.5rem; font-weight: 700;
  display: flex; align-items: center; gap: 0.6rem;
}
.page-header h1 i { color: var(--accent); font-size: 1.3rem; }
.header-actions { display: flex; gap: 0.5rem; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  overflow: hidden;
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border); }
.card-header {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.card-header h2 {
  font-size: 0.95rem; font-weight: 600;
  display: flex; align-items: center; gap: 0.5rem;
}
.card-header h2 i { color: var(--accent); }
.card-body { padding: 1.25rem; }

/* ===== KPI CARDS ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 1.25rem;
}
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), border-color var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.kpi-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; color: #fff; flex-shrink: 0;
}
.kpi-info { display: flex; flex-direction: column; }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.kpi-label { font-size: 0.8rem; color: var(--text-secondary); }

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.25rem; margin-bottom: 1.25rem;
}

/* ===== BAR LIST (Dashboard charts) ===== */
.bar-list { display: flex; flex-direction: column; gap: 0.75rem; }
.bar-item { display: flex; align-items: center; gap: 0.75rem; }
.bar-label { width: 140px; font-size: 0.85rem; color: var(--text-secondary); flex-shrink: 0; text-align: right; }
.bar-track { flex: 1; height: 24px; background: var(--bg-input); border-radius: 12px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 12px; transition: width 0.6s ease; min-width: 8px; }
.bar-fill-teal { background: linear-gradient(90deg, var(--accent), var(--accent-hover)); }
.bar-fill-red { background: linear-gradient(90deg, var(--danger), #f87171); }
.bar-value { width: 32px; font-size: 0.85rem; font-weight: 600; }

/* ===== TABLES ===== */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th {
  text-align: left; padding: 0.7rem 0.75rem;
  background: var(--bg-surface2);
  color: var(--text-secondary);
  font-weight: 600; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--bg-surface2); }
.table tbody tr:last-child td { border-bottom: none; }
.row-inactive { opacity: 0.5; }
.text-center { text-align: center; }
.actions-cell { white-space: nowrap; display: flex; gap: 0.35rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.form-group label {
  font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
  display: flex; align-items: center; gap: 0.4rem;
}
.form-group label i { color: var(--accent); font-size: 0.8rem; }
input[type="text"], input[type="password"], input[type="date"],
input[type="time"], input[type="number"], input[type="email"],
select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { resize: vertical; min-height: 70px; }
small.text-muted { font-size: 0.78rem; color: var(--text-muted); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.5rem;
}

.form-actions {
  display: flex; gap: 0.75rem; margin-top: 1rem;
  padding-top: 1rem; border-top: 1px solid var(--border-light);
}

.inline-form { display: inline; }
.inline-add-form {
  display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap;
}
.inline-add-form input { max-width: 220px; }
.inline-edit-form {
  display: flex; gap: 0.5rem; align-items: center;
}
.inline-edit-form input { max-width: 180px; }

/* ===== FILTER ===== */
.filter-card { margin-bottom: 1.25rem; }
.filter-card .card-body { padding: 1rem 1.25rem; }
.filter-form { display: flex; flex-direction: column; gap: 0.75rem; }
.filter-row {
  display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end;
}
.filter-row .form-group { flex: 1; min-width: 140px; margin-bottom: 0; }
.filter-actions { flex-direction: row !important; gap: 0.5rem; align-items: flex-end; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-family: var(--font); font-size: 0.88rem; font-weight: 600;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; color: #fff; }
.btn-warning { background: var(--warning); color: #1a1a1a; }
.btn-warning:hover { background: #d97706; color: #1a1a1a; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-outline {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover { color: var(--text); border-color: var(--text-secondary); }

.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.82rem; }
.btn-xs { padding: 0.3rem 0.6rem; font-size: 0.78rem; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem; font-weight: 600;
  border-radius: 50px; white-space: nowrap;
}
.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--info); }

/* ===== ALERTS ===== */
.alert {
  padding: 0.75rem 1rem; border-radius: var(--radius-sm);
  margin-bottom: 1rem; font-size: 0.88rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.alert-error { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }

/* ===== TOASTS ===== */
.toast {
  position: fixed; top: 1.25rem; right: 1.25rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem; font-weight: 500;
  display: flex; align-items: center; gap: 0.5rem;
  z-index: 999; box-shadow: var(--shadow);
  transition: opacity 0.4s ease, transform 0.4s ease;
  animation: slideIn 0.4s ease;
}
@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.toast-success { background: rgba(34,197,94,0.2); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }
.toast-error { background: rgba(239,68,68,0.2); color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }

/* ===== CHECKLIST ===== */
.section-divider {
  margin: 1.75rem 0 1rem;
  padding-top: 1.25rem; border-top: 1px solid var(--border-light);
}
.section-divider h2 {
  font-size: 1.1rem; font-weight: 700;
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem;
}
.section-divider h2 i { color: var(--accent); }

.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
.checklist-item {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--bg-surface2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: all var(--transition);
}
.checklist-item:hover { border-color: var(--accent); background: var(--accent-glow); }
.checklist-item input[type="checkbox"] { display: none; }
.checklist-toggle {
  width: 42px; height: 24px;
  background: var(--bg-input);
  border-radius: 12px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.checklist-toggle::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition);
}
.checklist-item input:checked + .checklist-toggle {
  background: var(--accent);
}
.checklist-item input:checked + .checklist-toggle::after {
  left: 21px; background: #fff;
}
.checklist-label { font-size: 0.9rem; font-weight: 500; }

/* ===== DETAIL VIEW ===== */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.25rem;
}
.detail-list { display: flex; flex-direction: column; gap: 0; }
.detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border-light);
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  color: var(--text-secondary); font-size: 0.85rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.detail-label i { color: var(--accent); font-size: 0.8rem; }
.detail-value { font-weight: 500; }

.equipment-list { display: flex; flex-direction: column; gap: 0.5rem; }
.equipment-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-surface2);
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.equipment-item:hover { background: var(--bg-input); }
.equipment-status { font-size: 1.25rem; }
.status-ok { color: var(--success); }
.status-missing { color: var(--danger); }
.equipment-name { flex: 1; font-size: 0.9rem; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex; gap: 0.35rem; justify-content: center;
  margin-top: 1rem; padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}
.page-link {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface2);
  border: 1px solid var(--border-light);
  transition: all var(--transition);
}
.page-link:hover { color: var(--text); border-color: var(--accent); }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 2.5rem 1rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; }
.empty-state p { font-size: 0.95rem; }

/* ===== UTILITIES ===== */
.text-muted { color: var(--text-muted) !important; }
.text-sm { font-size: 0.82rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar { display: flex; }
  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: calc(var(--topbar-height) + 1rem);
  }
  .form-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-row { flex-direction: column; }
  .filter-row .form-group { min-width: 100%; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .inline-add-form { flex-direction: column; }
  .inline-add-form input { max-width: 100%; }
  .inline-edit-form { flex-wrap: wrap; }
  .inline-edit-form input { max-width: 100%; }
  .bar-label { width: 100px; font-size: 0.78rem; }
  .checklist-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { padding: 1rem; }
}
