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

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f4f4f4;
  color: #222;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */

.cm-header {
  background-color: #1e40af;
  color: #fff;
  padding: 0.75rem 1rem;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
}

.cm-header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  box-sizing: border-box;
}

.cm-logo-wrap {
  width: auto;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cm-logo {
  height: 3rem;
  width: auto;
  display: block;
  object-fit: contain;
  max-width: 100%;
}

.cm-header-title {
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 1.1rem;
  line-height: 1.2;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Ajustes para móviles */
@media (max-width: 640px) {
  .cm-header {
    padding: 0.5rem 0.5rem;
  }
  
  .cm-header-inner {
    gap: 0.3rem;
  }
  
  .cm-logo {
    height: 1.8rem;
  }
  
  .cm-header-title {
    font-size: 0.7rem;
    letter-spacing: 0.01em;
  }
  
  #btnAbrirConsultor {
    font-size: 0.65rem !important;
    padding: 0.25rem 0.5rem !important;
  }
}

/* Main layout */

.cm-main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0.75rem 1rem 1.25rem;
}

/* Filters */

.cm-filters {
  background-color: #fff;
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem 0.95rem;
  margin-bottom: 0.9rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.cm-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background-color: #dbeafe;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.cm-filters-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.cm-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.cm-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
}

.cm-field input,
.cm-field select {
  border-radius: 999px;
  border: 1px solid #ddd;
  padding: 0.45rem 0.8rem;
  font-size: 0.9rem;
  outline: none;
}

.cm-field input:focus,
.cm-field select:focus {
  border-color: #1e40af;
  box-shadow: 0 0 0 1px rgba(30, 64, 175, 0.25);
}

.cm-filters-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .cm-filters-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.cm-filters-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cm-btn {
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cm-btn-primary {
  background-color: #1e40af;
  color: #fff;
  border-color: #1e40af;
}

.cm-btn-primary:hover {
  filter: brightness(0.95);
}

.cm-btn-ghost {
  background-color: #fff;
  color: #444;
  border-color: #ddd;
}

.cm-btn-ghost:hover {
  background-color: #f3f4f6;
}

.cm-summary {
  margin-top: 0.55rem;
  font-size: 0.8rem;
  color: #555;
}

.cm-summary-tag {
  margin-left: 0.3rem;
  color: #1e40af;
}

/* Product list */

.cm-list {
  margin-bottom: 0.9rem;
}

.cm-product-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.cm-product-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  border-radius: 0.65rem;
  background-color: #fff;
  border: 2.5px solid #d1d5db;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.cm-product-main {
  width: 100%;
}

.cm-product-name {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  word-wrap: break-word;
  word-break: break-word;
  width: 100%;
}

.cm-product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-size: 0.68rem;
  color: #666;
  margin-top: 0.05rem;
}

.cm-product-tags {
  margin-top: 0.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
}

.cm-tag {
  font-size: 0.65rem;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  background-color: #dbeafe;
  color: #1e3a8a;
}

.cm-tag-muted {
  background-color: #e5e7eb;
  color: #374151;
}

.cm-product-price {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.25rem;
}

.cm-price-adicionales {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: flex-end;
  flex-shrink: 0;
}

.cm-price-main {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.cm-price-normal {
  font-size: 0.9rem;
  font-weight: 700;
}

.cm-price-offer {
  font-size: 0.9rem;
  font-weight: 800;
  color: #dc2626;
}

.cm-price-list {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.3rem;
}

.cm-price-list-strike {
  font-size: 0.7rem;
  color: #6b7280;
  text-decoration: line-through;
}

.cm-badge-offer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.02rem 0.35rem;
  border-radius: 999px;
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.cm-price-bulto {
  font-size: 0.65rem;
  color: #166534;
  background-color: #dcfce7;
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  text-align: right;
  line-height: 1.2;
}

.cm-empty {
  text-align: center;
  font-size: 0.9rem;
  color: #666;
  padding: 1.2rem 0.5rem;
}

/* Pagination */

.cm-pagination {
  display: flex;
  justify-content: center;
}

.cm-pagination-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.cm-page-btn {
  font-size: 0.8rem;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  border: 1px solid #e5e7eb;
  text-decoration: none;
  color: #374151;
  cursor: pointer;
}

.cm-page-btn:hover {
  background-color: #f3f4f6;
}

.cm-page-btn-disabled {
  opacity: 0.55;
  cursor: default;
}

.cm-page-info {
  font-size: 0.8rem;
  color: #6b7280;
}

/* Footer */

.cm-footer {
  font-size: 0.75rem;
  color: #6b7280;
  text-align: center;
  padding: 0.5rem 1rem 0.9rem;
}

/* Modal de bienvenida */

.cm-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  touch-action: none;
}

.cm-modal {
  width: 100%;
  max-width: 380px;
  margin: 0 1.5rem;
  background: linear-gradient(135deg, #ffffff 0%, #eff6ff 60%, #dbeafe 100%);
  border-radius: 1rem;
  padding: 1.1rem 1.2rem 1rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.45);
  border-top: 4px solid #1e40af;
}

.cm-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: #1e40af;
}

.cm-modal-text {
  font-size: 0.87rem;
  color: #4b5563;
  margin-bottom: 0.8rem;
  line-height: 1.4;
}

.cm-modal-actions {
  display: flex;
  justify-content: flex-end;
}

.cm-modal-hidden {
  display: none;
}

/* Evita scroll del fondo cuando el modal está abierto */
.cm-modal-open {
  overflow: hidden;
}

/* Modal Consultor de Precios */
.cm-consultor-modal {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  width: 100%;
  max-width: 100vw;
}

.cm-consultor-modal-content {
  background: white;
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.45);
  box-sizing: border-box;
  margin: auto;
}

/* Ajustes del modal para tablets */
@media (max-width: 768px) {
  .cm-consultor-modal {
    padding: 0.75rem;
  }
  
  .cm-consultor-modal-content {
    max-width: 100%;
    width: 100%;
    padding: 1.25rem;
  }
}

/* Ajustes del modal para móviles */
@media (max-width: 640px) {
  .cm-consultor-modal {
    padding: 0.5rem;
    align-items: center;
  }
  
  .cm-consultor-modal-content {
    padding: 1rem;
    border-radius: 1rem;
    max-width: 100%;
    width: 100%;
    max-height: calc(100vh - 1rem);
    margin: 0;
  }
  
  .cm-consultor-modal-content > div {
    padding: 0.75rem !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }
  
  .cm-consultor-modal-content * {
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .cm-consultor-modal-content h2 {
    font-size: 1.1rem !important;
  }
}
