/* Variables globales */
:root {
  /* Colores principales */
  --primary-color: #4a6cf7;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  --dark-color: #343a40;
  --light-color: #f8f9fa;

  /* Colores de canales */
  --whatsapp-color: #25d366;
  --instagram-color: #e1306c;
  --facebook-color: #1877f2;
  --email-color: #ff7f50;
  --woocommerce-color: #96588a;

  /* Colores de fondo */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f8fb;
  --bg-dark: #1f2937;

  /* Colores de texto */
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-light: #e5e7eb;

  /* Dimensiones */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 80px;
  --header-height: 70px;
  --border-radius: 10px;

  /* Sombras */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
    0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Transiciones */
  --transition: all 0.3s ease;
}

/* Reseteo y estilos generales */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Poppins", sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

input,
button {
  outline: none;
}

/* Estructura principal */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar / Navegación lateral */
.sidebar {
  width: 280px;
  transition: var(--transition);
}

.sidebar-nav li[data-role="admin"] {
  display: none;
}

.sidebar-nav li[data-role="admin"].is-visible {
  display: block;
}

.sidebar-nav .badge-hidden {
  display: none;
}

.search-bar input:focus {
  width: 350px;
}

.search-bar i {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
}

.notifications {
  position: relative;
  margin-right: 20px;
  font-size: 1.2rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background-color: var(--danger-color);
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-nav .badge[data-unread="0"] {
  display: none;
}

.user-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
}

