/* ==============================
   VARIABLES GLOBALES
============================== */
:root {
  --fuchsia: #d63384;
  --fuchsia-soft: #f8d7e6;
  --fuchsia-hover: #c2186a;
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
  --sidebar-width: 260px;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ==============================
   LINKS & BOTONES
============================== */
a {
  text-decoration: none;
  color: inherit;
}

button,
.btn {
  background: var(--fuchsia);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
}

button:hover,
.btn:hover {
  background: var(--fuchsia-hover);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--fuchsia);
  color: var(--fuchsia);
}

.btn-outline:hover {
  background: var(--fuchsia);
  color: #fff;
}

/* ==============================
   LAYOUT GENERAL (FIX REAL)
============================== */
body {
  padding-left: var(--sidebar-width);
}

/* ==============================
   SIDEBAR (PC)
============================== */
.sidebar {
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 18px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  margin-bottom: 24px;
}

.sidebar-header strong {
  display: block;
  font-size: 1.2rem;
  color: var(--fuchsia);
}

.sidebar-user {
  font-size: .85rem;
  color: var(--muted);
}

.sidebar-menu a {
  display: block;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 6px;
  font-weight: 500;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
  background: var(--fuchsia-soft);
  color: var(--fuchsia);
}

.sidebar-menu .logout {
  margin-top: 20px;
  color: #b91c1c;
}

/* ==============================
   CONTENIDO
============================== */
.main {
  padding: 24px;
  min-height: 100vh;
}

/* ==============================
   HEADER SUPERIOR (MÓVIL)
============================== */
.topbar {
  display: none;
  align-items: center;
  padding: 14px 18px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.menu-toggle {
  font-size: 22px;
  background: none;
  border: none;
  color: var(--fuchsia);
  cursor: pointer;
}

/* ==============================
   SIDEBAR MÓVIL
============================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 90;
}

body.menu-open .sidebar {
  transform: translateX(0);
}

body.menu-open .sidebar-overlay {
  display: block;
}

/* ==============================
   CARDS
============================== */
.card,
.form-card,
.table-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

/* ==============================
   FORMULARIOS
============================== */
.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}

label {
  font-size: .85rem;
  margin-bottom: 6px;
  color: var(--muted);
}

input,
select,
textarea {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: .95rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--fuchsia);
}

/* ==============================
   TABLAS
============================== */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}

th {
  text-align: left;
  color: var(--muted);
}

/* ==============================
   LOGIN
============================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fde7f3, #fff);
}

.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
}

/* ==============================
   RESPONSIVE
============================== */
@media (max-width: 900px) {
  body {
    padding-left: 0;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
  }

  .topbar {
    display: flex;
  }
}

/* ======================================================
   🔔 RECORDATORIOS – NUEVA ACTUALIZACIÓN (NO ROMPE NADA)
====================================================== */

.recordatorio-activo {
  background: #d1fae5; /* verde claro */
  color: #065f46;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.recordatorio-vencido {
  background: #fee2e2; /* rojo claro */
  color: #991b1b;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 700;
}

.parpadeo {
  animation: blink 1.2s infinite;
}

@keyframes blink {
  0% { opacity: 1; }
  50% { opacity: .4; }
  100% { opacity: 1; }
}

/* ==============================
   CHAT INTERNO – BADGES POR USUARIO
   (NO ROMPE NADA EXISTENTE)
============================== */

.chat-user {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.chat-user:hover {
  background: #f3f4f6;
}

.chat-user-badge {
  background: #d63384;
  color: #fff;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 999px;
  padding: 0 6px;
  font-weight: 700;
}

/* ==============================
   EXTRA: ALERTAS VISUALES (NO TOCA MENÚ)
   - WhatsApp nuevo (rojo suave)
   - Recordatorio activo (verde)
   - Recordatorio vencido + parpadeo (rojo + blink)
============================== */

/* ✅ WhatsApp nuevo (solo el link/numero) */
.table-card table a.whatsapp-nuevo,
.table-card table td.whatsapp-nuevo a {
  background: #fee2e2;
  color: #991b1b !important;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  display: inline-block;
}

/* ✅ Recordatorio activo (verde claro) */
.table-card .recordatorio-activo {
  background: #d1fae5;
  color: #065f46;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
  display: inline-block;
}

/* ✅ Recordatorio vencido (rojo claro) */
.table-card .recordatorio-vencido {
  background: #fee2e2;
  color: #991b1b;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 700;
  display: inline-block;
}

/* ✅ Parpadeo */
.table-card .parpadeo {
  animation: crm-blink 1.2s infinite;
}

@keyframes crm-blink {
  0% { opacity: 1; }
  50% { opacity: .4; }
  100% { opacity: 1; }
}

/* ======================================================
   💬 CHAT – FIX DEFINITIVO VISIBILIDAD EN PC MAXIMIZADA
   (NO ROMPE SIDEBAR, NO ROMPE MÓVIL)
====================================================== */

/* Contenedor flotante SOLO para escritorio */
.chat-desktop-fixed {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 1200;
  display: none; /* por defecto oculto */
}

/* Estilo del botón chat en escritorio */
.chat-desktop-fixed .chat-icon-btn {
  background: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
}

/* 📌 PC / pantallas grandes */
@media (min-width: 901px) {
  .chat-desktop-fixed {
    display: block; /* FORZAMOS VISIBILIDAD */
  }
}

/* 📌 Móvil: se usa el topbar normal */
@media (max-width: 900px) {
  .chat-desktop-fixed {
    display: none;
  }

/* ======================================================
   🔧 FIX FINAL: CHAT SOLO UNO EN MÓVIL
   - Móvil: solo chat del header
   - PC: solo chat flotante
====================================================== */

/* 📱 MÓVILES Y TABLETS */
@media (max-width: 900px) {
  .chat-desktop-fixed {
    display: none !important;
  }
}

/* 🖥 PC / PANTALLA GRANDE */
@media (min-width: 901px) {
  .topbar .chat-icon-btn {
    display: none !important;
  }

/* ==============================
   🔴 FIX DEFINITIVO BADGE CHAT
   PC MAXIMIZADO + MÓVIL
============================== */

/* Asegura que el header no recorte hijos */
.topbar {
  overflow: visible !important;
  position: relative;
  z-index: 1000;
}

/* El botón del chat siempre por encima */
.chat-icon-btn {
  position: relative !important;
  z-index: 1100 !important;
}

/* Badge SIEMPRE visible, nunca recortado */
.chat-badge {
  position: absolute !important;
  top: -4px !important;
  right: -4px !important;
  z-index: 1200 !important;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 18px;
  height: 18px;
  padding: 0 6px;

  border-radius: 999px;
  background: #d63384;
  color: #fff;
  font-size: 11px;
  font-weight: 700;

  pointer-events: none;
}

/* Desktop grande: NO ocultar topbar */
@media (min-width: 901px) {
  .topbar {
    display: flex !important;
  }
}
