/* ==========================================================================
   SISTEMA DE DISEÑO NEXUS CONTACTOS (Aesthetics: Glassmorphism / Dark Mode)
   ========================================================================== */

:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Outfit', sans-serif;

  /* Colores primarios y de acento HSL */
  --bg-dark: #090d16;
  --bg-surface: rgba(18, 26, 43, 0.75);
  --bg-surface-elevated: rgba(26, 38, 64, 0.85);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-hover: rgba(56, 189, 248, 0.3);

  --primary-500: #0284c7;
  --primary-400: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.25);

  --accent-cyan: #06b6d4;
  --accent-indigo: #6366f1;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --transition-fast: 0.18s ease;
  --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Efectos de resplandor de fondo */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

.bg-glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #0284c7, transparent 70%);
  top: -100px;
  right: -100px;
}

.bg-glow-2 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #4f46e5, transparent 70%);
  bottom: 50px;
  left: -100px;
}

/* Banner superior para descarga en móvil */
.mobile-apk-banner {
  background: linear-gradient(90deg, #0369a1, #1d4ed8);
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideDown 0.3s ease;
}

.banner-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.banner-icon {
  font-size: 22px;
}

.banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: #f8fafc;
}

.btn-banner-download {
  background: #ffffff;
  color: #0369a1;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.btn-banner-download:hover {
  background: #e0f2fe;
  transform: translateY(-1px);
}

.btn-banner-close {
  background: none;
  border: none;
  color: #bae6fd;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

/* Header / Navbar */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  background: rgba(9, 13, 22, 0.8);
  border-bottom: 1px solid var(--border-glass);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 24px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #38bdf8 !important;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.2);
}

.logo-icon i {
  color: #38bdf8 !important;
  font-size: 22px;
  display: inline-block;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-title .highlight {
  color: var(--primary-400);
}

.brand-badge {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  margin-left: 8px;
}

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

/* Badges de estado de red */
.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

.status-badge.online {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.offline {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 8px currentColor;
}

/* Botón APK en header */
.btn-apk-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(56, 189, 248, 0.1);
  color: var(--primary-400);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition-normal);
}

.btn-apk-header:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--primary-400);
  transform: translateY(-1px);
}

/* Usuario en header */
.user-session {
  display: flex;
  align-items: center;
  gap: 14px;
  border-left: 1px solid var(--border-glass);
  padding-left: 14px;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.user-email {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inactivity-timer {
  font-size: 11px;
  color: var(--accent-amber);
  font-weight: 500;
}

.btn-logout {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: #fb7185;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-logout:hover {
  background: rgba(244, 63, 94, 0.2);
  color: #fff;
}

/* Main Layout */
.main-content {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 20px;
  position: relative;
  z-index: 10;
}

/* Paneles Glassmorphism */
.glass-panel {
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

/* SECCIÓN DE AUTENTICACIÓN */
.auth-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 160px);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 36px 32px;
  animation: fadeIn 0.4s ease;
}

.auth-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 28px;
  border: 1px solid var(--border-glass);
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 14px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-normal);
}

.tab-btn.active {
  background: var(--primary-500);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.form-header {
  margin-bottom: 24px;
  text-align: center;
}

.form-header h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.form-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  background: #0f172a !important; /* Fondo oscuro constante */
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: #f1f5f9 !important;
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition-fast);
}

/* Prevenir que el autocompletado de Chrome / Edge pinte de blanco los inputs */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px #0f172a inset !important;
  box-shadow: 0 0 0 1000px #0f172a inset !important;
  -webkit-text-fill-color: #f1f5f9 !important;
  color: #f1f5f9 !important;
  caret-color: #38bdf8 !important;
  border-color: rgba(56, 189, 248, 0.4) !important;
  transition: background-color 5000s ease-in-out 0s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input-wrap input {
  width: 100%;
  padding-right: 48px !important;
}

.btn-toggle-pwd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  color: #38bdf8 !important; /* Azul cian eléctrico de alto contraste */
  cursor: pointer;
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  transition: transform 0.15s ease, opacity 0.15s ease;
  z-index: 10;
}

.btn-toggle-pwd i {
  color: #38bdf8 !important;
  font-size: 1.25rem;
  display: inline-block;
}

.btn-toggle-pwd:hover,
.btn-toggle-pwd:focus {
  background: transparent !important;
  transform: translateY(-50%) scale(1.1);
}

.form-sub-action {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.btn-link-forgot {
  background: none;
  border: none;
  color: var(--primary-400);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 0;
  transition: var(--transition-fast);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-link-forgot:hover {
  color: #7dd3fc;
}

.modal-subtext {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 18px;
}

/* Botones Principales */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--primary-500), #2563eb);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--primary-glow);
  transition: var(--transition-normal);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(56, 189, 248, 0.35);
}

