/* Encabezado, formularios, avisos, botón flotante, modal y calendario. */

/* Sin JavaScript: se ocultan los controles que no funcionarían y el menú queda visible. */
html:not(.js) .fab,
html:not(.js) .nav-toggle,
html:not(.js) [data-open-meeting],
html:not(.js) .demo__tab[aria-selected="false"] { display: none; }

html:not(.js) .site-header__inner { flex-wrap: wrap; }
html:not(.js) .site-nav {
  position: static;
  display: block;
  width: 100%;
  padding: 0 0 .75rem;
  border: 0;
}
html:not(.js) .site-nav__list { display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
html:not(.js) .site-nav__list a { font-size: 1rem; padding: .4rem 0; }

/* Con el modal abierto, la página de fondo no se desplaza. */
html:has(dialog[open]) { overflow: hidden; }

/* Encabezado */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--ink);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.site-header.is-scrolled { border-bottom-color: var(--line-dark); }

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
}

.site-logo {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.01em;
  text-decoration: none;
}

.nav-toggle {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-right: -.5rem;
}
.nav-toggle__close { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle__open { display: none; }
.nav-toggle[aria-expanded="true"] .nav-toggle__close { display: block; }

.site-nav {
  position: absolute;
  inset: 100% 0 auto;
  display: none;
  padding: .5rem var(--gutter) 1.5rem;
  background: var(--ink);
  border-bottom: 1px solid var(--line-dark);
}
.site-nav.is-open { display: block; }

.site-nav__list a {
  display: block;
  padding: .8rem 0;
  font-size: 1.15rem;
  text-decoration: none;
}
.site-nav__list a:hover,
.site-nav__list a[aria-current="true"] { color: var(--amber); }
.site-nav .btn { width: 100%; margin-top: .75rem; }

@media (min-width: 860px) {
  .nav-toggle { display: none; }
  .site-nav,
  .site-nav.is-open {
    position: static;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0;
    border: 0;
    background: none;
  }
  .site-nav__list { display: flex; gap: 1.75rem; }
  .site-nav__list a {
    position: relative;
    padding: .4rem 0;
    font-size: 1rem;
  }
  .site-nav__list a::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 2px;
    background: var(--amber);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .25s var(--ease);
  }
  .site-nav__list a:hover::after,
  .site-nav__list a[aria-current="true"]::after { transform: scaleX(1); }
  .site-nav .btn { width: auto; margin: 0; }
}

/* Campos de formulario */
.field { display: grid; gap: .35rem; }
.field + .field { margin-top: 1.1rem; }

.field label,
.modal legend {
  font-size: .95rem;
  font-weight: 600;
}
.field__optional { font-weight: 400; color: var(--on-light-muted); }

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 3rem;
  padding: .65rem .85rem;
  border: 1.5px solid var(--line-control);
  border-radius: 8px;
  background: #fff;
  color: var(--on-light);
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; }
.field input:hover,
.field select:hover,
.field textarea:hover { border-color: var(--on-light); }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 0;
  border-color: #0b6e80;
  box-shadow: 0 0 0 3px rgba(11, 110, 128, .2);
}
.field.is-invalid input,
.field.is-invalid select,
.field.is-invalid textarea { border-color: var(--error-light); }
.field.is-valid input,
.field.is-valid select,
.field.is-valid textarea { border-color: var(--success); }

.field__error {
  color: var(--error-light);
  font-size: .9rem;
  font-weight: 500;
}

