/*
 * Teide Cookie Banner — estilos del frontend.
 * Todo va prefijado con "tcb-" para minimizar conflictos con el tema.
 * Los colores se inyectan como variables CSS inline desde PHP (ver class-tcb-frontend.php),
 * con estos valores como respaldo por si el navegador no las recibe.
 */

#tcb-root {
  --tcb-bg: #211d1a;
  --tcb-text: #f4ece0;
  --tcb-muted: #b9b0a0;
  --tcb-accent: #bd5a3a;
  --tcb-accent-contrast: #ffffff;
  --tcb-outline: #f4ece0;
  --tcb-focus: #4f7f93;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

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

#tcb-root button {
  font-family: inherit;
  cursor: pointer;
}

#tcb-root:focus-visible,
#tcb-root *:focus-visible {
  outline: 3px solid var(--tcb-focus);
  outline-offset: 2px;
}

/* ---------- Botón flotante para reabrir preferencias ---------- */
.tcb-reopen {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 999998;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--tcb-bg);
  color: var(--tcb-text);
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s ease;
}
.tcb-reopen:hover {
  transform: translateY(-2px);
}
#tcb-root[data-visible="0"] .tcb-reopen {
  display: flex;
}

/* ---------- Primer nivel: banner ---------- */
.tcb-banner {
  position: fixed;
  z-index: 999999;
  background: var(--tcb-bg);
  color: var(--tcb-text);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.28);
  display: none;
  gap: 14px;
}

#tcb-root[data-visible="1"] .tcb-banner {
  display: flex;
  flex-direction: column;
}

/* Variante: tarjeta flotante (por defecto, la más discreta) */
.tcb-pos-card .tcb-banner {
  left: 16px;
  bottom: 16px;
  max-width: 380px;
  width: calc(100% - 32px);
  border-radius: 16px;
  padding: 18px 18px 16px;
}

/* Variante: barra inferior a todo el ancho */
.tcb-pos-bar .tcb-banner {
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  padding: 16px 20px;
}
@media (min-width: 720px) {
  .tcb-pos-bar .tcb-banner {
    flex-direction: row !important;
    align-items: center;
  }
  .tcb-pos-bar .tcb-banner-copy {
    flex: 1;
  }
}

.tcb-logo {
  border-radius: 50%;
  flex-shrink: 0;
}

.tcb-banner-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tcb-banner-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--tcb-text);
}

.tcb-banner-text {
  margin: 0;
  font-size: 0.86rem;
  color: var(--tcb-muted);
}

.tcb-link {
  color: var(--tcb-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.tcb-link:hover {
  color: var(--tcb-accent);
}

.tcb-banner-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
}

.tcb-banner-actions-main {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

@media (max-width: 420px) {
  .tcb-banner-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .tcb-banner-actions-main {
    order: 1;
  }
  #tcb-btn-settings {
    order: 2;
    align-self: center;
  }
}

/* ---------- Botones (Aceptar / Rechazar al mismo nivel de prominencia) ---------- */
.tcb-btn {
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 600;
  padding: 10px 16px;
  border: 2px solid transparent;
  line-height: 1.2;
  white-space: nowrap;
}

.tcb-btn-solid {
  background: var(--tcb-accent);
  border-color: var(--tcb-accent);
  color: var(--tcb-accent-contrast);
  flex: 1;
}
.tcb-btn-solid:hover {
  filter: brightness(1.08);
}

.tcb-btn-outline {
  background: transparent;
  border-color: var(--tcb-outline);
  color: var(--tcb-text);
  flex: 1;
}
.tcb-btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
}

.tcb-btn-text {
  background: transparent;
  border-color: transparent;
  color: var(--tcb-muted);
  padding: 10px 4px;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}
.tcb-btn-text:hover {
  color: var(--tcb-text);
}

.tcb-btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--tcb-text);
}
.tcb-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ---------- Segundo nivel: modal de preferencias ---------- */
.tcb-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(15, 13, 11, 0.55);
  display: none;
}

