/*! Asistente Meteo 2.0 — experiència pilot accessible, Fase 4 */
:root {
  --ma-brand: var(--brand, #2dd4bf);
  --ma-brand-strong: var(--brand-2, #0f766e);
  --ma-bg: var(--card, #111827);
  --ma-bg-soft: color-mix(in srgb, var(--ma-bg) 90%, white);
  --ma-text: var(--text, #f1f5f9);
  --ma-muted: var(--muted, #a8b3c2);
  --ma-border: var(--border, rgba(148, 163, 184, .25));
  --ma-danger: #fb7185;
}

.ma-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html.ma-dialog-open,
html.ma-dialog-open body {
  width: 100%;
  max-width: 100%;
  overflow: hidden !important;
  overflow-x: hidden !important;
  overscroll-behavior: none;
}

#meteo-assistant-root {
  position: relative;
  z-index: 2147483000;
  isolation: isolate;
  color: var(--ma-text);
  font: 400 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

#meteo-assistant-root [hidden] {
  display: none !important;
}

.ma-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: rgba(2, 6, 23, .58);
  opacity: 0;
  backdrop-filter: blur(3px);
  transition: opacity .2s ease;
}

.ma-panel {
  position: fixed;
  z-index: 1;
  top: 0;
  right: 0;
  width: min(430px, calc(100vw - 48px));
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--ma-text);
  background:
    radial-gradient(circle at 85% 0, color-mix(in srgb, var(--ma-brand) 15%, transparent), transparent 34%),
    var(--ma-bg);
  border-left: 1px solid var(--ma-border);
  box-shadow: -18px 0 60px rgba(2, 6, 23, .36);
  transform: translateX(104%);
  transition: transform .22s ease;
}

#meteo-assistant-root.is-open .ma-backdrop {
  opacity: 1;
}

#meteo-assistant-root.is-open .ma-panel {
  transform: translateX(0);
}

.ma-header {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: calc(18px + env(safe-area-inset-top)) 20px 17px;
  border-bottom: 1px solid var(--ma-border);
}

.ma-heading,
.ma-title-line,
.ma-title-line > div {
  min-width: 0;
}

.ma-title-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ma-title-line h2 {
  margin: 0;
  color: var(--ma-text);
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: -.02em;
}

.ma-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #081018;
  background: linear-gradient(135deg, var(--ma-brand), color-mix(in srgb, var(--ma-brand) 65%, white));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--ma-brand) 25%, transparent);
}

.ma-mark svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ma-beta {
  display: inline-flex;
  margin-top: 4px;
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--ma-brand) 42%, transparent);
  border-radius: 999px;
  color: color-mix(in srgb, var(--ma-brand) 74%, white);
  background: color-mix(in srgb, var(--ma-brand) 10%, transparent);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.4;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.ma-heading > p {
  margin: 9px 0 0 54px;
  color: var(--ma-muted);
  font-size: 12px;
}

.ma-icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  margin: -3px -5px 0 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 13px;
  color: var(--ma-muted);
  background: transparent;
  cursor: pointer;
}

.ma-icon-button:hover {
  color: var(--ma-text);
  border-color: var(--ma-border);
  background: color-mix(in srgb, var(--ma-text) 6%, transparent);
}

.ma-icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.ma-conversation {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.ma-log {
  min-height: 160px;
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--ma-muted) 40%, transparent) transparent;
}

.ma-message {
  display: flex;
  margin: 0 0 16px;
}

.ma-message-user {
  justify-content: flex-end;
}

.ma-message p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ma-message-user > p {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 16px 16px 4px 16px;
  color: #071117;
  background: color-mix(in srgb, var(--ma-brand) 78%, white);
  font-weight: 570;
}

.ma-bubble {
  max-width: 94%;
  padding: 13px 14px;
  border: 1px solid var(--ma-border);
  border-radius: 4px 17px 17px;
  background: color-mix(in srgb, var(--ma-bg-soft) 94%, transparent);
  box-shadow: 0 8px 24px rgba(2, 6, 23, .1);
}

.ma-message-error .ma-bubble {
  border-color: color-mix(in srgb, var(--ma-danger) 45%, transparent);
}

.ma-sources {
  display: grid;
  gap: 5px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--ma-border);
  color: var(--ma-muted);
  font-size: 11px;
  line-height: 1.4;
}

.ma-sources strong {
  color: var(--ma-text);
  font-size: 11px;
}

.ma-sources ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ma-sources li {
  overflow-wrap: anywhere;
}

