/* ============================================================
   SMART SHIELD 360 — main.css  (versión limpia)
   Paleta: Azul #1a3a6b / Blanco #fff / Rojo #dc2626 / Negro texto
   ============================================================ */

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

:root {
  --sidebar-w:    260px;
  --bg:           #f0f4f8;
  --bg-card:      #ffffff;
  --sidebar-bg:   #1a3a6b;
  --sidebar-dark: #122d55;
  --blue:         #2563a8;
  --blue2:        #1e78c8;
  --blue-lt:      #4a90d9;
  --white:        #ffffff;
  --txt:          #111827;
  --txt-body:     #1f2937;
  --txt-muted:    #6b7280;
  --txt-side:     #c8daf0;
  --red:          #dc2626;
  --green:        #16a34a;
  --amber:        #d97706;
  --info:         #0284c7;
  --border:       #dde3ec;
  --shadow:       0 2px 12px rgba(0,0,0,.10);
  --shadow-md:    0 4px 20px rgba(0,0,0,.13);
  --r:            12px;
  --r-sm:         8px;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--txt-body);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 300;
  transition: transform .3s ease;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px;
  background: var(--sidebar-dark);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo .logo-icon { font-size: 2rem; }
.sidebar-logo .logo-text h2 { color: #fff; font-size: .95rem; letter-spacing: 1px; font-weight: 700; }
.sidebar-logo .logo-text p  { color: var(--txt-side); font-size: .7rem; opacity: .8; }

.sidebar-nav { flex: 1; padding: 10px 0; }
.nav-section {
  padding: 10px 20px 4px;
  font-size: .65rem;
  color: rgba(200,218,240,.6);
  text-transform: uppercase;
  letter-spacing: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--txt-side);
  text-decoration: none;
  font-size: .88rem;
  border-left: 3px solid transparent;
  transition: all .18s;
}
.nav-item:hover { background: rgba(255,255,255,.10); color: #fff; border-left-color: var(--blue-lt); }
.nav-item.active { background: rgba(255,255,255,.15); color: #fff; border-left-color: #fff; font-weight: 600; }
.nav-item .nav-icon { width: 20px; text-align: center; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: .68rem; padding: 2px 7px; border-radius: 10px; }

.sidebar-user {
  padding: 14px 20px;
  background: var(--sidebar-dark);
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--blue-lt); display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: .95rem; flex-shrink: 0; }
.user-info .user-name { font-size: .85rem; font-weight: 600; color: #fff; }
.user-info .user-role { font-size: .7rem; color: var(--txt-side); opacity: .8; }
.btn-logout { margin-left: auto; color: #ff8080; text-decoration: none; font-size: 1.2rem; display: flex; align-items: center; transition: color .2s; }
.btn-logout:hover { color: #fff; }

/* ── MAIN CONTENT (escritorio: empuja a la derecha del sidebar) ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ── TOPBAR ── */
.topbar {
  background: var(--bg-card);
  border-bottom: 2px solid var(--border);
  padding: 13px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--txt); }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.topbar-btn { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 1.1rem; padding: 6px; border-radius: var(--r-sm); transition: all .2s; position: relative; }
.topbar-btn:hover { background: var(--bg); }
.notif-count { position: absolute; top: 0; right: 0; background: var(--red); color: #fff; font-size: .6rem; width: 15px; height: 15px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* botón hamburguesa — oculto en escritorio */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--txt);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}

/* ── PAGE CONTENT ── */
.page-content { padding: 24px; flex: 1; }

/* ── PAGE HEADER ── */
.page-header {
  margin-bottom: 24px;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--txt); }
.page-header p  { color: var(--txt-muted); margin-top: 3px; }

/* Versión fila (escritorio) → columna (móvil) */
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header-row > div:first-child { flex: 1; min-width: 0; }
.page-header-row h1 { font-size: 1.5rem; font-weight: 700; color: var(--txt); }
.page-header-row p  { color: var(--txt-muted); margin-top: 3px; }

/* ── STATS GRID ── */
.stats-grid   { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stats-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 20px; }

.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r); padding: 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 50px; height: 50px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-icon.gold  { background: #fef9e7; color: var(--amber); }
.stat-icon.blue  { background: #eff6ff; color: var(--blue); }
.stat-icon.red   { background: #fef2f2; color: var(--red); }
.stat-icon.green { background: #f0fdf4; color: var(--green); }
.stat-info .stat-value { font-size: 1.9rem; font-weight: 700; color: var(--txt); line-height: 1; }
.stat-info .stat-label { color: var(--txt-muted); font-size: .8rem; margin-top: 3px; }

/* ── CARDS ── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--border); background: #f8fafc; display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: .95rem; font-weight: 700; color: var(--txt); }
.card-body { padding: 20px; }

/* ── TABLES ── */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data-table th { padding: 11px 14px; text-align: left; color: var(--txt-muted); font-size: .73rem; text-transform: uppercase; letter-spacing: 1px; border-bottom: 2px solid var(--border); background: #f8fafc; white-space: nowrap; }
table.data-table td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; color: var(--txt-body); vertical-align: middle; }
table.data-table tr:hover td { background: #f8fafc; }
table.data-table tr:last-child td { border-bottom: none; }

/* ── BADGES ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .73rem; font-weight: 600; }
.badge-nueva     { background: #e0f2fe; color: #0284c7; }
.badge-proceso   { background: #fef9c3; color: #a16207; }
.badge-resuelta  { background: #dcfce7; color: #15803d; }
.badge-cerrada   { background: #f1f5f9; color: #64748b; }
.badge-active    { background: #dcfce7; color: #15803d; }
.badge-suspended { background: #fef2f2; color: #dc2626; }
.badge-danger    { background: #fef2f2; color: #dc2626; }
.badge-warning   { background: #fef9c3; color: #a16207; }
.badge-info      { background: #e0f2fe; color: #0284c7; }
.badge-default   { background: #f1f5f9; color: #64748b; }
.badge-gold      { background: #fef3c7; color: #b45309; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--r-sm); font-size: .86rem; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: all .18s; white-space: nowrap; }
.btn-primary   { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue2); transform: translateY(-1px); }
.btn-secondary { background: #fff; color: var(--txt-body); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger    { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-success   { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }
.btn-success:hover { background: #dcfce7; }
.btn-sm  { padding: 5px 11px; font-size: .78rem; }
.btn-icon{ padding: 7px; }

/* ── FORMS ── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--txt); }
.form-control { padding: 10px 13px; background: #fff; border: 1.5px solid var(--border); border-radius: var(--r-sm); color: var(--txt-body); font-size: .92rem; width: 100%; transition: border-color .2s, box-shadow .2s; }
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,168,.12); }
.form-control option { background: #fff; color: var(--txt-body); }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }

/* ── ALERTS FLASH ── */
.alert { padding: 12px 16px; border-radius: var(--r-sm); margin-bottom: 18px; font-size: .88rem; display: flex; align-items: center; gap: 9px; font-weight: 500; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #b45309; }
.alert-info    { background: #f0f9ff; border: 1px solid #bae6fd; color: #0369a1; }

/* ── FILTER BAR ── */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

/* ── ROUNDS GRID ── */
.rounds-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 400; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { padding: 16px 22px; border-bottom: 1px solid var(--border); background: #f8fafc; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 1; }
.modal-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--txt); }
.modal-close { background: none; border: none; color: var(--txt-muted); font-size: 1.2rem; cursor: pointer; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 6px; transition: all .15s; flex-shrink: 0; }
.modal-close:hover { background: #fee2e2; color: var(--red); }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: #f8fafc; display: flex; justify-content: flex-end; gap: 10px; }

/* ── CHAT ── */
.chat-wrap { display: flex; flex-direction: column; height: 480px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 75%; }
.chat-msg.own { align-self: flex-end; }
.chat-bubble { padding: 9px 13px; border-radius: 14px; font-size: .88rem; line-height: 1.5; }
.chat-msg.own .chat-bubble   { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.other .chat-bubble { background: #f1f5f9; color: var(--txt-body); border-bottom-left-radius: 4px; }
.chat-meta { font-size: .7rem; color: var(--txt-muted); margin-top: 3px; }
.chat-msg.own .chat-meta { text-align: right; }
.chat-input-wrap { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; background: #f8fafc; }
.chat-input { flex: 1; padding: 9px 13px; background: #fff; border: 1.5px solid var(--border); border-radius: 20px; color: var(--txt-body); font-size: .88rem; }
.chat-input:focus { outline: none; border-color: var(--blue); }

/* ── EMERGENCY BUTTON ── */
.emergency-btn-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px 0; }
.emergency-btn { width: 170px; height: 170px; border-radius: 50%; border: 6px solid var(--red); background: #fef2f2; color: var(--red); font-size: 2.8rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; transition: all .2s; animation: pulse-ring 2s infinite; }
.emergency-btn:hover { background: #fee2e2; transform: scale(1.05); }
.emergency-btn span { font-size: .85rem; font-weight: 700; letter-spacing: 1px; }
@keyframes pulse-ring { 0%,100%{box-shadow:0 0 0 0 rgba(220,38,38,.3)} 50%{box-shadow:0 0 0 18px rgba(220,38,38,0)} }

.alert-type-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; width: 100%; max-width: 340px; }
.alert-type-btn { padding: 14px; border-radius: var(--r-sm); border: 2px solid transparent; cursor: pointer; font-weight: 600; font-size: .88rem; transition: all .2s; text-align: center; }
.alert-type-btn.emergencia { background: #fef2f2; color: var(--red);    border-color: #fecaca; }
.alert-type-btn.ayuda      { background: #fffbeb; color: var(--amber);  border-color: #fde68a; }
.alert-type-btn.incidencia { background: #f0f9ff; color: var(--info);   border-color: #bae6fd; }
.alert-type-btn.aviso      { background: #f0fdf4; color: var(--green);  border-color: #bbf7d0; }
.alert-type-btn.active,.alert-type-btn:hover { transform: scale(1.03); border-color: currentColor; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(37,99,168,.25); border-radius: 3px; }

/* ── UTILITIES ── */
.d-flex     { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-muted  { color: var(--txt-muted); }
.text-danger { color: var(--red); }
.text-success{ color: var(--green); }
.text-gold   { color: #b45309; }
.hidden { display: none !important; }

/* ── LOGIN ── */
.login-wrap { width: 100%; max-width: 440px; padding: 20px; }

/* ================================================================
   RESPONSIVE — MÓVIL  (≤ 768px)
   ================================================================ */
@media (max-width: 768px) {

  /* El sidebar se esconde fuera de pantalla */
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* El contenido ocupa TODO el ancho */
  .main-content {
    margin-left: 0;
  }

  /* Mostrar botón hamburguesa */
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Topbar */
  .topbar { padding: 11px 14px; }
  .topbar-title { font-size: .95rem; }

  /* Page content */
  .page-content { padding: 12px; }

  /* Page header → columna */
  .page-header-row {
    flex-direction: column;
    align-items: stretch;
  }
  .page-header-row .btn,
  .page-header-row > .btn {
    width: 100%;
    justify-content: center;
  }
  .page-header-row h1,
  .page-header h1 { font-size: 1.2rem; }

  /* Stats → 2 columnas */
  .stats-grid { grid-template-columns: repeat(2,1fr); gap: 10px; }

  /* Rounds grid → 1 columna */
  .rounds-grid { grid-template-columns: 1fr; gap: 14px; }

  /* Forms → 1 columna */
  .form-grid { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }

  /* Tablas — scroll horizontal */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.data-table { min-width: 480px; }
  table.data-table th,
  table.data-table td { padding: 9px 11px; font-size: .8rem; white-space: nowrap; }

  /* Cards */
  .card-body   { padding: 12px; }
  .card-header { padding: 11px 14px; }

  /* Modales desde abajo */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--r) var(--r) 0 0; max-width: 100%; max-height: 90vh; }

  /* Acciones de tabla */
  .d-flex.gap-2 { flex-wrap: wrap; }

  /* Emergency */
  .emergency-btn { width: 140px; height: 140px; font-size: 2.4rem; }

  /* Chat */
  .chat-wrap { height: 400px; }
  .chat-msg { max-width: 88%; }
}

@media (max-width: 480px) {
  .stats-grid   { grid-template-columns: 1fr; }
  .stats-grid-2 { grid-template-columns: 1fr; }
  .page-content { padding: 8px; }
  .topbar-actions { gap: 8px; }
}