.user-menu:hover {
  box-shadow: var(--shadow);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.user-summary {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.user-menu-toggle {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: var(--bg-primary);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 10px 0;
  min-width: 180px;
  display: none;
  z-index: 20;
}

.user-dropdown.open {
  display: block;
}

.user-dropdown button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: var(--transition);
}

.user-dropdown button:hover {
  background: var(--bg-secondary);
  color: var(--primary-color);
}

/* Secciones de contenido */
.content-sections {
  padding: 30px;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

/* Dashboard */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background-color: var(--bg-primary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-right: 20px;
  color: white;
}

.stat-icon.whatsapp {
  background-color: var(--whatsapp-color);
}

.stat-icon.instagram {
  background-color: var(--instagram-color);
}

.stat-icon.facebook {
  background-color: var(--facebook-color);
}

.stat-icon.email {
  background-color: var(--email-color);
}

.stat-info h3 {
  font-size: 1.2rem;
  margin-bottom: 5px;
}

.stat-info p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.chart-card {
  background-color: var(--bg-primary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 20px;
  height: 300px;
}

.chart-card h3 {
  margin-bottom: 20px;
  font-size: 1.2rem;
}

.chart-container {
  height: 220px;
}

.recent-messages {
  background-color: var(--bg-primary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.recent-messages h3 {
  margin-bottom: 20px;
  font-size: 1.2rem;
}

/* Chat */

.chat-container {
  display: grid;
  grid-template-columns: minmax(240px, 0.95fr) minmax(360px, 1.8fr) minmax(260px, 1.1fr);
  grid-template-areas: "sidebar main info";
  gap: 0;
  height: calc(100vh - var(--header-height) - 60px);
  background-color: var(--bg-primary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 600px; /* Altura mínima para evitar problemas con zoom */
}

.chat-sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--bg-secondary);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-search {
  padding: 15px;
  position: relative;
  border-bottom: 1px solid var(--bg-secondary);
}

.chat-search input {
  width: 100%;
  padding: 10px 15px 10px 40px;
  border: none;
  background-color: var(--bg-secondary);
  border-radius: 20px;
}

.chat-search i {
  position: absolute;
  left: 30px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
}

.chat-list {
  flex-grow: 1;
  overflow-y: auto;
  padding: 10px;
}

.chat-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0; /* Asegurar que flex funcione correctamente */
  position: relative; /* Para controlar el posicionamiento */
}

.chat-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-contact {
  display: flex;
  align-items: center;
}

.chat-contact img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 15px;
}

.chat-contact h3 {
  font-size: 1.1rem;
  margin-bottom: 3px;
}

.chat-contact p {
  font-size: 0.8rem;
  color: var(--success-color);
}

.chat-actions button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  margin-left: 10px;
  color: var(--text-secondary);
  font-size: 1rem;
  transition: var(--transition);
}

.chat-actions button:hover {
  background-color: var(--primary-color);
  color: white;
}

.chat-messages {
  flex-grow: 1;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--bg-secondary);
  height: 0; /* Fuerza el contenedor a usar flex-grow correctamente */
  scroll-behavior: smooth;
  min-height: 300px; /* Altura mínima para evitar problemas */
  max-height: calc(100vh - 200px); /* Altura máxima para controlar el viewport */
}

.chat-input {
  padding: 15px 20px;
  border-top: 1px solid var(--bg-secondary);
  display: flex;
  align-items: center;
  background-color: var(--bg-primary);
  min-height: 70px; /* Altura mínima para asegurar visibilidad */
  position: relative;
  z-index: 1; /* Asegurar que esté por encima de otros elementos */
}

.chat-input input {
  flex-grow: 1;
  padding: 12px 15px;
  border: 1px solid var(--bg-secondary);
  border-radius: 20px;
  margin: 0 15px;
  font-size: 14px;
  background-color: white;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.chat-input input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(74, 108, 247, 0.2);
}

.chat-input input:disabled {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: not-allowed;
}

.chat-input button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 1rem;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-input button:hover:not(:disabled) {
  background-color: var(--primary-color);
  color: white;
  transform: scale(1.05);
}

.chat-input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-info {
  grid-area: info;
  border-left: 1px solid var(--bg-secondary);
  padding: 24px;
  overflow-y: auto;
  background: #f7f9fc;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.chat-info section {
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.contact-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.contact-identity {
  display: flex;
  align-items: center;
  gap: 16px;
}

.contact-avatar-text {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.2rem;
}

.contact-heading h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

.contact-heading p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.contact-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.meta-item {
  background: var(--bg-secondary);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.meta-value {
  font-weight: 600;
  font-size: 0.9rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(74, 108, 247, 0.12);
  color: var(--primary-color);
  font-weight: 600;
  font-size: 0.75rem;
}

.meta-pill.status-open {
  background: rgba(40, 167, 69, 0.14);
  color: var(--success-color);
}

.meta-pill.status-closed {
  background: rgba(220, 53, 69, 0.14);
  color: var(--danger-color);
}

.meta-pill.status-archived {
  background: rgba(108, 117, 125, 0.14);
  color: var(--secondary-color);
}

.contact-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.contact-actions button {
  padding: 10px 16px;
  background-color: #f1f4ff;
  border-radius: 12px;
  color: var(--primary-color);
  font-size: 0.88rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.contact-actions button:hover {
  background-color: var(--primary-color);
  color: #fff;
}

.conversation-summary h4,
.media-shared h4 {
  font-size: 1rem;
  margin-bottom: 16px;
}

.conversation-stats {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.conversation-stats li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-secondary);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stat-value {
  font-weight: 600;
  font-size: 0.9rem;
}

.chat-agent {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

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

.media-header button {
  background: var(--bg-secondary);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.media-header button:hover {
  background: var(--primary-color);
  color: #fff;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 12px;
}

.empty-media {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.users-wrapper {
  background: var(--bg-primary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.users-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.users-header h2 {
  font-size: 1.4rem;
  font-weight: 600;
}

.users-header p {
  color: var(--text-secondary);
}

.users-filters {
  display: flex;
  gap: 10px;
}

.pending-users {
  display: grid;
  gap: 16px;
}

.pending-user-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--bg-secondary);
  border-radius: 16px;
  padding: 18px 20px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.pending-user-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.pending-user-info span {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.pending-user-info strong {
  color: var(--text-primary);
  font-size: 1rem;
}

.pending-user-info span small {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.pending-user-actions {
  display: flex;
  gap: 10px;
}

.pending-user-actions button {
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: 600;
  color: #fff;
}

.pending-user-actions .approve {
  background: var(--success-color);
}

.pending-user-actions .reject {
  background: var(--danger-color);
}

.pending-user-actions button:hover {
  filter: brightness(0.92);
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: 18px;
}

.empty-state i {
  font-size: 2.4rem;
  margin-bottom: 10px;
  color: var(--primary-color);
}

/* Canales */
.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.channel-card {
  background-color: var(--bg-primary);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: var(--transition);
}

.channel-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.channel-header {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.channel-header i {
  font-size: 2rem;
  margin-right: 15px;
}

.channel-header.whatsapp i {
  color: var(--whatsapp-color);
}

.channel-header.instagram i {
  color: var(--instagram-color);
}

.channel-header.facebook i {
  color: var(--facebook-color);
}

.channel-header.email i {
  color: var(--email-color);
}

.channel-header.woocommerce i {
  color: var(--woocommerce-color);
}

.channel-status {
  margin-bottom: 20px;
}

.channel-status span {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
}

.channel-status.active span {
  background-color: var(--success-color);
  color: white;
}

.channel-status.inactive span {
  background-color: var(--danger-color);
  color: white;
}

.channel-stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.stat p {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 5px;
}

.stat span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.channel-actions {
  display: flex;
  gap: 10px;
}

.btn-primary {
  padding: 10px 20px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 5px;
  transition: var(--transition);
}

.btn-primary:hover {
  background-color: #3851e0;
}

.btn-secondary {
  padding: 10px 20px;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 5px;
  transition: var(--transition);
}

.btn-secondary:hover {
  background-color: #e2e8f0;
}

.channel-connect {
  text-align: center;
  padding: 30px 0;
}

.channel-connect p {
  margin-bottom: 20px;
  color: var(--text-secondary);
}

/* Mensajes de chat */
.message {
  display: flex;
  margin-bottom: 20px;
  clear: both; /* Asegurar que cada mensaje se posicione correctamente */
  min-height: 40px; /* Altura mínima para cada mensaje */
}

.message.incoming {
  justify-content: flex-start;
}

.message.outgoing {
  justify-content: flex-end;
}

.message-content {
  max-width: 70%;
  padding: 15px;
  border-radius: 15px;
  position: relative;
  word-wrap: break-word; /* Evitar que el texto se salga del contenedor */
  overflow-wrap: break-word;
}

.message.incoming .message-content {
  background-color: var(--bg-primary);
  border-top-left-radius: 0;
}

.message.outgoing .message-content {
  background-color: var(--primary-color);
  color: white;
  border-top-right-radius: 0;
}

.message-agent {
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-secondary);
  gap: 4px;
}

.message.outgoing .message-agent {
  color: rgba(255, 255, 255, 0.85);
}

.message-time {
  font-size: 0.7rem;
  margin-top: 5px;
  text-align: right;
}

.message.incoming .message-time {
  color: var(--text-secondary);
}

.message.outgoing .message-time {
  color: rgba(255, 255, 255, 0.8);
}

/* Animaciones */
@keyframes slideInLeft {
  from {
    transform: translateX(-30px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

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

.animate-slide-left {
  animation: slideInLeft 0.3s ease forwards;
}

.animate-slide-right {
  animation: slideInRight 0.3s ease forwards;
}

.animate-fade {
  animation: fadeIn 0.3s ease forwards;
}

/* Estilos responsive */
@media (max-width: 1280px) {
  .chat-container {
    grid-template-columns: minmax(220px, 0.9fr) minmax(320px, 1.6fr);
    grid-template-areas:
      "sidebar main"
      "info info";
    height: auto;
  }

  .chat-info {
    border-left: none;
    border-top: 1px solid var(--bg-secondary);
    background: var(--bg-primary);
  }
}

@media (max-width: 992px) {
  .sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .sidebar .logo span,
  .sidebar-nav ul li a span {
    display: none;
  }

  .sidebar-nav ul li a {
    justify-content: center;
    padding: 12px;
  }

  .sidebar-nav ul li a i {
    margin-right: 0;
  }

  .main-content {
    margin-left: 0;
  }

  .dashboard-charts {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .chat-container {
    grid-template-columns: 1fr;
    grid-template-areas:
      "main"
      "info";
    height: auto;
  }

  .chat-sidebar {
    grid-area: sidebar;
    width: 85%;
    max-width: 360px;
    display: none;
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    z-index: 20;
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
  }

  .chat-sidebar.active {
    display: flex;
  }

  .chat-info {
    padding: 16px;
    background: var(--bg-secondary);
  }

  .header {
    padding: 0 15px;
  }

  .search-bar input {
    width: 200px;
  }

  .search-bar input:focus {
    width: 200px;
  }

  .user-summary {
    display: none;
  }
}

@media (max-width: 576px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
  }

  .sidebar.mobile-active {
    transform: translateX(0);
  }

  .content-sections {
    padding: 15px;
  }

  .dashboard-stats {
    grid-template-columns: 1fr;
  }

  .search-bar {
    display: none;
  }
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

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

.logo {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--primary-color);
}

.logo i {
  margin-right: 10px;
  font-size: 1.8rem;
}

.sidebar-toggle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  padding: 5px;
  border-radius: 5px;
  transition: var(--transition);
}

.sidebar-toggle:hover {
  background-color: var(--bg-secondary);
  color: var(--primary-color);
}

.sidebar-nav {
  flex-grow: 1;
  padding: 20px 0;
  overflow-y: auto;
}

.sidebar-nav ul li {
  margin-bottom: 5px;
}

.sidebar-nav ul li a {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--text-secondary);
  transition: var(--transition);
  border-radius: 8px;
  margin: 0 10px;
}

.sidebar-nav ul li a i {
  margin-right: 15px;
  font-size: 1.2rem;
  width: 20px;
  text-align: center;
}

.sidebar-nav ul li a:hover {
  background-color: var(--bg-secondary);
  color: var(--primary-color);
}

.sidebar-nav ul li.active a {
  background-color: var(--primary-color);
  color: white;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--bg-secondary);
}

.channel-status {
  display: flex;
  justify-content: space-around;
}

.channel {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 1.2rem;
  transition: var(--transition);
}

.channel.active {
  color: white;
}

.channel.whatsapp.active {
  background-color: var(--whatsapp-color);
}

.channel.instagram.active {
  background-color: var(--instagram-color);
}

.channel.facebook.active {
  background-color: var(--facebook-color);
}

.channel.email.active {
  background-color: var(--email-color);
}

.channel.woocommerce.active {
  background-color: var(--woocommerce-color);
}

/* Contenido principal */
.main-content {
  flex-grow: 1;
  margin-left: 0;
  transition: var(--transition);
}

/* Encabezado */
.header {
  height: var(--header-height);
  background-color: var(--bg-primary);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
}

.header-left h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
}

.search-bar {
  position: relative;
  margin-right: 20px;
}

.search-bar input {
  background-color: var(--bg-secondary);
  border: none;
  border-radius: 20px;
  padding: 10px 15px 10px 40px;
  width: 100%;
}

/* Adiciones para mejorar la interfaz de usuario */

/* Sistema de notificaciones */
.notification-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 350px;
}

.notification {
  background-color: var(--bg-primary);
  border-left: 4px solid var(--primary-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  padding: 15px;
  display: flex;
  align-items: center;
  animation: slideInRight 0.3s ease forwards;
}

.notification.success {
  border-left-color: var(--success-color);
}

.notification.error {
  border-left-color: var(--danger-color);
}

.notification.warning {
  border-left-color: var(--warning-color);
}

.notification i {
  font-size: 1.2rem;
  margin-right: 10px;
}

.notification.success i {
  color: var(--success-color);
}

.notification.error i {
  color: var(--danger-color);
}

.notification.warning i {
  color: var(--warning-color);
}

.notification span {
  flex-grow: 1;
  margin-right: 10px;
}

.notification .close-notification {
  background: none;
  border: none;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.notification.fade-out {
  opacity: 0;
  transform: translateX(30px);
  transition: all 0.3s ease;
}

/* Mejoras para avatares */
.chat-avatar-text,
.contact-avatar-text {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  margin-right: 10px;
}

.contact-avatar-text {
  width: 100px;
  height: 100px;
  font-size: 2.5rem;
  margin-bottom: 15px;
}

/* Mejoras para separadores de fecha en mensajes */
.date-separator {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin: 20px 0;
  position: relative;
}

.date-separator::before,
.date-separator::after {
  content: "";
  position: absolute;
  top: 50%;
  height: 1px;
  background-color: var(--bg-secondary);
}

.date-separator::before {
  left: 0;
  right: 60%;
}

.date-separator::after {
  right: 0;
  left: 60%;
}

/* Indicador de carga */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-secondary);
}

.loading::after {
  content: "";
  width: 20px;
  height: 20px;
  border: 3px solid var(--bg-secondary);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  margin-left: 10px;
  animation: spin 1s linear infinite;
}

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

/* Mensajes de error y chat vacío */
.error-message,
.empty-chat,
.empty-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.empty-chat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
}

.empty-chat::before {
  content: "💬";
  font-size: 3rem;
  margin-bottom: 15px;
  opacity: 0.5;
}

.error-message {
  color: var(--danger-color);
}

.retry-button {
  background-color: var(--bg-secondary);
  border: none;
  border-radius: 20px;
  padding: 5px 15px;
  margin-left: 10px;
  color: var(--primary-color);
  cursor: pointer;
  transition: var(--transition);
}

.retry-button:hover {
  background-color: var(--primary-color);
  color: white;
}

/* Mejoras para estados de mensajes */
.message.outgoing .message-time i {
  margin-left: 5px;
}

.message .text-blue {
  color: var(--primary-color);
}

.message .text-red {
  color: var(--danger-color);
}

/* Badge para conteo de no leídos en el sidebar */
.sidebar-nav .badge {
  position: absolute;
  right: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--danger-color);
  color: white;
  border-radius: 50%;
  min-width: 20px;
  height: 20px;
  font-size: 0.7rem;
  padding: 0 5px;
}

/* Estilos para mensajes específicos por canal */
.message.incoming .message-content.whatsapp {
  background-color: #dcf8c6;
  color: var(--text-primary);
}

.message.outgoing .message-content.whatsapp {
  background-color: #e2f7cb;
  color: var(--text-primary);
}

.message.incoming .message-content.instagram {
  background-color: #e1306c;
  background: linear-gradient(
    45deg,
    #405de6,
    #5851db,
    #833ab4,
    #c13584,
    #e1306c,
    #fd1d1d
  );
  color: white;
}

.message.incoming .message-content.facebook {
  background-color: #1877f2;
  color: white;
}

/* Mejoras para las listas de chat */
.chat-item {
  padding: 15px;
  border-radius: var(--border-radius);
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}

.chat-item:hover,
.chat-item.active {
  background-color: var(--bg-secondary);
}

.chat-item.active {
  background-color: rgba(74, 108, 247, 0.1);
}

.chat-item .chat-preview {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-item .chat-preview p {
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
  font-size: 0.8rem;
  max-width: 100%;
}

.chat-item .chat-preview .unread-badge {
  align-self: flex-end;
}

.unread-badge {
  background-color: var(--primary-color);
  color: white;
  border-radius: 50%;
  min-width: 20px;
  height: 20px;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* Vista móvil para chat */
@media (max-width: 768px) {
  .chat-container {
    flex-direction: column;
  }

  .chat-sidebar {
    width: 100%;
    height: auto;
    max-height: 40vh;
  }

  .chat-main {
    height: 60vh;
  }

  .chat-messages {
    max-height: calc(60vh - 140px);
  }

  .chat-input {
    padding: 10px 15px;
    min-height: 60px;
  }

  .chat-input input {
    font-size: 16px; /* Evitar zoom en iOS */
    margin: 0 10px;
  }

  .chat-input button {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }
}

/* Mejoras para vista de dashboard en móvil */
@media (max-width: 576px) {
  .dashboard-stats {
    grid-template-columns: 1fr;
  }

  .dashboard-charts {
    grid-template-columns: 1fr;
  }
}

/* Correcciones para UI móvil - Añadir al final de styles.css */

/* Menú hamburguesa para móviles */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1000;
  width: 40px;
  height: 40px;
  background-color: var(--primary-color);
  border-radius: 50%;
  color: white;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  cursor: pointer;
}

/* Overlay para cerrar el menú cuando está abierto */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

/* Mejoras para responsividad */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }

  .app-container {
    position: relative;
    overflow-x: hidden;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -300px; /* Comenzar fuera de la pantalla */
    height: 100vh;
    z-index: 100;
    transition: all 0.3s ease;
    background-color: white;
    width: 280px !important;
    max-width: 85vw;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.mobile-active {
    left: 0;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main-content {
    width: 100%;
    margin-left: 0;
  }

  /* Rediseño del header para móvil */
  .header {
    padding: 0 15px 0 60px; /* Espacio para el botón de menú */
  }

  .header-left h1 {
    font-size: 1.2rem;
  }

  .search-bar {
    display: none;
  }

  .user-summary {
    display: none;
  }

  /* Mejoras para tarjetas en móvil */
  .stat-card,
  .channel-card,
  .chart-card {
    margin-bottom: 15px;
  }

  /* Ajustar el tamaño de los iconos para mejorar la usabilidad en móvil */
  .sidebar-nav ul li a i {
    font-size: 1.3rem;
  }

  .chat-input button,
  .chat-actions button {
    width: 45px;
    height: 45px;
  }
}

/* Fijaciones adicionales para dispositivos muy pequeños */
@media (max-width: 375px) {
  .header {
    padding: 0 10px 0 50px;
  }

  .content-sections {
    padding: 10px;
  }

  .notifications {
    margin-right: 10px;
  }

  .dashboard-stats {
    grid-template-columns: 1fr;
  }
}

/* Animaciones mejoradas para interactividad en móvil */
.sidebar.mobile-active {
  animation: slideInRight 0.3s ease forwards;
}

@keyframes slideInRight {
  from {
    transform: translateX(-280px);
  }
  to {
    transform: translateX(0);
  }
}

/* Estilos para botones de "pull-to-refresh" y cargar más mensajes */
.pull-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.pull-indicator i {
  margin-right: 10px;
  animation: spin 1s linear infinite;
}

.load-more-button {
  display: block;
  width: 80%;
  margin: 10px auto;
  padding: 8px 0;
  text-align: center;
  background-color: var(--bg-secondary);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: var(--transition);
}

.load-more-button:hover {
  background-color: var(--primary-color);
  color: white;
}

/* Mejora para la usabilidad de la barra de búsqueda en móvil */
.mobile-search-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-right: 10px;
}

@media (max-width: 768px) {
  .mobile-search-toggle {
    display: flex;
  }

  .search-bar.mobile-active {
    display: block;
    position: absolute;
    top: 60px;
    left: 0;
    width: 100%;
    padding: 10px 15px;
    background-color: white;
    z-index: 80;
    box-shadow: var(--shadow);
  }

  .search-bar.mobile-active input {
    width: 100%;
  }
}