.ma-sources a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.ma-sources a:hover,
.ma-sources a:focus-visible {
  color: var(--ma-text);
}

.ma-freshness {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--ma-muted);
  background: color-mix(in srgb, var(--ma-muted) 10%, transparent);
  font-size: 10px;
  font-weight: 700;
}

.ma-freshness::before {
  width: 6px;
  height: 6px;
  content: "";
  border-radius: 50%;
  background: #94a3b8;
}

.ma-freshness.is-fresh::before {
  background: #34d399;
}

.ma-freshness.is-historical::before {
  background: #6f7f99;
}

.ma-freshness.is-climate::before {
  background: #8f70c9;
}

.ma-freshness.is-forecast::before {
  background: #4d91d8;
}

.ma-freshness.is-delayed::before {
  background: #fbbf24;
}

.ma-freshness.is-stale::before,
.ma-freshness.is-offline::before {
  background: #fb7185;
}

.ma-suggestions {
  flex: 0 0 auto;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 20px 10px;
  scrollbar-width: none;
}

.ma-suggestions::-webkit-scrollbar {
  display: none;
}

.ma-suggestions button {
  min-height: 36px;
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid color-mix(in srgb, var(--ma-brand) 35%, var(--ma-border));
  border-radius: 999px;
  color: var(--ma-text);
  background: color-mix(in srgb, var(--ma-brand) 8%, transparent);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.ma-suggestions button:hover {
  border-color: var(--ma-brand);
  background: color-mix(in srgb, var(--ma-brand) 15%, transparent);
}

.ma-status {
  min-height: 0;
  margin: 0;
  padding: 0 20px;
  color: var(--ma-danger);
  font-size: 12px;
}

.ma-status:not(:empty) {
  min-height: 20px;
  padding-bottom: 5px;
}

.ma-composer {
  width: 100%;
  min-width: 0;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 20px 8px;
  border-top: 1px solid var(--ma-border);
  background: color-mix(in srgb, var(--ma-bg) 96%, transparent);
}

.ma-input-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex: 1 1 auto;
}

.ma-input-wrap textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 52px;
  max-height: 132px;
  resize: vertical;
  box-sizing: border-box;
  padding: 11px 12px 22px;
  border: 1px solid var(--ma-border);
  border-radius: 14px;
  color: var(--ma-text);
  background: color-mix(in srgb, var(--ma-bg-soft) 96%, transparent);
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
}

.ma-input-wrap textarea::placeholder {
  color: var(--ma-muted);
  opacity: .82;
}

.ma-counter {
  position: absolute;
  right: 10px;
  bottom: 5px;
  color: var(--ma-muted);
  font-size: 10px;
  pointer-events: none;
}

.ma-counter.is-near-limit {
  color: #fbbf24;
}

.ma-send {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 15px;
  color: #071117;
  background: var(--ma-brand);
  cursor: pointer;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--ma-brand) 22%, transparent);
}

.ma-send span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.ma-send svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ma-send:disabled,
.ma-access-form button:disabled {
  cursor: wait;
  opacity: .58;
}

.ma-privacy {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 20px calc(11px + env(safe-area-inset-bottom));
  color: var(--ma-muted);
  font-size: 10px;
  text-align: center;
}

.ma-access {
  flex: 1 1 auto;
  overflow: auto;
  padding: 44px 28px 28px;
  text-align: center;
}

.ma-access-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 0 auto 17px;
  border-radius: 18px;
  color: var(--ma-brand);
  background: color-mix(in srgb, var(--ma-brand) 12%, transparent);
}

.ma-access-icon svg {
  width: 29px;
  height: 29px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ma-access h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.ma-access > p {
  max-width: 330px;
  margin: 0 auto 24px;
  color: var(--ma-muted);
}

.ma-access-form {
  width: 100%;
  max-width: 340px;
  min-width: 0;
  margin: 0 auto;
  text-align: left;
}

.ma-access-form label {
  display: block;
  margin: 0 0 6px;
  color: var(--ma-text);
  font-size: 12px;
  font-weight: 700;
}

.ma-access-row {
  width: 100%;
  min-width: 0;
  display: flex;
  gap: 8px;
}

.ma-access-row input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 46px;
  flex: 1 1 auto;
  padding: 9px 11px;
  border: 1px solid var(--ma-border);
  border-radius: 12px;
  color: var(--ma-text);
  background: var(--ma-bg-soft);
  font: inherit;
  font-size: 16px;
}

