/* ═══════════════════════════════════════════════════
   SISDEL RONDÍN — Design System
   Premium dark theme with security aesthetic
   ═══════════════════════════════════════════════════ */

:root {
  /* Colors */
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #253349;
  --bg-input: #1a2332;
  --border-color: rgba(99, 179, 237, 0.15);
  --border-active: rgba(99, 179, 237, 0.4);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.3);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.15);
  --emergency: #dc2626;

  /* Spacing */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --glow-accent: 0 0 20px rgba(59, 130, 246, 0.2);

  /* Font */
  --font: 'Inter', -apple-system, sans-serif;
}

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

html, body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  font-size: 120%; /* +20% tamaño global */
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* ═══════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a0e1a 0%, #0f172a 50%, #1a1a3e 100%);
  position: relative;
  overflow: hidden;
}

.login-container::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 70%);
  top: -200px; right: -200px;
  border-radius: 50%;
  animation: float 15s ease-in-out infinite;
}

.login-container::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.06) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  border-radius: 50%;
  animation: float 20s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, -30px); }
}

.login-card {
  background: rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 420px;
  max-width: 95vw;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .shield-icon {
  font-size: 56px;
  background: linear-gradient(135deg, var(--accent), var(--info));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: block;
  margin-bottom: 12px;
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #f1f5f9, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.login-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 28px;
}

.login-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
}

.login-tab.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 2px 10px var(--accent-glow);
}

/* ─── Form Elements ─── */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  transition: all 0.3s;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

.pin-input-group {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.pin-digit {
  width: 52px; height: 64px;
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--accent);
  outline: none;
  transition: all 0.3s;
  -webkit-text-security: disc;
  caret-color: transparent;
}

.pin-digit:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  transform: scale(1.05);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: white;
  box-shadow: 0 4px 15px var(--accent-glow);
  width: 100%;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px var(--accent-glow);
}

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: #1a1a1a; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 8px 16px; font-size: 12px; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; }

/* ═══════════════════════════════════════
   LAYOUT — ADMIN/SUPERVISOR
   ═══════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-hidden { transform: translateX(-100%); }

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header .shield {
  font-size: 28px;
  background: linear-gradient(135deg, var(--accent), var(--info));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-header h2 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
}

.sidebar-header small {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.5px;
}

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

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(59, 130, 246, 0.08);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  font-weight: 600;
}

.nav-item i { width: 18px; text-align: center; font-size: 15px; }

.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--info));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
}

.user-info-text small {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.user-info-text span {
  font-size: 13px;
  font-weight: 600;
}

/* Main Content */
.main-content {
  margin-left: 260px;
  flex: 1;
  min-height: 100vh;
}

.topbar {
  height: 64px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.topbar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-bell {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.alert-bell:hover { border-color: var(--accent); color: var(--accent); }

.alert-bell .dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.page-content {
  padding: 24px;
}

/* ─── Stats Cards ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before { background: var(--danger); }

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-active);
}

.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}

.stat-card .stat-icon.blue { background: rgba(59,130,246,0.15); color: var(--accent); }
.stat-card .stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-card .stat-icon.yellow { background: var(--warning-bg); color: var(--warning); }
.stat-card .stat-icon.red { background: var(--danger-bg); color: var(--danger); }

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── Cards & Panels ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.card-body { padding: 20px; }

/* ─── Table ─── */
.table-container { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 14px 16px;
  font-size: 13px;
  border-bottom: 1px solid rgba(99, 179, 237, 0.06);
}

.data-table tr:hover td {
  background: rgba(59, 130, 246, 0.04);
}

/* ─── Badges ─── */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-active { background: var(--success-bg); color: var(--success); }
.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-completed { background: var(--info-bg); color: var(--info); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--accent); }

/* ─── Map Container ─── */
.map-container {
  width: 100%;
  height: 500px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.map-container .leaflet-container { height: 100%; }

/* ─── Grid layouts ─── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ─── Alert toast ─── */
.alert-toast {
  position: fixed;
  top: 80px; right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: 0 8px 30px rgba(239, 68, 68, 0.3);
  z-index: 9999;
  animation: slideIn 0.4s ease-out;
  max-width: 400px;
}

.alert-toast.panic {
  background: linear-gradient(135deg, #7f1d1d, #991b1b);
  border-color: var(--emergency);
  animation: slideIn 0.4s ease-out, blink 0.5s infinite;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.alert-toast h4 { font-size: 14px; margin-bottom: 4px; }
.alert-toast p { font-size: 12px; color: var(--text-secondary); }

/* ═══════════════════════════════════════
   GUARD MOBILE VIEW
   ═══════════════════════════════════════ */
.guard-layout {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-primary);
}

.guard-header {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
}

.guard-header .guard-name {
  font-size: 18px;
  font-weight: 700;
  margin-top: 8px;
}

.guard-header .guard-route {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.guard-status-bar {
  display: flex;
  justify-content: space-around;
  padding: 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.guard-status-item {
  text-align: center;
}

.guard-status-item .value {
  font-size: 20px;
  font-weight: 800;
}

.guard-status-item .label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.guard-actions {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guard-action-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  text-align: left;
  width: 100%;
}

.guard-action-btn:hover {
  border-color: var(--accent);
  transform: scale(1.02);
}

.guard-action-btn i {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.guard-action-btn .action-desc {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

/* ─── Panic Button ─── */
.panic-btn {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  width: 90px; height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, #dc2626, #991b1b);
  border: 4px solid rgba(239, 68, 68, 0.5);
  color: white;
  font-size: 13px;
  font-weight: 800;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: 0 0 30px rgba(220, 38, 38, 0.4);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  animation: panicPulse 3s infinite;
}

@keyframes panicPulse {
  0%, 100% { box-shadow: 0 0 30px rgba(220, 38, 38, 0.4); }
  50% { box-shadow: 0 0 50px rgba(220, 38, 38, 0.6); }
}

.panic-btn i { font-size: 24px; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.4s ease-out;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 14px;
  margin-top: 8px;
}

/* ─── Chart container ─── */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar-toggle { display: block; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .map-container { height: 350px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px; }
  .pin-digit { width: 44px; height: 56px; font-size: 20px; }
}