.visually-hidden-field {
  position: absolute;
  left: -100vw;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-error {
  margin-bottom: 1.25rem;
  color: var(--error-light);
  font-weight: 500;
}

.form-success {
  margin-bottom: 1.25rem;
  padding: .7rem .9rem;
  border-left: 3px solid var(--success);
  background: #e0f3ea;
  color: #0e4a36;
  font-size: .975rem;
}

/* Estado de carga de los botones */
.btn.is-loading { cursor: progress; opacity: .85; transform: none; }
.btn.is-loading::before {
  content: "";
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Avisos */
.toasts {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 300;
  display: grid;
  gap: .5rem;
  max-width: min(24rem, calc(100vw - 6.5rem));
}
/* Dentro del modal van arriba, para no tapar los horarios. */
.modal .toasts { top: 1rem; bottom: auto; max-width: min(24rem, calc(100vw - 2rem)); }
.toast {
  padding: .8rem 1rem;
  border-left: 4px solid var(--aqua);
  border-radius: 6px;
  background: var(--paper);
  color: var(--on-light);
  box-shadow: 0 10px 30px rgba(4, 18, 23, .35);
  font-size: .95rem;
  animation: toast-in .25s var(--ease);
}
.toast--error { border-left-color: var(--error-light); }
.toast--success { border-left-color: var(--success); }
.toast--info { border-left-color: var(--amber); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

/* Botón flotante */
.fab {
  position: fixed;
  right: clamp(1rem, 3vw, 2rem);
  bottom: clamp(1rem, 3vw, 2rem);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .75rem;
}

.fab__toggle {
  display: grid;
  place-items: center;
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 50%;
  background: var(--amber);
  color: var(--ink-deep);
  box-shadow: 0 8px 24px rgba(4, 18, 23, .4);
  transition: background-color .2s, transform .2s var(--ease);
}
.fab__toggle:hover { background: var(--amber-strong); transform: scale(1.06); }
.fab__toggle .icon { grid-area: 1 / 1; width: 1.65rem; height: 1.65rem; transition: opacity .2s, transform .25s var(--ease); }
.fab__toggle-close { opacity: 0; transform: rotate(-90deg); }
.fab__toggle[aria-expanded="true"] .fab__toggle-open { opacity: 0; transform: rotate(90deg); }
.fab__toggle[aria-expanded="true"] .fab__toggle-close { opacity: 1; transform: none; }

.fab__menu { display: grid; gap: .5rem; justify-items: end; }
.fab__menu > li { animation: fab-item .24s var(--ease) both; }
.fab__menu > li:nth-child(1) { animation-delay: .1s; }
.fab__menu > li:nth-child(2) { animation-delay: .05s; }

@keyframes fab-item {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
}

.fab__item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .45rem 1rem .45rem .45rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--on-light);
  box-shadow: 0 6px 20px rgba(4, 18, 23, .3);
  font-size: .975rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  transition: transform .2s var(--ease), background-color .2s;
}
a.fab__item:hover,
button.fab__item:hover { background: #fff; transform: translateX(-4px); }

.fab__icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
}
.fab__icon .icon { width: 1.25rem; height: 1.25rem; }
.fab__icon--whatsapp { background: #128c4a; }
.fab__icon--accent { background: var(--amber); color: var(--ink-deep); }

/* Panel para escribir el mensaje de WhatsApp */
.fab__composer {
  display: grid;
  gap: .9rem;
  width: min(21rem, calc(100vw - 2rem));
  padding: 1.1rem;
  border-radius: 14px;
  background: var(--paper);
  color: var(--on-light);
  box-shadow: 0 10px 30px rgba(4, 18, 23, .35);
  animation: fab-item .24s var(--ease);
}
.fab__composer-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.fab__composer-title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; }
.fab__back {
  min-height: 2.25rem;
  padding-inline: .5rem;
  border-radius: 6px;
  color: var(--on-light-muted);
  font-size: .925rem;
  font-weight: 600;
  text-decoration: underline;
}
.fab__back:hover { color: var(--on-light); }
.fab__composer :focus-visible { outline-color: #0b6e80; }

.btn--whatsapp { background: #0f7a40; color: #fff; }
.btn--whatsapp:hover { background: #0c6535; }
.btn--whatsapp .icon { width: 1.25rem; height: 1.25rem; }

/* Modal de reunión */
.modal {
  width: min(100%, 56rem);
  max-width: 100%;
  max-height: 100dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 16px 16px 0 0;
  background: var(--paper);
  color: var(--on-light);
}
.modal[open] { animation: modal-in .28s var(--ease); }
.modal::backdrop { background: rgba(4, 18, 23, .72); }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(24px); }
}

.modal__panel { display: grid; gap: 1.25rem; padding: 1.5rem var(--gutter) 2rem; }
.modal__header { display: flex; justify-content: space-between; gap: 1rem; }
.modal__header h2 { font-size: clamp(1.6rem, 4vw, 2.1rem); }
.modal__header p { margin-top: .4rem; color: var(--on-light-muted); }

.modal__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  margin: -.4rem -.5rem 0 0;
  border-radius: 50%;
  transition: background-color .15s;
}
.modal__close:hover { background: var(--mist); }

.modal__grid { display: grid; gap: 1.75rem; }
.modal__schedule { display: grid; gap: 1.25rem; align-content: start; }
.modal legend { margin-bottom: .5rem; }
.modal__details .btn { margin-top: 1.25rem; }

/* En una sola columna, el orden sigue el recorrido: datos, fecha, horario y motivo. */
@media (max-width: 759.98px) {
  .modal__grid { gap: 1.1rem; }
  .modal__details { display: contents; }
  .modal__details .field + .field { margin-top: 0; }
  .modal__schedule { order: 1; }
  .modal__details .field:nth-child(3) { order: 2; }
  .modal__details .btn { order: 3; margin-top: 0; }
}

@media (min-width: 760px) {
  .modal { margin: auto; border-radius: 16px; max-height: 92dvh; }
  .modal__panel { padding: 2rem; }
  .modal__grid { grid-template-columns: 1.05fr 1fr; gap: 2.5rem; }
}

/* Calendario */
.calendar {
  padding: .75rem;
  border: 1.5px solid var(--line-light);
  border-radius: 10px;
  background: #fff;
}
.calendar__head { display: flex; align-items: center; justify-content: space-between; }
.calendar__month { font-weight: 600; }
.calendar__month::first-letter { text-transform: uppercase; }
.calendar__nav {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
}
.calendar__nav:hover:not(:disabled) { background: var(--mist); }
.calendar__nav:disabled { opacity: .3; cursor: not-allowed; }
.calendar__nav .icon { width: 1.1rem; height: 1.1rem; }

.calendar__weekdays,
.calendar__days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.calendar__weekdays { margin-top: .35rem; color: var(--on-light-muted); font-size: .8rem; }

.calendar__day {
  height: 2.5rem;
  width: 100%;
  border-radius: 8px;
  font-size: .95rem;
  transition: background-color .15s, color .15s;
}
.calendar__day:hover:not(:disabled) { background: var(--mist); }
.calendar__day:disabled { color: #7b8b8c; cursor: not-allowed; }
.calendar__day:not(:disabled) { font-weight: 600; }
.calendar__day.is-today { box-shadow: inset 0 0 0 1.5px var(--line-control); }
.calendar__day[aria-pressed="true"],
.calendar__day[aria-pressed="true"]:hover { background: var(--ink); color: var(--amber); font-weight: 600; }

/* Horarios */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.6rem, 1fr)); gap: .4rem; }
.slots__empty { grid-column: 1 / -1; color: var(--on-light-muted); font-size: .95rem; }
.slots .btn { grid-column: 1 / -1; justify-self: start; }

.slot {
  min-height: 2.6rem;
  border: 1.5px solid var(--line-control);
  border-radius: 8px;
  background: #fff;
  font-weight: 500;
  transition: border-color .15s, background-color .15s, color .15s;
}
.slot:hover { border-color: var(--ink); }
.slot[aria-pressed="true"],
.slot[aria-pressed="true"]:hover { border-color: var(--ink); background: var(--ink); color: var(--amber); }

.modal fieldset > .field__error { margin-top: .4rem; }

/* Confirmación de la solicitud */
.modal__success { display: grid; justify-items: start; gap: 1.1rem; padding-block: .5rem 1rem; font-size: 1.1rem; }
.modal__success-icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: #e0f3ea;
  color: var(--success);
}