.btn-primary.btn-danger-gradient {
  background: linear-gradient(135deg, #e11d48, #be123c);
  box-shadow: 0 6px 20px rgba(225, 29, 72, 0.3);
}

.btn-primary.btn-danger {
  background: #e11d48;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.w-full {
  width: 100%;
}

/* Card informativa */
.info-card {
  display: flex;
  gap: 12px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 13px;
  color: #bae6fd;
}

.info-icon {
  font-size: 18px;
}

/* Alertas */
.alert-box {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 18px;
  line-height: 1.5;
}

.alert-box.error {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fca5a5;
}

.alert-box.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.alert-box.warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

/* SECCIÓN: DASHBOARD DE CONTACTOS */
.dashboard-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.topbar-title h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.topbar-title p {
  color: var(--text-muted);
  font-size: 14px;
}

/* Barra de Búsqueda */
.search-bar-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.search-input-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 260px;
}

.search-input-box input {
  background: none;
  border: none;
  color: #fff;
  font-size: 14px;
  width: 100%;
  outline: none;
}

.search-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.count-badge {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Banner Offline */
.sync-banner {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  font-size: 13px;
  animation: pulse 2s infinite;
}

/* Tabla de Contactos */
.contacts-container {
  padding: 12px;
  overflow: hidden;
}

.table-responsive {
  overflow-x: auto;
}

.contacts-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.contacts-table th {
  padding: 14px 18px;
  color: var(--text-subtle);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-glass);
}

.contacts-table td {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.contacts-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.contact-user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

.contact-name {
  font-weight: 600;
  color: var(--text-main);
}

.cc-badge {
  font-family: monospace;
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--primary-400);
}

.phone-link {
  color: #38bdf8;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.phone-link:hover {
  text-decoration: underline;
}

.table-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-action-edit, .btn-action-delete {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-action-edit {
  color: #38bdf8;
}

.btn-action-edit:hover {
  background: rgba(56, 189, 248, 0.15);
}

.btn-action-delete {
  color: #f43f5e;
}

.btn-action-delete:hover {
  background: rgba(244, 63, 94, 0.15);
}

.text-right {
  text-align: right;
}

/* Estados de carga y vacío */
.empty-state, .loading-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--primary-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

/* Modales */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  padding: 28px;
  animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.modal-sm {
  max-width: 400px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-subtle);
  font-size: 24px;
  cursor: pointer;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group.full-width {
  grid-column: span 2;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.justify-center {
  justify-content: center;
}

.delete-icon-wrap {
  font-size: 44px;
  margin-bottom: 12px;
}

/* Botón Módulo Pendientes */
.btn-pendientes {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--accent-amber);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition-normal);
}

.btn-pendientes:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--accent-amber);
  transform: translateY(-1px);
}

.btn-pendientes.has-pending {
  background: rgba(245, 158, 11, 0.22);
  border-color: var(--accent-amber);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.3);
  animation: pulseAmber 2s infinite;
}

@keyframes pulseAmber {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* Listado de Pendientes */
.pending-list-wrap {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
  padding-right: 4px;
}

.pending-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-glass);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.pending-item:hover {
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(26, 38, 64, 0.7);
}

.pending-item-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pending-badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.pending-badge.crear {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.pending-badge.editar {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.pending-badge.eliminar {
  background: rgba(244, 63, 94, 0.2);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.pending-item-details {
  display: flex;
  flex-direction: column;
}

.pending-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.pending-item-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.pending-item-time {
  font-size: 11px;
  color: var(--text-subtle);
}

.empty-pending {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
  font-size: 14px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px dashed var(--border-glass);
  border-radius: var(--radius-md);
}

/* Toasts flotantes */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-glass);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease;
  max-width: 340px;
}

.toast.success {
  border-left: 4px solid var(--accent-emerald);
}

.toast.error {
  border-left: 4px solid var(--accent-rose);
}

.toast.warning {
  border-left: 4px solid var(--accent-amber);
}

.toast.info {
  border-left: 4px solid var(--primary-400);
}

/* Clases utilitarias */
.hidden {
  display: none !important;
}

.text-danger {
  color: #fb7185;
}

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

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

@keyframes scaleUp {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

/* ==========================================================================
   COMPONENTES: TARJETAS RESPONSIVE Y BOTÓN FLOTANTE (FAB)
   ========================================================================== */

/* Contenedor de Tarjetas (Oculto por defecto en escritorios / laptops) */
.view-cards-container {
  display: none;
  width: 100%;
}

/* Tarjeta de Contacto Estilizada */
.contact-card-responsive {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: blur(10px);
  transition: var(--transition-normal);
  position: relative;
}

.contact-card-responsive:hover {
  border-color: var(--border-glass-hover);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transform: translateY(-2px);
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.card-avatar-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
  flex-shrink: 0;
}

.card-user-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.card-user-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.card-prof-badge {
  font-size: 11px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: var(--primary-400);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Botón de Llamada Rápida Directa */
.btn-quick-call {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  text-decoration: none;
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.btn-quick-call:hover {
  background: rgba(16, 185, 129, 0.3);
  border-color: #34d399;
  transform: scale(1.06);
  color: #fff;
}

/* Cuadrícula de detalles internos */
.card-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  background: rgba(0, 0, 0, 0.22);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.card-detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 11px;
  color: var(--text-subtle);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.detail-value {
  font-size: 13px;
  color: var(--text-main);
  font-weight: 500;
  word-break: break-word;
}

.phone-value {
  color: var(--primary-400);
  text-decoration: none;
}

.phone-value:hover {
  text-decoration: underline;
}

/* Barra de acciones de tarjeta */
.card-actions-bar {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.btn-card-edit, .btn-card-delete {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition-fast);
  border: 1px solid transparent;
}

.btn-card-edit {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.25);
  color: var(--primary-400);
}

.btn-card-edit:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--primary-400);
}

.btn-card-delete {
  background: rgba(244, 63, 94, 0.08);
  border-color: rgba(244, 63, 94, 0.25);
  color: #fb7185;
}

.btn-card-delete:hover {
  background: rgba(244, 63, 94, 0.2);
  border-color: #fb7185;
}

/* Botón Flotante de Acción Rápida (FAB) */
.fab-mobile-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #fff;
  border: none;
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
  font-size: 24px;
  cursor: pointer;
  z-index: 95;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}