.tcb-modal {
  position: fixed;
  z-index: 1000000;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 32px);
  max-width: 560px;
  max-height: min(88vh, 720px);
  background: #fffdf9;
  color: #211d1a;
  border-radius: 18px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

#tcb-root.tcb-modal-open .tcb-modal-backdrop,
#tcb-root.tcb-modal-open .tcb-modal {
  display: flex;
}
#tcb-root.tcb-modal-open .tcb-banner {
  display: none !important;
}

.tcb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #ece2d0;
  flex-shrink: 0;
}
.tcb-modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}
.tcb-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: #6d675e;
  padding: 4px 8px;
  border-radius: 6px;
}
.tcb-modal-close:hover {
  background: #ece2d0;
  color: #211d1a;
}

.tcb-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  font-size: 0.9rem;
  color: #3a332c;
}
.tcb-modal-body > p {
  margin-top: 0;
  color: #6d675e;
}

.tcb-category {
  border: 1px solid #ece2d0;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.tcb-category-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tcb-category-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.tcb-category-title strong {
  font-size: 0.92rem;
}
.tcb-category-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6d675e;
  background: #ece2d0;
  padding: 2px 8px;
  border-radius: 20px;
}
.tcb-category-desc {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: #6d675e;
}

.tcb-cookie-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.78rem;
}
.tcb-cookie-table th,
.tcb-cookie-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #ece2d0;
}
.tcb-cookie-table th {
  color: #6d675e;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
}

.tcb-modal-footnote {
  font-size: 0.8rem;
  color: #6d675e;
}

.tcb-modal-footer {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid #ece2d0;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.tcb-modal-footer .tcb-btn {
  flex: 1;
  min-width: 120px;
}
.tcb-modal-footer .tcb-btn-outline {
  border-color: #211d1a;
  color: #211d1a;
}
.tcb-modal-footer .tcb-btn-outline:hover {
  background: #ece2d0;
}
.tcb-modal-footer .tcb-btn-ghost {
  background: #ece2d0;
  border-color: #ece2d0;
  color: #211d1a;
}
.tcb-modal-footer .tcb-btn-ghost:hover {
  background: #e0d5bd;
}

/* ---------- Interruptores (toggles) accesibles, basados en checkboxes reales ---------- */
.tcb-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 24px;
  flex-shrink: 0;
}
.tcb-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.tcb-switch-track {
  position: absolute;
  inset: 0;
  background: #d8cdb8;
  border-radius: 999px;
  transition: background 0.15s ease;
}
.tcb-switch-track::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.tcb-switch input:checked + .tcb-switch-track {
  background: var(--tcb-accent, #bd5a3a);
}
.tcb-switch input:checked + .tcb-switch-track::before {
  transform: translateX(16px);
}
.tcb-switch input:focus-visible + .tcb-switch-track {
  outline: 3px solid var(--tcb-focus, #4f7f93);
  outline-offset: 2px;
}
.tcb-switch-disabled {
  opacity: 0.6;
}
.tcb-switch-disabled input {
  cursor: not-allowed;
}

/* Enlace generado por el shortcode [tcb_preferencias_cookies] */
.tcb-reopen-link {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  font: inherit;
  cursor: pointer;
}

/* ---------- Movimiento reducido y accesibilidad ---------- */
@media (prefers-reduced-motion: reduce) {
  #tcb-root * {
    transition: none !important;
  }
}

/* ---------- Ajuste fino en móvil pequeño ---------- */
@media (max-width: 380px) {
  .tcb-pos-card .tcb-banner {
    left: 8px;
    width: calc(100% - 16px);
    padding: 16px 14px 14px;
  }
  .tcb-modal {
    width: calc(100% - 16px);
    max-height: 92vh;
  }
  .tcb-modal-footer {
    flex-direction: column;
  }
}
