/* ===================================
   CAPACIDADES TECNOLÓGICAS - GRID VIEW
   Hoja de estilos principal
   =================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-primary: #007fa3;
  --color-secondary: #ce0058;
  --bg-light: #f5f7fa;
  --bg-white: #ffffff;
  --text-dark: #2c3e50;
  --text-muted: #6c757d;
  --border-light: #e1e8ed;
}

body {
  font-family: "Poppins", sans-serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8edf3 100%);
  color: var(--text-dark);
  min-height: 100vh;
}

/* ===================================
   HEADER COLAPSABLE CON OLA
   =================================== */
.header-with-wave {
  background: linear-gradient(
    135deg,
    var(--color-primary),
    var(--color-secondary)
  );
  position: relative;
  overflow: visible;
  min-height: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  transition: min-height 0.3s ease; /* Transición más rápida */
}

.header-with-wave.collapsed {
  min-height: 200px; /* Suficiente para wave + logo */
}

/* Cuando hay conversación activa, el header crece */
.header-with-wave.has-conversation {
  min-height: 950px; /* 280px (hasta el container) + 670px (nuevo max-height) = 950px */
}

/* Wave y logo permanecen visibles cuando colapsa */
.header-with-wave.collapsed .wave-top {
  opacity: 1;
  visibility: visible;
}

.header-with-wave.collapsed .header-logo {
  max-height: 100px; /* Más pequeño pero visible */
  margin-bottom: 0;
}

/* Logo grande cuando hay conversación activa */
.header-with-wave.has-conversation .header-logo {
  max-height: 150px;
  margin-bottom: 20px;
}

/* Solo ocultar título y chat input inicial */
.header-with-wave.collapsed h1,
.header-with-wave.collapsed .header-subtitle,
.header-with-wave.collapsed #chatInputInitial {
  opacity: 0;
  visibility: hidden;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Ola superior - grande y visible */
.wave-top {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 250px;
  z-index: 100; /* MUY por encima para que siempre se vea */
  pointer-events: none;
  transition: all 0.6s ease, opacity 0.6s ease, visibility 0.6s ease;
}

.wave-top svg {
  width: 100%;
  height: 275px;
  display: block;
}

.wave-top path {
  transition: fill 0.6s ease;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 101; /* Por encima del wave-top */
  transition: all 0.6s ease;
  padding: 20px;
  padding-top: 40px;
}

.header-logo {
  max-height: 150px;
  margin-bottom: 30px;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.3));
  position: relative;
  z-index: 2;
  transition: all 0.6s ease;
}

.header-with-wave h1 {
  font-size: 3rem;
  font-weight: 900;
  color: white;
  margin-bottom: 12px;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  position: relative;
  z-index: 2;
  transition: all 0.6s ease, opacity 0.6s ease, visibility 0.6s ease;
}

.header-subtitle {
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.95);
  font-weight: 400;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 2;
  transition: all 0.6s ease, opacity 0.6s ease, visibility 0.6s ease;
  overflow: hidden;
}

/* ===================================
   CONTENEDOR CONVERSACIONAL
   =================================== */
.conversation-container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  position: absolute;
  top: 280px;
  left: 0;
  z-index: 0;
  opacity: 0;
  visibility: hidden;
  height: 0;
  overflow: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, height 0s 0.3s;
  background: white;
}

.conversation-container.active {
  opacity: 1;
  visibility: visible;
  height: 670px; /* Altura fija, no max-height */
  padding-top: 5px;
  padding-bottom: 5px;
  overflow: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease, height 0s;
}

/* Wave invertido - perfecta continuidad con wave-top */
.conversation-wave {
  position: absolute;
  top: -20px; /* Subir el wave para que esté más arriba (ajustar según necesidad) */
  left: 0;
  width: 100%;
  height: 300px; /* Altura del viewBox (0 0 1200 300) */
  z-index: 100; /* Por encima de todo el contenido */
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.conversation-wave.active {
  opacity: 1;
  visibility: visible;
}

.conversation-wave path {
  fill: white;
}

/* Mensajes del chat - comienzan DESPUÉS del wave */
.chat-messages {
  max-width: 1200px; /* Más ancho */
  width: 100%;
  margin: 0 auto;
  padding: 0 40px;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column-reverse;
  gap: 24px;
  min-height: 550px;
  max-height: 550px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Scrollbar personalizado para el chat */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 127, 163, 0.3);
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 127, 163, 0.5);
}

