/* =====================================================================
   Retícula de 12 columnas para todo el sitio (escritorio ≥ 901 px).
   Contenedor 1200 px · 12 columnas de 78 px · medianil 24 px.
   Mismas líneas que la página de curso. El prefijo con :not(#…) da a estas
   reglas prioridad sobre los estilos de cada sección.
   Zonas de lectura:  texto alineado a la izquierda → columnas 1–8
                      texto centrado                → columnas 3–10
                      componentes (rejillas, catálogos, formularios) → 1–12
   ===================================================================== */
@media (min-width: 901px) {
  :root { --tek-g-cols: repeat(12, minmax(0, 1fr)); --tek-g-gap: 24px; --tek-g-width: min(1200px, calc(100% - 44px)); }

  /* ---------- 1. Contenedores de sección ---------- */
  html body:not(#tek-no-grid) :is(.tek-home-section > .tek-section-inner, .tkm .tkm-container) {
    width: var(--tek-g-width) !important;
    max-width: none !important;
    margin-inline: auto !important;
    padding-inline: 0 !important;
    display: grid !important;
    grid-template-columns: var(--tek-g-cols);
    column-gap: var(--tek-g-gap);
    row-gap: 0;
    box-sizing: border-box;
  }
  /* Secciones de Investigadores y Biblioteca de Prompts (anidadas). */
  html body:not(#tek-no-grid) :is(.tkm-inv, .tkm-inv > .tek-section-inner) {
    grid-column: 1 / -1;
    width: auto !important;
    max-width: none !important;
    margin-inline: 0 !important;
    padding-inline: 0 !important;
    display: grid !important;
    grid-template-columns: var(--tek-g-cols);
    column-gap: var(--tek-g-gap);
    row-gap: 0;
  }
  /* Cuando la sección de Investigadores/Prompts cuelga directamente de la franja, actúa como contenedor. */
  html body:not(#tek-no-grid) .tek-home-section > .tkm-inv {
    width: var(--tek-g-width) !important;
    margin-inline: auto !important;
  }
  /* Por defecto cada hijo ocupa las 12 columnas (sin anchos máximos ni márgenes automáticos). */
  html body:not(#tek-no-grid) :is(.tek-home-section > .tek-section-inner, .tkm .tkm-container, .tkm-inv, .tkm-inv > .tek-section-inner) > * {
    grid-column: 1 / -1;
    max-width: none !important;
    margin-inline: 0 !important;
    min-width: 0;
    box-sizing: border-box;
  }

  /* ---------- 2. Texto: alineado a la izquierda (1–8) o centrado (3–10) ---------- */
  html body:not(#tek-no-grid) :is(.tek-home-section > .tek-section-inner, .tkm-inv > .tek-section-inner) > :is(h1, h2, h3, p, .wp-block-heading, .wp-block-paragraph) {
    grid-column: 1 / 9;
  }
  html body:not(#tek-no-grid) .tkm-inv > :is(.tkm-inv-hero, .tkm-inv-cta, .tkm-inv-faq, .tkm-inv-centered-block) > :is(h2, h3, p, .tkm-inv-faq-list, .wp-block-heading),
  html body:not(#tek-no-grid) :is(.tek-home-section > .tek-section-inner, .tkm-inv > .tek-section-inner) > .tkm-inv-centered,
  html body:not(#tek-no-grid) .tek-home-section > .tek-section-inner > .tek-section-heading,
  html body:not(#tek-no-grid) .tkm .tkm-container > :is(.tkm-lead, .tkm-h2, .tkm-faq__list) {
    grid-column: 3 / 11;
  }
  /* Títulos principales centrados: columnas 2–11. */
  html body:not(#tek-no-grid) .tkm-inv > .tkm-inv-hero > :is(h1, .wp-block-heading),
  html body:not(#tek-no-grid) .tkm .tkm-container > :is(.tkm-h1, .tkm-h2--lg) {
    grid-column: 2 / 12;
  }
  html body:not(#tek-no-grid) .tek-home-section > .tek-section-inner > .tek-section-heading > * { max-width: none !important; margin-inline: 0 !important; }
  /* Botones, rejillas, catálogos y formularios: 12 columnas. */
  html body:not(#tek-no-grid) :is(.tek-home-section > .tek-section-inner, .tkm-inv > .tek-section-inner) > :is(.wp-block-buttons, .woocommerce, .tkm-inv-catalog, .tkm-inv-services, .tkm-inv-quoter, .tkm-inv-resources, .tkm-inv-cards, .tkm-pr-grid, .tkm-pr-steps, .tkm-pr-chips, .tkm-pr-demo, .tkm-inv-spacer) {
    grid-column: 1 / -1;
  }

  /* ---------- 3. Rejillas internas sobre las mismas 12 columnas ---------- */
  html body:not(#tek-no-grid) :is(.tkm-inv-cards, .tkm-pr-grid, .tkm-pr-steps, .tkm-inv-services, .tkm-services__grid, .tkm-pr-demo) {
    display: grid !important;
    grid-template-columns: var(--tek-g-cols) !important;
    column-gap: var(--tek-g-gap) !important;
    row-gap: var(--tek-g-gap) !important;
    width: auto !important;
    max-width: none !important;
  }
  html body:not(#tek-no-grid) :is(.tkm-inv-cards, .tkm-pr-grid, .tkm-pr-steps) > * { grid-column: span 4; min-width: 0; margin: 0; }
  html body:not(#tek-no-grid) .tkm-inv-services > * { grid-column: span 6; min-width: 0; margin: 0; }
  html body:not(#tek-no-grid) .tkm .tkm-container.tkm-services__grid > * { grid-column: span 6; margin: 0 !important; }
  html body:not(#tek-no-grid) .tkm-pr-demo > .tkm-pr-demo-form { grid-column: 1 / 6; min-width: 0; }
  html body:not(#tek-no-grid) .tkm-pr-demo > .tkm-pr-demo-out { grid-column: 6 / 13; min-width: 0; }

  /* Catálogo de WooCommerce (3 por fila = 4 columnas cada curso). */
  html body:not(#tek-no-grid) :is(.tek-home-section, .tkm-inv) .woocommerce ul.products {
    display: grid !important;
    grid-template-columns: var(--tek-g-cols) !important;
    column-gap: var(--tek-g-gap) !important;
    row-gap: 40px !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
  }
  html body:not(#tek-no-grid) :is(.tek-home-section, .tkm-inv) .woocommerce ul.products::before,
  html body:not(#tek-no-grid) :is(.tek-home-section, .tkm-inv) .woocommerce ul.products::after { display: none !important; }
  html body:not(#tek-no-grid) :is(.tek-home-section, .tkm-inv) .woocommerce ul.products > li.product {
    grid-column: span 4 !important;
    width: auto !important;
    margin: 0 !important;
    float: none !important;
    clear: none !important;
  }

  /* Cotizador incrustado: sin márgenes propios; el formulario ocupa 3–10. */
  html body:not(#tek-no-grid) .tkm-inv-quoter :is(.tek-science-calculator, .tek-container) { width: auto !important; max-width: none !important; margin: 0 !important; padding-inline: 0 !important; }
  html body:not(#tek-no-grid) .tkm-inv-quoter .tek-science-calculator__layout { display: grid !important; grid-template-columns: var(--tek-g-cols) !important; column-gap: var(--tek-g-gap) !important; }
  html body:not(#tek-no-grid) .tkm-inv-quoter .tek-science-calculator__layout > * { grid-column: 3 / 11; max-width: none !important; margin-inline: 0 !important; }

  /* Bloque de llamada a la acción con recuadro: el recuadro ocupa 1–12 y su contenido 3–10. */
  html body:not(#tek-no-grid) .tkm-inv > .tkm-inv-cta { padding-inline: 0 !important; }

  /* ---------- 4. Portada (plugin Tekamolo Inicio) ---------- */
  /* Tableta: columnas 2–11; las tarjetas del carrusel caen en 3–10. */
  html body:not(#tek-no-grid) .tkm .tkm-container > .tkm-tablet { grid-column: 2 / 12; margin: 40px 0 0 !important; box-sizing: border-box; }
  html body:not(#tek-no-grid) .tkm .tkm-tablet { padding: 18px !important; }
  html body:not(#tek-no-grid) .tkm .tkm-tablet__screen { padding-inline: 84px !important; }
  html body:not(#tek-no-grid) .tkm .tkm-carousel { max-width: none !important; width: 100% !important; }
  /* Recuadro de prompts: 2–11, contenido 3–10. */
  html body:not(#tek-no-grid) .tkm .tkm-container > .tkm-glass { grid-column: 2 / 12; padding-inline: 102px !important; box-sizing: border-box; }
  html body:not(#tek-no-grid) .tkm .tkm-glass > * { max-width: none !important; margin-inline: 0 !important; }
  /* Llamada final: recuadro 1–12; título 2–6 y enlaces 8–11. */
  html body:not(#tek-no-grid) .tkm .tkm-container > .tkm-cta {
    grid-column: 1 / -1;
    display: grid !important;
    grid-template-columns: var(--tek-g-cols) !important;
    column-gap: var(--tek-g-gap) !important;
    padding-inline: 0 !important;
    box-sizing: border-box;
  }
  html body:not(#tek-no-grid) .tkm .tkm-cta > .tkm-cta__title { grid-column: 2 / 7; max-width: none !important; margin: 0 !important; }
  html body:not(#tek-no-grid) .tkm .tkm-cta > .tkm-cta__side { grid-column: 8 / 12; max-width: none !important; margin: 0 !important; }
  /* Preguntas frecuentes de la portada: título y lista en 3–10. */
  html body:not(#tek-no-grid) .tkm .tkm-container--narrow > * { grid-column: 3 / 11; }

  /* ---------- 5. Encabezado y pie de página ---------- */
  html body:not(#tek-no-grid) .tek-site-header .tek-site-header__inner {
    width: var(--tek-g-width) !important;
    max-width: none !important;
    margin-inline: auto !important;
    padding-inline: 0 !important;
    box-sizing: border-box;
  }
  html body:not(#tek-no-grid) .tek-unified-footer .tek-footer-shell { width: var(--tek-g-width) !important; }
  html body:not(#tek-no-grid) .tek-unified-footer .tek-footer-grid {
    grid-template-columns: var(--tek-g-cols) !important;
    column-gap: var(--tek-g-gap) !important;
  }
  html body:not(#tek-no-grid) .tek-unified-footer .tek-footer-grid > .tek-footer-brand { grid-column: 1 / 5; }
  html body:not(#tek-no-grid) .tek-unified-footer .tek-footer-grid > .tek-footer-column:nth-child(2) { grid-column: 6 / 8; }
  html body:not(#tek-no-grid) .tek-unified-footer .tek-footer-grid > .tek-footer-column:nth-child(3) { grid-column: 8 / 10; }
  html body:not(#tek-no-grid) .tek-unified-footer .tek-footer-grid > .tek-footer-column:nth-child(4) { grid-column: 10 / 13; }
}

/* =====================================================================
   Retícula en móvil y tableta.
   Móvil (≤ 599 px):     4 columnas · medianil 16 px · margen lateral 20 px
   Tableta (600–900 px): 8 columnas · medianil 24 px · margen lateral 32 px
   Todas las páginas comparten el mismo margen lateral: encabezado, secciones,
   tienda, página de curso y pie.
   ===================================================================== */
@media (max-width: 900px) {
  :root { --tek-m: 32px; --tek-g-gap: 24px; --tek-g-cols: repeat(8, minmax(0, 1fr)); --tek-card-span: span 4; }
}
@media (max-width: 599px) {
  :root { --tek-m: 20px; --tek-g-gap: 16px; --tek-g-cols: repeat(4, minmax(0, 1fr)); --tek-card-span: 1 / -1; }
}
@media (max-width: 900px) {
  /* ---------- 1. Margen lateral único ---------- */
  html body:not(#tek-no-grid) .tek-site-header .tek-site-header__inner,
  html body:not(#tek-no-grid) .tek-header .tek-header__inner {
    padding-inline: var(--tek-m) !important;
    margin-inline: 0 !important;
    width: auto !important;
    max-width: none !important;
    box-sizing: border-box;
  }
  /* Franjas de sección (Cursos, Investigadores, Prompts). */
  html body:not(#tek-no-grid) .tek-home-section { padding-inline: var(--tek-m) !important; }
  html body:not(#tek-no-grid) :is(.tek-home-section > .tek-section-inner, .tek-home-section > .tkm-inv, .tkm-inv, .tkm-inv > .tek-section-inner) {
    padding-inline: 0 !important;
    margin-inline: 0 !important;
    width: auto !important;
    max-width: none !important;
  }
  /* Recuadros de llamada a la acción: conservan su margen interior. */
  html body:not(#tek-no-grid) .tkm-inv > .tek-section-inner.tkm-inv-cta {
    padding-inline: clamp(16px, 5vw, 32px) !important;
  }
  html body:not(#tek-no-grid) .tkm-inv .wp-block-button > .wp-block-button__link {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: normal !important;
    height: auto !important;
    max-width: 100%;
    box-sizing: border-box;
  }
  html body:not(#tek-no-grid) .tkm-inv > .tek-section-inner.tkm-inv-cta { padding-bottom: 32px !important; }
  /* Portada (plugin Tekamolo Inicio). */
  html body:not(#tek-no-grid) .tkm .tkm-container {
    padding-inline: var(--tek-m) !important;
    max-width: none !important;
    box-sizing: border-box;
  }
  /* Página de curso. */
  html body:not(#tek-no-grid) .tek-course-site .tek-container,
  html body:not(#tek-no-grid) .tek-container.tek-course-narrow,
  html body:not(#tek-no-grid) .tek-prompt-product-page .tek-container {
    width: auto !important;
    max-width: none !important;
    margin-inline: var(--tek-m) !important;
    padding-inline: 0 !important;
  }
  /* Tienda y demás páginas de bloques de WooCommerce. */
  html body:not(#tek-no-grid) main :is(.wp-block-woocommerce-product-collection, .wp-block-query-title, .wp-block-woocommerce-store-notices, .wp-block-woocommerce-breadcrumbs, .wp-block-woocommerce-catalog-sorting, .wp-block-woocommerce-product-results-count, .wp-block-query-pagination, .woocommerce-products-header) {
    margin-inline: var(--tek-m) !important;
    max-width: none !important;
    width: auto !important;
    box-sizing: border-box;
  }
  /* Pie de página. */
  html body:not(#tek-no-grid) .tek-unified-footer .tek-footer-shell {
    width: auto !important;
    max-width: none !important;
    margin-inline: var(--tek-m) !important;
  }

  /* ---------- 2. Rejillas internas sobre 8 / 4 columnas ---------- */
  html body:not(#tek-no-grid) :is(.tkm-inv-cards, .tkm-pr-grid, .tkm-pr-steps, .tkm-inv-services, .tkm-inv-resources, ul.wc-block-product-template) {
    display: grid !important;
    grid-template-columns: var(--tek-g-cols) !important;
    gap: var(--tek-g-gap) !important;
    width: auto !important;
    max-width: none !important;
    margin-inline: 0 !important;
    padding-inline: 0 !important;
  }
  html body:not(#tek-no-grid) :is(.tkm-inv-cards, .tkm-pr-grid, .tkm-pr-steps, .tkm-inv-services, ul.wc-block-product-template) > * {
    grid-column: var(--tek-card-span) !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    min-width: 0;
  }
  html body:not(#tek-no-grid) .tkm-inv-resources > * { grid-column: 1 / -1 !important; margin: 0 !important; }
  /* Catálogo clásico de WooCommerce dentro de las secciones. */
  html body:not(#tek-no-grid) :is(.tek-home-section, .tkm-inv) .woocommerce ul.products {
    display: grid !important;
    grid-template-columns: var(--tek-g-cols) !important;
    gap: 32px var(--tek-g-gap) !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  html body:not(#tek-no-grid) :is(.tek-home-section, .tkm-inv) .woocommerce ul.products::before,
  html body:not(#tek-no-grid) :is(.tek-home-section, .tkm-inv) .woocommerce ul.products::after { display: none !important; }
  html body:not(#tek-no-grid) :is(.tek-home-section, .tkm-inv) .woocommerce ul.products > li.product {
    grid-column: var(--tek-card-span) !important;
    width: auto !important;
    margin: 0 !important;
    float: none !important;
  }
  /* Formulario de prompt de ejemplo y su resultado: a todo el ancho. */
  html body:not(#tek-no-grid) .tkm-pr-demo { display: grid !important; grid-template-columns: minmax(0, 1fr) !important; gap: var(--tek-g-gap) !important; }
}

/* ===== Investigadores: tarjetas de curso, servicios y aviso de cookies (UX) ===== */
/* Tarjeta de curso en columna: el botón «Ver curso» siempre al fondo, alineado entre tarjetas. */
html body:not(#tek-no-grid) .tkm-inv .woocommerce ul.products > li.product {
  display: flex !important;
  flex-direction: column;
  position: relative;
  min-width: 0;
}
html body:not(#tek-no-grid) .tkm-inv .woocommerce ul.products > li.product > .button,
html body:not(#tek-no-grid) .tkm-inv .woocommerce ul.products > li.product > .wp-block-button,
html body:not(#tek-no-grid) .tkm-inv .woocommerce ul.products > li.product > .add_to_cart_button {
  margin-top: auto !important;
  align-self: flex-start;
}
html body:not(#tek-no-grid) .tkm-inv .woocommerce ul.products > li.product .price { margin-bottom: 16px !important; }
/* «Gratis» en lugar de $0. */
.tek-price-free {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: #e8f9d0;
  color: #1f4d0a;
  font-weight: 800;
  font-size: .85em;
  letter-spacing: .02em;
}
/* Insignia de oferta: pastilla que crece con el texto (antes círculo de tamaño fijo). */
html body:not(#tek-no-grid) .tkm-inv .woocommerce ul.products > li.product .onsale {
  min-width: 0 !important;
  min-height: 0 !important;
  width: auto !important;
  height: auto !important;
  padding: 5px 12px !important;
  border-radius: 999px !important;
  line-height: 1.2 !important;
  white-space: nowrap;
  top: 10px !important;
  right: 10px !important;
  left: auto !important;
  margin: 0 !important;
}
/* Servicios: pasan a una columna cuando el texto crece (zoom) o el ancho no alcanza. */
html body:not(#tek-no-grid) .tkm-inv .tkm-inv-services {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)) !important;
}
html body:not(#tek-no-grid) .tkm-inv .tkm-inv-services > * { grid-column: auto !important; }
.tkm-inv-empty {
  padding: 20px;
  border: 1px dashed rgba(255, 255, 255, .25);
  border-radius: 14px;
  opacity: .9;
}

/* Tableta: los cursos en rejilla de 3 columnas (sin un curso huérfano). */
@media (min-width: 600px) and (max-width: 900px) {
  html body:not(#tek-no-grid) .tkm-inv .woocommerce ul.products {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 28px 16px !important;
  }
  html body:not(#tek-no-grid) .tkm-inv .woocommerce ul.products > li.product { grid-column: auto !important; }
  html body:not(#tek-no-grid) .tkm-inv .woocommerce ul.products > li.product .woocommerce-loop-product__title { font-size: .95rem !important; }
  html body:not(#tek-no-grid) .tkm-inv .woocommerce ul.products > li.product > .button { padding: 10px 16px !important; font-size: .9rem !important; }
}

/* Aviso de cookies en móvil: barra compacta para no tapar el contenido. */
@media (max-width: 599px) {
  html body .tkm-cc { left: 8px; right: 8px; bottom: 8px; width: auto; max-width: none; }
  html body .tkm-cc .tkm-cc__box { padding: 14px 14px 12px; border-radius: 14px; }
  html body .tkm-cc .tkm-cc__title { font-size: .95rem; margin-bottom: 4px; }
  html body .tkm-cc .tkm-cc__text { font-size: .8rem; line-height: 1.45; margin-bottom: 10px; }
  html body .tkm-cc .tkm-cc__actions { flex-wrap: nowrap; gap: 6px; }
  html body .tkm-cc .tkm-cc__btn { flex: 1 1 0; padding: 9px 6px; font-size: .78rem; }
}