.fab-mobile-btn:active {
  transform: scale(0.92);
}

/* ==========================================================================
   TRANSFORMACIÓN ESTRUCTURAL SEGÚN DISPOSITIVO
   ========================================================================== */

/* 1. DISPOSITIVOS PORTÁTILES Y ESCRITORIO (> 992px): TABLA ADMINISTRATIVA */
@media (min-width: 993px) {
  .view-desktop-table {
    display: block !important;
  }
  .view-cards-container {
    display: none !important;
  }
  .fab-mobile-btn {
    display: none !important;
  }
}

/* 2. TABLETS (641px a 992px): CUADRÍCULA DE 2 COLUMNAS */
@media (min-width: 641px) and (max-width: 992px) {
  /* La tabla se oculta */
  .view-desktop-table {
    display: none !important;
  }

  /* La interfaz se transforma en una cuadrícula de 2 columnas */
  .view-cards-container {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 8px 0;
  }

  .fab-mobile-btn {
    display: none !important;
  }

  .dashboard-topbar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .topbar-actions {
    flex-wrap: wrap;
    gap: 10px;
  }

  .search-bar-wrap {
    flex-direction: row;
  }

  .search-input-box {
    flex: 1;
  }
}

/* 3. TELÉFONOS MÓVILES (<= 640px): AGENDA MÓVIL NATIVA + FAB + BOTTOM SHEET */
@media (max-width: 640px) {
  /* La tabla desaparece completamente */
  .view-desktop-table {
    display: none !important;
  }

  /* La interfaz se transforma en una lista vertical táctil */
  .view-cards-container {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    padding: 4px 0;
  }

  /* Ocultar botón superior "+ Agregar Contacto" para dar paso al FAB */
  .btn-add-desktop {
    display: none !important;
  }

  /* Activar botón flotante FAB en la esquina inferior */
  .fab-mobile-btn {
    display: flex !important;
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  /* Tarjeta móvil optimizada para pulgares */
  .contact-card-responsive {
    padding: 14px;
    gap: 10px;
    border-radius: var(--radius-lg);
    background: rgba(18, 26, 43, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .card-avatar {
    width: 46px;
    height: 46px;
    font-size: 18px;
  }

  .card-user-name {
    font-size: 15px;
  }

  .btn-quick-call {
    width: 44px;
    height: 44px;
    font-size: 19px;
    background: rgba(16, 185, 129, 0.22);
    border-color: rgba(16, 185, 129, 0.5);
  }

  .card-details-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .card-actions-bar {
    gap: 8px;
  }

  .btn-card-edit, .btn-card-delete {
    padding: 10px 8px;
    font-size: 13px;
  }

  /* Transformación del Modal en Bottom Sheet (Hoja Deslizable Inferior) */
  .modal-backdrop {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .modal-card.modal-sheet {
    max-width: 100% !important;
    border-radius: 24px 24px 0 0 !important;
    padding: 24px 18px 32px !important;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUpBottom 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: 0 -10px 35px rgba(0, 0, 0, 0.7);
    border-bottom: none;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .form-group.full-width {
    grid-column: span 1 !important;
  }

  /* Header móvil compacto */
  .header-container {
    padding: 10px 14px;
    gap: 8px;
  }

  .brand-title {
    font-size: 16px;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
  }

  .user-email {
    max-width: 90px;
    font-size: 11px;
  }

  .inactivity-timer {
    font-size: 11px;
    padding: 3px 8px;
  }

  .btn-apk-header span {
    display: none;
  }

  .dashboard-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .topbar-actions {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .topbar-actions .btn-pendientes {
    width: 100%;
    justify-content: center;
  }

  .search-bar-wrap {
    flex-direction: column;
    gap: 10px;
  }

  .search-meta {
    justify-content: space-between;
    width: 100%;
  }
}

@keyframes slideUpBottom {
  from {
    transform: translateY(100%);
    opacity: 0.5;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