/* Input dentro de la conversación (sticky) */
.chat-input-conversation {
  position: sticky;
  bottom: 20px;
  z-index: 200;
  margin-top: 30px;
  box-shadow: 0 -10px 40px rgba(0, 127, 163, 0.15),
    0 20px 60px rgba(0, 127, 163, 0.25);
}

.chat-input-wrapper {
  max-width: 1200px; /* Mismo ancho que los mensajes */
  margin: 30px auto 0;
  background: white;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0, 127, 163, 0.1);
  border: 1px solid rgba(0, 127, 163, 0.15);
  display: flex;
  gap: 12px;
  transition: all 0.3s ease;
  position: relative;
  z-index: 3;
}

.chat-input-wrapper:hover {
  box-shadow: 0 4px 20px rgba(0, 127, 163, 0.15);
  border-color: rgba(0, 127, 163, 0.4);
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 0.95rem;
  border: 1px solid rgba(0, 127, 163, 0.1);
  border-radius: 12px;
  background: #FAFBFC;
  color: var(--text-dark);
  outline: none;
  transition: all 0.3s ease;
  font-family: "Poppins", sans-serif;
}

.chat-input:focus {
  background: white;
  border-color: rgba(0, 127, 163, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 127, 163, 0.1);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-send-btn {
  padding: 12px 24px;
  background: #007FA3;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.chat-send-btn:hover {
  background: linear-gradient(135deg, #007FA3, #006A8A);
  box-shadow: 0 4px 16px rgba(0, 127, 163, 0.3);
  transform: translateY(-1px);
}

.chat-send-btn:active {
  transform: scale(0.98);
}

.chat-send-btn .btn-icon {
  display: none; /* Ocultar emoji del botón */
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: messageSlideIn 0.4s ease;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.user {
  align-items: flex-end;
}

.chat-message.ai {
  align-items: flex-start;
}

/* Etiqueta pequeña para identificar quién habla */
.message-avatar {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6C757D;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0 4px;
  margin-bottom: 4px;
}

.chat-message.user .message-avatar::before {
  content: "Tú";
}

.chat-message.ai .message-avatar::before {
  content: "Asistente";
}

.message-content {
  max-width: 85%;
  padding: 16px 20px;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 0.95rem;
}

.chat-message.user .message-content {
  background: linear-gradient(135deg, #007FA3 0%, #0096C7 100%);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 127, 163, 0.2);
}

.chat-message.ai .message-content {
  background: #F7F9FB;
  color: var(--text-dark);
  border: 1px solid rgba(0, 127, 163, 0.12);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 127, 163, 0.06);
}

.message-thinking {
  display: flex;
  gap: 5px;
  padding: 12px;
  align-items: center;
}

.message-thinking span {
  width: 6px;
  height: 6px;
  background: #007FA3;
  border-radius: 50%;
  animation: thinking 1.4s ease-in-out infinite;
}

.message-thinking span:nth-child(2) {
  animation-delay: 0.2s;
}

.message-thinking span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinking {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Capacidades en la respuesta */
.capacity-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.capacity-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: white;
  border: 2px solid var(--color-primary);
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.capacity-chip:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 127, 163, 0.3);
}

/* ===================================
   FILTROS
   =================================== */
.filters-section {
  max-width: 1400px;
  margin: 0 auto 40px;
  padding: 0 20px;
  position: relative;
  z-index: 10;
  transition: margin-top 0.5s ease;
}

/* Empujar filters-section hacia abajo cuando hay conversación activa */
.header-with-wave.has-conversation ~ .filters-section {
  margin-top: 60px; /* Espacio después del header con conversación */
}

/* Espacio después del header normal (sin conversación) */
.header-with-wave:not(.has-conversation) ~ .filters-section {
  margin-top: 40px;
}

.filters-card {
  background: white;
  border-radius: 24px;
  box-shadow: 0 8px 32px rgba(0, 127, 163, 0.12);
  overflow: hidden;
}

/* Sistema de pestañas */
.tabs-container {
  display: flex;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8edf3 100%);
  border-bottom: 2px solid #e0e0e0;
}

.tab-button {
  flex: 1;
  padding: 20px 30px;
  border: none;
  background: transparent;
  font-family: "Poppins", sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: #6c757d;
  cursor: pointer;
  position: relative;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.tab-button::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--color-primary),
    var(--color-secondary)
  );
  transform: translateX(-50%);
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-button:hover {
  color: var(--color-primary);
  transform: translateY(-2px);
}