.ma-access-row button {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 9px 14px;
  border: 0;
  border-radius: 12px;
  color: #071117;
  background: var(--ma-brand);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.ma-access-status {
  min-height: 22px;
  margin: 12px auto 0 !important;
  color: var(--ma-danger) !important;
  font-size: 12px;
}

#meteoAssistantBtn.jd-fab--assistant {
  left: auto;
  right: var(--ma-fab-right, 16px);
  bottom: var(--ma-fab-base-bottom, var(--jd-fab-bottom, clamp(8px, 1.6vh, 14px)));
  width: var(--ma-fab-width, auto);
  height: var(--ma-fab-height, 36px);
  min-width: var(--ma-fab-width, 48px);
  justify-content: center;
  border-color: color-mix(in srgb, var(--ma-brand) 42%, var(--border, #2b2f36));
  transform: translateZ(0);
}

#jd-fab-wrap.ma-fab-swapped #goTopBtn {
  bottom: calc(
    var(--ma-fab-base-bottom, var(--jd-fab-bottom, clamp(8px, 1.6vh, 14px)))
    + var(--ma-fab-height, 36px)
    + 8px
  );
}

#meteoAssistantBtn.jd-fab--assistant:hover {
  transform: translateY(-2px);
}

#meteoAssistantBtn.jd-fab--assistant:active {
  transform: translateZ(0);
}

.ma-fab-icon {
  display: inline-flex;
}

.ma-fab-label {
  white-space: nowrap;
}

.ma-fab-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--ma-brand);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#meteo-assistant-root button:focus-visible,
#meteo-assistant-root input:focus-visible,
#meteo-assistant-root textarea:focus-visible,
#meteoAssistantBtn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ma-brand) 72%, white);
  outline-offset: 3px;
}

html[data-theme="light"] #meteo-assistant-root,
body[data-theme="light"] #meteo-assistant-root {
  --ma-bg: #f8fafc;
  --ma-bg-soft: #ffffff;
  --ma-text: #0f172a;
  --ma-muted: #526174;
  --ma-border: rgba(15, 23, 42, .15);
}

@media (prefers-color-scheme: light) {
  html[data-theme="auto"] #meteo-assistant-root,
  html:not([data-theme]) #meteo-assistant-root {
    --ma-bg: #f8fafc;
    --ma-bg-soft: #ffffff;
    --ma-text: #0f172a;
    --ma-muted: #526174;
    --ma-border: rgba(15, 23, 42, .15);
  }
}

@media (max-width: 767.98px) {
  .ma-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100vw;
    max-width: 100%;
    max-height: var(--ma-visual-height, 100dvh);
    overflow-x: hidden;
    height: min(88vh, 760px);
    height: min(88dvh, 760px);
    border: 1px solid var(--ma-border);
    border-width: 1px 0 0;
    border-radius: 23px 23px 0 0;
    box-shadow: 0 -18px 55px rgba(2, 6, 23, .42);
    transform: translateY(104%);
  }

  #meteo-assistant-root.is-open .ma-panel {
    transform: translateY(0);
  }

  .ma-header {
    padding: 15px 15px 13px;
  }

  .ma-header::before {
    position: absolute;
    top: 7px;
    left: 50%;
    width: 38px;
    height: 4px;
    content: "";
    border-radius: 999px;
    background: color-mix(in srgb, var(--ma-muted) 45%, transparent);
    transform: translateX(-50%);
  }

  .ma-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 12px;
  }

  .ma-title-line h2 {
    font-size: 18px;
  }

  .ma-heading > p {
    margin: 6px 0 0 50px;
  }

  .ma-log {
    padding: 15px;
  }

  .ma-suggestions {
    padding-right: 15px;
    padding-left: 15px;
  }

  .ma-composer {
    padding: 10px 15px 7px;
  }

  .ma-status {
    padding-right: 15px;
    padding-left: 15px;
  }

  .ma-privacy {
    padding-right: 15px;
    padding-left: 15px;
  }

}

@media (max-width: 359.98px) {
  .ma-panel {
    height: min(92vh, 760px);
    height: min(92dvh, 760px);
    border-radius: 18px 18px 0 0;
  }

  .ma-header {
    gap: 8px;
    padding-right: 10px;
    padding-left: 12px;
  }

  .ma-heading > p {
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ma-access {
    padding: 30px 15px 20px;
  }

  .ma-access-row {
    flex-direction: column;
  }

  .ma-access-row button {
    width: 100%;
  }

  .ma-log,
  .ma-composer {
    padding-right: 12px;
    padding-left: 12px;
  }

  .ma-send {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .ma-panel,
  .ma-backdrop,
  #meteoAssistantBtn {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
