/* Asistente "Cadete de Guardia". Sigue el estilo Casco: color plano y
   línea de 2px; relevo entre cadete, dama cadete e infante. Todos los nombres llevan of- */

.of {
  --of-verde: #0d6b45;
  font-family: 'Barlow', 'Segoe UI', sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  color: #14233a;
}
.of[hidden], .of [hidden] { display: none !important; }

/* ---------- Botón flotante ---------- */
.of-boton {
  position: fixed;
  right: 28px;
  bottom: 22px;
  z-index: 1040;
  display: flex;
  align-items: stretch;
  padding: 0;
  border: 2px solid #e0b23c;
  background: #07182e;
  color: #fff;
  text-align: left;
  cursor: pointer;
  transition: transform .25s cubic-bezier(.16, 1, .3, 1), background-color .2s, box-shadow .25s;
  /* backwards: al terminar no retiene el transform, para que funcione la elevación */
  animation: of-izar .8s cubic-bezier(.16, 1, .3, 1) 1.6s backwards;
}
.of-boton.of-izado { animation: none; }
.of-boton:hover { transform: translateY(-6px); background: #0b2240; box-shadow: 0 22px 44px rgba(0, 0, 0, .6); }
.of-boton:focus-visible { outline: 3px solid #7cc0ea; outline-offset: 3px; }
.of-boton { box-shadow: 0 14px 34px rgba(0, 0, 0, .5); }
.of-rostro { position: relative; display: block; flex: none; overflow: hidden; background: #07182e; }
.of-rostro img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; transition: opacity .9s ease, transform .9s cubic-bezier(.16, 1, .3, 1); }
.of-rostro img:not(.on) { opacity: 0; transform: scale(1.12); }
.of-boton-avatar { width: 92px; height: 92px; border-right: 2px solid #e0b23c; }
.of-cabeza-avatar { width: 72px; height: 72px; border: 2px solid #e0b23c; }
.of-relevo-nombre { display: grid !important; }
.of-relevo-nombre span { grid-area: 1 / 1; transition: opacity .9s ease; }
.of-relevo-nombre span:not(.on) { opacity: 0; }
.of-boton-texto { display: flex; flex-direction: column; justify-content: center; padding: 6px 18px 6px 14px; }
.of-boton-texto strong {
  font-family: 'Saira Stencil One', 'Barlow Condensed', sans-serif;
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1.1;
  color: #e0b23c;
  text-transform: uppercase;
  white-space: nowrap;
}
.of-estado { display: flex; align-items: center; gap: 8px; font-size: 1rem; color: #fff; white-space: nowrap; }
.of-punto { position: relative; width: 10px; height: 10px; border-radius: 50%; background: #e0b23c; flex: none; }
.of-punto::after { border-radius: 50%; }
.of-punto::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid #e0b23c;
  animation: of-baliza 2.4s ease-out infinite;
}
@keyframes of-izar { from { opacity: 0; transform: translateY(120%); } to { opacity: 1; transform: none; } }
@keyframes of-baliza { from { transform: scale(1); opacity: 1; } 70%, to { transform: scale(2.6); opacity: 0; } }
@keyframes of-abrir { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: none; } }
@keyframes of-entra { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes of-escribe { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ---------- Panel ---------- */
.of-panel {
  position: fixed;
  right: 28px;
  bottom: 22px;
  z-index: 1045;
  display: flex;
  flex-direction: column;
  width: 420px;
  max-width: calc(100vw - 16px);
  height: min(680px, calc(100vh - 110px));
  background: #fff;
  border: 2px solid #07182e;
  border-top: 8px solid #e0b23c;
  box-shadow: 0 24px 70px rgba(7, 24, 46, .55);
  animation: of-abrir .35s cubic-bezier(.16, 1, .3, 1);
}
.of-cabeza {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 12px;
  background: #07182e;
  color: #fff;
  flex: none;
}
.of-cabeza-texto { flex: 1; min-width: 0; }
.of-titulo {
  font-family: 'Saira Stencil One', 'Barlow Condensed', sans-serif;
  font-size: 1.4rem;
  line-height: 1.15;
  color: #fff;
}
.of-aviso { font-size: 1rem; line-height: 1.25; color: #fff; }
.of-cerrar {
  width: 44px;
  height: 44px;
  flex: none;
  border: 2px solid transparent;
  background: transparent;
  color: #fff;
  font-size: 1.15rem;
  cursor: pointer;
}
.of-cerrar:hover { border-color: #e0b23c; color: #e0b23c; }
.of-cerrar:focus-visible, .of-log:focus-visible { outline: 3px solid #7cc0ea; outline-offset: -3px; }

/* ---------- Conversación ---------- */
.of-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px;
  background: #eef1f4;
}
.of-msg {
  max-width: 92%;
  padding: 10px 12px;
  white-space: pre-line;
  overflow-wrap: anywhere;
  animation: of-entra .25s ease-out;
}
.of-msg-oficial { align-self: flex-start; background: #fff; border: 1px solid #e0b23c; color: #14233a; }
.of-msg-usuario { align-self: flex-end; background: #0b2240; color: #fff; }
.of-escribiendo { display: flex; gap: 5px; padding: 15px 14px; }
.of-escribiendo span { width: 8px; height: 8px; background: #0b2240; animation: of-escribe 1s infinite; }
.of-escribiendo span:nth-child(2) { animation-delay: .15s; }
.of-escribiendo span:nth-child(3) { animation-delay: .3s; }

.of-acciones { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; max-width: 92%; }
.of-accion {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  border: 2px solid #0b2240;
  background: #fff;
  color: #0b2240;
  transition: transform .2s;
}
.of-accion:hover { transform: translateY(-2px); background: #0b2240; color: #fff; }
.of-accion-wa { background: var(--of-verde); border-color: var(--of-verde); color: #fff; }
.of-accion-wa:hover { background: #07482e; border-color: #07482e; color: #fff; }
.of-accion-tel { background: #0b2240; color: #fff; }
.of-accion-tel:hover { background: #e0b23c; border-color: #e0b23c; color: #07182e; }
.of-accion:focus-visible { outline: 3px solid #1f6fa8; outline-offset: 2px; }

/* ---------- Temas ---------- */
.of-temas {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  background: #fff;
  border-top: 2px solid #0b2240;
  flex: none;
}
.of-tema {
  min-height: 40px;
  padding: 6px 10px;
  border: 2px solid #0b2240;
  background: #fff;
  color: #0b2240;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.15;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.of-tema:hover { background: #e0b23c; }
.of-tema:focus-visible { outline: 3px solid #1f6fa8; outline-offset: 2px; }

.of-temas::-webkit-scrollbar { height: 4px; }

/* ---------- Pregunta libre ---------- */
.of-form { display: flex; flex: none; border-top: 2px solid #0b2240; }
.of-form input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #14233a;
  font: inherit;
  font-size: 1rem;
}
.of-form input::placeholder { color: #43536a; opacity: 1; }
.of-form input:focus { outline: 3px solid #1f6fa8; outline-offset: -3px; }
.of-form button {
  width: 56px;
  flex: none;
  border: 0;
  background: #0b2240;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
.of-form button:hover { background: #e0b23c; color: #07182e; }
.of-form button:focus-visible { outline: 3px solid #7cc0ea; outline-offset: -5px; }

/* ---------- Móvil ---------- */
@media (max-width: 575.98px) {
  .of-boton { right: 12px; bottom: 12px; }
  /* Solo el rostro: el texto tapaba el contenido; el aviso sigue en aria-label y en el panel */
  .of-boton-texto { display: none; }
  .of-boton-avatar { width: 64px; height: 64px; border-right: 0; }
  .of-panel {
    inset: 8px;
    width: auto;
    max-width: none;
    height: auto;
  }
  .of-temas { flex-wrap: nowrap; overflow-x: auto; }
  .of-tema { flex: none; }
}
@media (max-height: 480px) {
  .of-panel { height: calc(100vh - 16px); bottom: 8px; }
  .of-temas { flex-wrap: nowrap; overflow-x: auto; }
  .of-tema { flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  .of-rostro img, .of-relevo-nombre span { transition: none !important; }
  .of-boton, .of-panel, .of-msg, .of-punto::after, .of-escribiendo span { animation: none !important; }
  .of-boton, .of-accion, .of-tema { transition: none !important; }
  .of-boton:hover, .of-accion:hover { transform: none; }
}