.tab-button.active {
  color: var(--color-primary);
  background: white;
}

.tab-button.active::before {
  width: 80%;
}

.tab-icon {
  font-size: 1.5rem;
  transition: transform 0.3s ease;
}

.tab-button.active .tab-icon {
  transform: scale(1.2) rotate(5deg);
}

/* Contenido de pestañas */
.tab-content {
  padding: 30px;
  display: none;
  animation: fadeInUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-content.active {
  display: block;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.filters-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  animation: staggerIn 0.6s ease;
}

@keyframes staggerIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.filter-btn,
.filter-btn-func {
  padding: 12px 24px;
  border: 2px solid var(--border-light);
  background: white;
  border-radius: 25px;
  font-family: "Poppins", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.filter-btn::before,
.filter-btn-func::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 127, 163, 0.2), transparent);
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.filter-btn:hover::before,
.filter-btn-func:hover::before {
  width: 300px;
  height: 300px;
}

.filter-btn:hover,
.filter-btn-func:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 20px rgba(0, 127, 163, 0.25);
}

.filter-btn.active,
.filter-btn-func.active {
  background: linear-gradient(
    135deg,
    var(--color-primary),
    var(--color-secondary)
  );
  color: white;
  border-color: transparent;
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(0, 127, 163, 0.35);
}

.filter-btn .count,
.filter-btn-func .count {
  margin-left: 8px;
  padding: 2px 8px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  font-size: 0.85rem;
  transition: all 0.3s ease;
}

.filter-btn.active .count,
.filter-btn-func.active .count {
  background: rgba(255, 255, 255, 0.2);
}

/* ===================================
   CONTAINER PRINCIPAL
   =================================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* Stats Bar con buscador integrado */
.stats-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
  padding: 20px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0, 127, 163, 0.1);
  flex-wrap: wrap;
}

.stats-info {
  display: flex;
  gap: 30px;
  flex: 1;
  min-width: 200px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-number {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(
    135deg,
    var(--color-primary),
    var(--color-secondary)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Buscador tradicional en stats-bar */
.quick-search {
  position: relative;
  flex: 1;
  max-width: 400px;
  min-width: 250px;
}

.quick-search-input {
  width: 100%;
  padding: 12px 40px 12px 15px;
  border: 2px solid var(--border-light);
  border-radius: 25px;
  font-size: 0.9rem;
  font-family: "Poppins", sans-serif;
  transition: all 0.3s ease;
}

.quick-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 4px 15px rgba(0, 127, 163, 0.15);
}

.quick-search-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.quick-search-icon {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
}

/* ===================================
   GRID DE TARJETAS
   =================================== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.capacity-card {
  background: white;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 4px 20px rgba(0, 127, 163, 0.1);
  border: 2px solid transparent;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.capacity-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(
    90deg,
    var(--color-primary),
    var(--color-secondary)
  );
  transform: scaleX(0);
  transition: transform 0.4s ease;
}

.capacity-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 40px rgba(0, 127, 163, 0.2);
  border-color: var(--color-primary);
}

.capacity-card:hover::before {
  transform: scaleX(1);
}

/* Imágenes de las tarjetas */
.card-image-container {
  position: relative;
  width: 100%;
  height: 180px;
  overflow: hidden;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8edf3 100%);
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.capacity-card:hover .card-image {
  transform: scale(1.1) rotate(2deg);
}

.card-image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.2) 0%,
    rgba(0, 0, 0, 0) 40%,
    rgba(0, 0, 0, 0.4) 100%
  );
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 12px;
}

