/**
 * Fix overflow horizontal + Guille FAB + chat móvil abierto (solo diseño)
 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: clip;
  overflow-y: auto;
}

body.landing-page,
body.site-page,
body.overflow-x-hidden {
  max-width: 100%;
  width: 100%;
  position: relative;
  overflow-x: clip !important;
  overflow-y: visible !important;
}

img,
canvas,
svg,
video {
  max-width: 100%;
  height: auto;
}

canvas.hero-ripple-canvas {
  max-width: 100% !important;
  width: 100% !important;
  display: block;
}

.qa-card {
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.quick-access .wrap-inner,
.landing-main,
.institutional-about,
.landing-gallery,
.recruitment-section,
footer.landing-footer {
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}
.quick-access .wrap-inner {
  overflow: visible;
}

/* ---------- Guille chat dock (cerrado) ---------- */
#guille-chat-dock,
.guille-chat-dock {
  max-width: 100vw;
  width: auto;
  box-sizing: border-box;
  right: 16px;
  bottom: 16px;
  left: auto;
}

.guille-fab {
  overflow: hidden;
  flex-shrink: 0;
}

.guille-fab-ring {
  inset: 0;
  pointer-events: none;
}

.guille-fab-badge {
  right: 0;
  bottom: 0;
}

.chatbot-card.is-floating {
  width: min(820px, calc(100% - 32px)) !important;
  max-width: 100% !important;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  #guille-chat-dock,
  .guille-chat-dock {
    position: fixed !important;
    right: 16px !important;
    bottom: 16px !important;
    left: auto !important;
    z-index: 9999 !important;
    max-width: 100vw !important;
    width: auto !important;
    align-items: flex-end !important;
  }

  .guille-fab {
    width: 60px !important;
    height: 60px !important;
    overflow: hidden !important;
  }

  .guille-fab-ring {
    position: absolute !important;
    inset: 0 !important;
    width: 60px !important;
    height: 60px !important;
    max-width: 60px !important;
    max-height: 60px !important;
    box-sizing: border-box;
  }

  .guille-fab-badge {
    width: 20px;
    height: 20px;
    right: 0 !important;
    bottom: 0 !important;
    font-size: 10px;
  }

  /* ===== Chat abierto: hoja móvil cómoda ===== */
  body.guille-chat-open {
    overflow: hidden !important;
  }

  body.guille-chat-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(4, 18, 34, 0.58);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: guilleSheetBackdropIn 0.28s ease both;
  }

  body.guille-chat-open #guille-chat-dock,
  body.guille-chat-open .guille-chat-dock {
    inset: 0 !important;
    right: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: auto !important;
    align-items: stretch !important;
    padding: 0 !important;
    gap: 0 !important;
    z-index: 9999 !important;
    pointer-events: none;
  }

  body.guille-chat-open #guille-chat-dock > *,
  body.guille-chat-open .guille-chat-dock > * {
    pointer-events: auto;
  }

  body.guille-chat-open .chatbot-card.is-floating {
    --guille-sheet-navy: #0a3558;
    --guille-sheet-navy-deep: #072844;
    --guille-sheet-surface: #f3f7fb;
    --guille-sheet-ink: #0f2f4d;
    --guille-sheet-muted: #5a7a92;
    width: 100% !important;
    max-width: 100% !important;
    height: min(94svh, 860px) !important;
    max-height: calc(100svh - env(safe-area-inset-top, 0px)) !important;
    margin: 0 !important;
    border-radius: 24px 24px 0 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-shadow: 0 -18px 48px rgba(4, 24, 48, 0.42) !important;
    animation: guilleSheetSlideUp 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
    background: var(--guille-sheet-surface) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Asa de arrastre */
  body.guille-chat-open .chatbot-card.is-floating::before {
    content: "";
    display: block;
    order: 0;
    width: 40px;
    height: 4px;
    margin: 10px auto 0;
    border-radius: 999px;
    background: rgba(15, 47, 77, 0.22);
    flex-shrink: 0;
  }

  /* Expone hijos del main para reordenar sin tocar JS */
  body.guille-chat-open .chatbot-card.is-floating .chatbot-main {
    display: contents;
  }

  /* 1) Cabecera de marca */
  body.guille-chat-open .chatbot-card.is-floating .chatbot-header {
    order: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px 14px;
    margin: 8px 12px 0;
    border-radius: 16px;
    background: linear-gradient(145deg, var(--guille-sheet-navy) 0%, var(--guille-sheet-navy-deep) 100%);
    border: 0;
    border-bottom: 0;
    box-shadow: 0 10px 24px rgba(7, 40, 68, 0.28);
    flex-shrink: 0;
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-header .guille-avatar {
    width: 44px;
    height: 44px;
    border-width: 2px;
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 0 0 3px rgba(0, 163, 224, 0.22);
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-title-row {
    gap: 6px;
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-title-row h3 {
    font-size: 16px;
    letter-spacing: -0.01em;
    color: #fff;
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-header p {
    font-size: 12px;
    line-height: 1.35;
    margin-top: 3px;
    color: rgba(197, 233, 247, 0.88);
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-live {
    font-size: 9px;
    padding: 3px 7px;
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-float-btn {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.18);
    color: #e8f7fc;
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-float-btn:hover,
  body.guille-chat-open .chatbot-card.is-floating .chat-float-btn:focus-visible {
    background: rgba(0, 163, 224, 0.35);
    color: #fff;
    transform: none;
  }

  /* 2) Preguntas rápidas (chips) bajo la cabecera */
  body.guille-chat-open .chatbot-card.is-floating .chatbot-sidebar {
    order: 2;
    width: 100% !important;
    max-height: none !important;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 12px 0 8px !important;
    border-right: 0 !important;
    border-bottom: 0;
    background: transparent !important;
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-sidebar-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 16px 8px;
    padding: 0;
    border: 0;
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-sidebar-heading span {
    color: var(--guille-sheet-ink);
    font-size: 11px;
    letter-spacing: 0.06em;
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-sidebar-heading small {
    display: none;
  }

  body.guille-chat-open .chatbot-card.is-floating .faq-buttons {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 16px 6px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    flex: 0 0 auto;
  }

  body.guille-chat-open .chatbot-card.is-floating .faq-buttons::-webkit-scrollbar {
    display: none;
  }

  body.guille-chat-open .chatbot-card.is-floating .faq-chat-button {
    flex: 0 0 auto;
    width: auto;
    max-width: 240px;
    min-height: 42px;
    padding: 11px 14px;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.3;
    border-radius: 14px;
    scroll-snap-align: start;
    box-shadow: 0 6px 14px rgba(0, 82, 155, 0.16);
    background: linear-gradient(145deg, #00a3e0, #0086bd);
  }

  body.guille-chat-open .chatbot-card.is-floating .faq-chat-button:hover,
  body.guille-chat-open .chatbot-card.is-floating .faq-chat-button:active {
    transform: none;
    background: #007eaf;
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-sidebar-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin: 4px 16px 0;
    padding: 0;
    border: 0;
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-sidebar-footer .guille-avatar {
    display: none;
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-reset {
    min-height: 34px;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 11px;
    color: var(--guille-sheet-muted);
    background: #e8eef4;
    border: 1px solid rgba(15, 47, 77, 0.1);
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-reset:hover {
    color: var(--guille-sheet-ink);
    background: #dce7f0;
  }

  /* 3) Conversación: zona amplia y legible */
  body.guille-chat-open .chatbot-card.is-floating .chat-messages {
    order: 3;
    min-height: 0 !important;
    flex: 1 1 auto;
    padding: 8px 14px 12px;
    gap: 12px;
    background:
      linear-gradient(180deg, rgba(243, 247, 251, 0) 0%, #eaf1f7 100%);
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-message .guille-avatar {
    width: 30px;
    height: 30px;
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-bubble {
    max-width: 88%;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.55;
    border-radius: 16px;
    box-shadow: 0 4px 14px rgba(15, 47, 77, 0.08);
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-bubble.bot {
    color: var(--guille-sheet-ink);
    background: #fff;
    border: 1px solid rgba(15, 47, 77, 0.08);
    border-top-left-radius: 4px;
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-bubble.user {
    color: #fff;
    background: linear-gradient(145deg, #00a3e0, #007eb8);
    border-top-right-radius: 4px;
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-time {
    color: rgba(90, 122, 146, 0.85);
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-bubble.user .chat-time {
    color: rgba(232, 247, 252, 0.8);
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-answer a {
    color: #0077ad;
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-action a,
  body.guille-chat-open .chatbot-card.is-floating .chat-action button {
    color: #0a3558;
    background: #e8f4fb;
    border-color: rgba(0, 163, 224, 0.35);
    min-height: 40px;
    padding: 10px 12px;
    font-size: 12px;
    border-radius: 10px;
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-feedback {
    color: var(--guille-sheet-muted);
    border-top-color: rgba(15, 47, 77, 0.1);
  }

  body.guille-chat-open .chatbot-card.is-floating .typing-bubble {
    color: var(--guille-sheet-muted);
  }

  /* 4) Temas + reinicio: barra inferior limpia */
  body.guille-chat-open .chatbot-card.is-floating .chatbot-topics {
    order: 4;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid rgba(15, 47, 77, 0.08);
    box-shadow: 0 -8px 24px rgba(15, 47, 77, 0.06);
    flex-shrink: 0;
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-topics > span {
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--guille-sheet-muted);
  }

  body.guille-chat-open .chatbot-card.is-floating #chat-topic-buttons {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 0 4px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  body.guille-chat-open .chatbot-card.is-floating #chat-topic-buttons::-webkit-scrollbar {
    display: none;
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-topic-button {
    flex: 0 0 auto;
    scroll-snap-align: start;
    border-radius: 999px;
    padding: 10px 14px;
    min-height: 38px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: var(--guille-sheet-ink);
    background: #eef5fa;
    border: 1px solid rgba(15, 47, 77, 0.1);
    box-shadow: none;
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-topic-button:hover,
  body.guille-chat-open .chatbot-card.is-floating .chat-topic-button:focus-visible,
  body.guille-chat-open .chatbot-card.is-floating .chat-topic-button.is-active {
    background: var(--cyan-accent, #00a3e0);
    border-color: transparent;
    color: #fff;
  }

  .qa-card {
    width: 100%;
    max-width: 100%;
  }

  .qa-text p {
    max-width: none;
  }

  .hero.hero-ripple,
  .hero-ripple-canvas,
  .hero-ripple-sources,
  .hero-ripple-sources img {
    max-width: 100% !important;
  }
}

@media (max-width: 480px) {
  #guille-chat-dock:not(:has(.chatbot-card.is-floating)),
  .guille-chat-dock:not(:has(.chatbot-card.is-floating)) {
    right: 14px !important;
    bottom: 14px !important;
  }

  body.guille-chat-open .chatbot-card.is-floating {
    height: min(96svh, 900px) !important;
    max-height: calc(100svh - env(safe-area-inset-top, 0px)) !important;
    border-radius: 20px 20px 0 0 !important;
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-header {
    margin: 6px 10px 0;
    padding: 11px 12px 12px;
    border-radius: 14px;
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-title-row h3 {
    font-size: 15px;
  }

  body.guille-chat-open .chatbot-card.is-floating .faq-buttons {
    padding-left: 12px;
    padding-right: 12px;
  }

  body.guille-chat-open .chatbot-card.is-floating .faq-chat-button {
    max-width: 210px;
    font-size: 12px;
    padding: 10px 12px;
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-messages {
    padding: 6px 12px 10px;
  }

  body.guille-chat-open .chatbot-card.is-floating .chat-bubble {
    font-size: 13.5px;
    max-width: 90%;
  }

  body.guille-chat-open .chatbot-card.is-floating .chatbot-topics {
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }
}

@keyframes guilleSheetSlideUp {
  from {
    opacity: 0.4;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  body.guille-chat-open .chatbot-card.is-floating,
  body.guille-chat-open::before {
    animation: none !important;
  }
}