.card-type-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.card-type-badge.type-caso {
  background: rgba(206, 0, 88, 0.95);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.card-type-badge.type-capacidad {
  background: rgba(0, 127, 163, 0.95);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.card-content {
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 15px;
  padding: 20px 20px 0 20px;
}

.card-type {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.type-caso {
  background: linear-gradient(
    135deg,
    rgba(206, 0, 88, 0.15),
    rgba(206, 0, 88, 0.25)
  );
  color: var(--color-secondary);
  border: 1px solid rgba(206, 0, 88, 0.3);
}

.type-capacidad {
  background: linear-gradient(
    135deg,
    rgba(0, 127, 163, 0.15),
    rgba(0, 127, 163, 0.25)
  );
  color: var(--color-primary);
  border: 1px solid rgba(0, 127, 163, 0.3);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 12px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-description {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: block;
  padding-top: 15px;
  border-top: 1px solid var(--border-light);
}

.card-group {
  font-size: 0.75rem;
  color: var(--color-primary);
  font-weight: 600;
  display: block;
}

/* No results */
.no-results {
  text-align: center;
  padding: 80px 20px;
}

.no-results-icon {
  font-size: 5rem;
  margin-bottom: 20px;
  opacity: 0.5;
}

.no-results h3 {
  font-size: 1.8rem;
  color: var(--text-dark);
  margin-bottom: 10px;
}

.no-results p {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* ===================================
   MODAL
   =================================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  padding: 20px;
}

.modal.active {
  opacity: 1;
  pointer-events: all;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(15px);
}

.modal-content {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.98),
    rgba(245, 247, 250, 0.98)
  );
  border: 2px solid rgba(0, 127, 163, 0.2);
  border-radius: 24px;
  max-width: 1000px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  position: relative;
  transform: scale(0.7) translateY(-100px);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: 0 50px 100px rgba(0, 127, 163, 0.3);
  scrollbar-gutter: stable;
}

.modal-content::-webkit-scrollbar {
  width: 10px;
}

.modal-content::-webkit-scrollbar-track {
  background: transparent;
  margin: 24px 0;
}

.modal-content::-webkit-scrollbar-thumb {
  background: rgba(0, 127, 163, 0.25);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: background 0.3s ease;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 127, 163, 0.5);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal-header-image {
  position: relative;
  width: 100%;
  height: 240px;
  background: linear-gradient(135deg, #007fa3, #ce0058);
  border-radius: 24px 24px 0 0;
  overflow: hidden;
}

.modal-header-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-header-image::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.7));
}

.modal-type-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 10px 20px;
  border-radius: 25px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
  color: white;
  z-index: 2;
}

.modal-type-badge.caso {
  background: rgba(206, 0, 88, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.modal-type-badge.capacidad {
  background: rgba(0, 127, 163, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.modal-body {
  padding: 30px;
}

.modal-close {
  position: absolute;
  top: 15px;
  left: 15px;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(0, 127, 163, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 22px;
  font-weight: bold;
  color: var(--color-primary);
  transition: all 0.3s ease;
  z-index: 3;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.modal-close:hover {
  background: var(--color-secondary);
  color: white;
  transform: rotate(90deg) scale(1.1);
  border-color: var(--color-secondary);
}

.modal-title {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--text-dark);
  margin-bottom: 18px;
  line-height: 1.2;
}

.modal-description {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 25px;
  text-align: justify;
}

.modal-section {
  margin-bottom: 30px;
}

.modal-section-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-section-content {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-dark);
  padding: 20px;
  background: rgba(0, 127, 163, 0.05);
  border-radius: 15px;
  border-left: 4px solid var(--color-primary);
}

.modal-details-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
  margin-bottom: 30px;
}

/* En escritorio: Madurez a la izquierda, Publicaciones a la derecha */
.modal-madurez-item {
  grid-column: 1 / 2;
  grid-row: 1;
}

.modal-publicaciones-item {
  grid-column: 2 / 3;
  grid-row: 1;
}

.modal-detail-item {
  background: rgba(255, 255, 255, 0.8);
  padding: 20px;
  border-radius: 15px;
  border: 2px solid var(--border-light);
  transition: all 0.3s ease;
}

.modal-detail-item:hover {
  transform: translateY(-5px);
  border-color: var(--color-primary);
  box-shadow: 0 10px 25px rgba(0, 127, 163, 0.15);
}

.modal-detail-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.modal-detail-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* Enlaces en publicaciones - estilos base */
#modalResponsables a {
  color: #ce0058 !important;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  transition: all 0.2s ease;
}

#modalResponsables a:hover {
  color: #007fa3 !important;
  text-decoration: none;
  background: rgba(0, 127, 163, 0.1) !important;
}

/* Barra de progreso de madurez */
#modalMadurezContainer {
  margin-top: 8px !important;
}

.madurez-progress-bar {
  width: 100%;
  height: 18px;
  background: #007fa3;
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(0, 127, 163, 0.3);
}

.madurez-progress-fill {
  height: 100%;
  background: #ce0058;
  border-radius: 18px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: 0 0 10px rgba(206, 0, 88, 0.3);
}

.madurez-progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0.1) 40%,
    rgba(0, 0, 0, 0.05) 100%
  );
  border-radius: 18px;
}

.madurez-label {
  margin-top: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a237e;
  text-align: left;
}

.madurez-description {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: left;
  font-style: italic;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 30px;
}

.modal-tag {
  padding: 8px 16px;
  background: linear-gradient(
    135deg,
    rgba(0, 127, 163, 0.1),
    rgba(206, 0, 88, 0.1)
  );
  border: 1px solid rgba(0, 127, 163, 0.3);
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
}

.modal-cta {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  margin-top: 30px;
  padding-top: 30px;
  border-top: 2px solid var(--border-light);
}

.modal-btn {
  flex: 1;
  min-width: 200px;
  padding: 16px 30px;
  border: none;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
  font-family: "Poppins", sans-serif;
}

.modal-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.modal-btn:hover::before {
  width: 400px;
  height: 400px;
}

.modal-btn-primary {
  background: linear-gradient(120deg, #007fa3, #ce0058);
  color: white;
  border: 2px solid transparent;
}

.modal-btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 40px rgba(0, 127, 163, 0.4);
}

.modal-btn-secondary {
  background: white;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.modal-btn-secondary:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(0, 127, 163, 0.3);
}

/* ===================================
   RESPONSIVE
   =================================== */
@media (max-width: 768px) {
  .header h1 {
    font-size: 2rem;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .stats-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .stats-info {
    flex-direction: column;
    gap: 15px;
  }

  .quick-search {
    max-width: 100%;
  }

  .tab-button {
    padding: 15px 20px;
    font-size: 0.95rem;
  }

  .tab-button span:not(.tab-icon) {
    display: none;
  }

  .tab-icon {
    font-size: 2rem;
  }

  .tab-content {
    padding: 20px;
  }

  .filters-grid {
    gap: 8px;
  }

  .filter-btn,
  .filter-btn-func {
    font-size: 0.85rem;
    padding: 10px 18px;
  }

  .modal-content {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
    overflow-y: auto;
  }

  .modal-body {
    padding: 20px;
  }

  .modal-title {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  .modal-header-image {
    height: 200px;
    border-radius: 0;
  }

  .modal-details-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  /* En móvil: Madurez arriba, Publicaciones debajo */
  .modal-madurez-item {
    grid-column: 1;
    grid-row: 1;
    order: 1;
  }

  .modal-publicaciones-item {
    grid-column: 1;
    grid-row: 2;
    order: 2;
  }

  .modal-detail-item {
    padding: 15px;
  }

  .modal-section-content {
    padding: 15px;
    font-size: 0.95rem;
  }

  .modal-btn {
    min-width: 100%;
    font-size: 0.9rem;
    padding: 14px 20px;
  }

  .modal-cta {
    flex-direction: column;
    gap: 12px;
  }

  .modal-close {
    width: 50px;
    height: 50px;
    font-size: 24px;
    top: 10px;
    left: 10px;
  }

  /* Enlaces en publicaciones - móvil */
  #modalResponsables a {
    display: inline-block !important;
    margin: 5px 4px !important;
    word-break: break-word;
    padding: 8px 12px !important;
    min-height: 44px !important;
    line-height: 1.4 !important;
    background: rgba(206, 0, 88, 0.1) !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
  }

  #modalResponsables a.publication-link {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(206, 0, 88, 0.3);
  }

  #modalResponsables a:active {
    background: rgba(206, 0, 88, 0.2) !important;
    transform: scale(0.98);
  }

  /* Responsive chat */
  .conversation-container {
    margin: -60px auto 40px;
  }

  .chat-input-wrapper {
    flex-direction: column;
    padding: 16px;
  }

  .chat-send-btn {
    width: 100%;
    justify-content: center;
  }

  .message-content {
    max-width: 85%;
    font-size: 0.95rem;
  }

  .capacity-chip {
    font-size: 0.8rem;
    padding: 5px 10px;
  }

  .header-with-wave.collapsed {
    padding: 20px 15px 60px;
  }
}

@media (max-width: 480px) {
  .quick-search-input {
    font-size: 0.85rem;
  }

  .filter-btn .count,
  .filter-btn-func .count {
    font-size: 0.75rem;
    padding: 1px 6px;
  }

  .chat-input {
    font-size: 0.9rem;
    padding: 12px 16px;
  }

  .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .header-with-wave {
    min-height: 400px;
  }

  .header-logo {
    max-height: 100px;
  }

  .header-with-wave h1 {
    font-size: 2.2rem;
  }

  .header-subtitle {
    font-size: 1rem;
  }
}
