/* Chat layout and message styling */

@font-face {
  font-family: "Material Symbols Outlined";
  font-style: normal;
  font-weight: 400;
  src: url("../assets/material-symbols/MaterialSymbolsOutlined.ttf?v=0.19.8-insert-chart") format("truetype");
}

/* Nunito autoalojada: es variable, asi que un unico fichero por subset cubre los
   pesos 400-700 que usa Chat Window. Solo latin y latin-ext, que son los subsets
   de los idiomas que sirve el chat. */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../assets/fonts/nunito-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../assets/fonts/nunito-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --assistant-logo-image: url("/logo/assistant-logo.png");
  --assistant-logo-size: 32px;
  --assistant-logo-radius: 50%;
}

.chat-material-symbol {
  direction: ltr;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  font-family: "Material Symbols Outlined";
  font-feature-settings: "liga";
  font-size: 20px;
  font-style: normal;
  font-weight: normal;
  letter-spacing: normal;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}

.wrap.chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
  max-height: 840px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icons {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chat-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header-logo {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border, #e5e7eb);
  background: #fff;
  padding: 2px;
}

.chat-header-title {
  margin: 0;
}

.header-actions .chat-action {
  background: midnightblue;
  border-color: midnightblue;
  color: #fff;
  box-shadow: 0 4px 10px rgba(25, 25, 112, 0.25);
  transition:
    background 0.15s ease,
    transform 0.08s ease,
    box-shadow 0.15s ease;
}

.header-actions .chat-action:hover {
  background: navy;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(25, 25, 112, 0.28);
}

.header-actions .chat-action:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(25, 25, 112, 0.22);
}

.header-actions .chat-action img,
.header-actions .chat-action .chat-material-symbol {
  width: 18px;
  height: 18px;
}

.header-actions .chat-action img {
  filter: brightness(0) invert(1);
}

.header-actions .chat-action,
.composer-input .send-icon,
.message.user .bubble {
  background: var(--chat-accent, #0032a8);
  border-color: var(--chat-accent, #0032a8);
  color: #fff;
}

.header-actions .chat-action:hover,
.composer-input .send-icon:hover {
  background: var(--chat-accent, #0032a8);
}

.header-actions .chat-action:active,
.composer-input .send-icon:active {
  background: var(--chat-accent, #0032a8);
}

.chat-window {
  flex: 1;
  background: white;
  border: 1px solid lightgray;
  border-radius: 12px;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  min-height: 0;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-new-conversation {
  align-items: center;
}

.chat-new-conversation-btn {
  border: 1px solid #1d4ed8;
  background: #1d4ed8;
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  align-self: center;
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.22);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
}

.chat-new-conversation-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(29, 78, 216, 0.26);
}

.chat-new-conversation-btn:active {
  transform: translateY(0);
  box-shadow: 0 5px 12px rgba(29, 78, 216, 0.22);
}

.chat-new-conversation-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-new-conversation-note {
  font-style: italic;
}

.message .bubble {
  display: inline-block;
  max-width: 640px;
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  background: ghostwhite;
  opacity: 0;
  animation-duration: 0.38s;
  animation-fill-mode: forwards;
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

body:not(.widget-embed):not(.aizy-agent-center) .message .bubble {
  font-family: "Nunito", "Segoe UI", Arial, Helvetica, sans-serif;
}

.message.assistant .bubble {
  position: relative;
  background: whitesmoke;
  border: 1px solid lightgray;
  color: black;
  padding: 12px 16px 12px calc(16px + var(--assistant-logo-size, 32px) + 12px);
  min-height: calc(var(--assistant-logo-size, 32px) + 24px);
  animation-name: bubbleSlideInLeft;
}

.message.assistant .bubble::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 12px;
  width: var(--assistant-logo-size, 32px);
  height: var(--assistant-logo-size, 32px);
  background-image: var(
    --assistant-logo-image,
    url("/logo/assistant-logo.png")
  );
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: var(--assistant-logo-radius, 50%);
}

.message.assistant.pending .bubble {
  background: #ffffff;
  color: #000000;
  min-height: 0;
}

.message.assistant.pending .bubble::before {
  display: none;
}

.message.assistant.error .bubble {
  background: mistyrose;
  border: 1px solid salmon;
  color: firebrick;
}

.message.assistant.warning .bubble {
  background: #fff8db;
  border: 1px solid #facc15;
  color: #854d0e;
}

.message.user {
  align-items: flex-end;
}

.message.user .bubble {
  background: var(--chat-accent, #0032a8);
  color: #fff;
  border: 1px solid var(--chat-accent, #0032a8);
  animation-name: bubbleSlideInRight;
}
.message-attachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  max-width: 320px;
}
.attachment-preview {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
  padding: 8px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
.attachment-preview-image {
  display: block;
  width: 100%;
  max-width: 280px;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 6px;
}
.attachment-preview-name {
  font-weight: 600;
  color: #111827;
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
}
.attachment-preview-meta {
  margin-top: 2px;
  color: #6b7280;
  font-size: 12px;
}

.message-meta {
  font-size: 12px;
  color: dimgray;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.message-meta a {
  color: steelblue;
  text-decoration: none;
  font-weight: 600;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  justify-content: var(--action-buttons-justify, flex-start);
  max-width: 640px;
  width: 100%;
  align-self: flex-start;
}

.action-btn {
  border: 1px solid var(--action-btn-border, var(--chat-accent, #0032a8));
  background: var(--action-btn-bg, #fff);
  color: var(--action-btn-text, var(--chat-accent, #0032a8));
  padding: 6px 12px;
  border-radius: 999px;
  font-size: var(--action-btn-font-size, 12px);
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.08s ease,
    box-shadow 0.15s ease;
}

.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.action-btn:active {
  transform: translateY(0);
}

.calendar-picker {
  align-self: flex-start;
  width: min(100%, 640px);
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(0, 50, 168, 0.14);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(244, 247, 255, 0.96));
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.calendar-picker-title,
.calendar-picker-slots-title {
  font-size: 12px;
  font-weight: 800;
  color: #334155;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.calendar-picker-slots-title {
  margin-top: 12px;
}

.calendar-picker-days,
.calendar-picker-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.calendar-picker-day,
.calendar-picker-slot {
  border: 1px solid rgba(0, 50, 168, 0.18);
  border-radius: 999px;
  background: #fff;
  color: #12306b;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.calendar-picker-day:hover,
.calendar-picker-slot:hover,
.calendar-picker-day.is-selected {
  border-color: var(--chat-accent, #0032a8);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}

.calendar-picker-status {
  color: #64748b;
  font-size: 12px;
  margin-top: 8px;
}

.composer {
  margin-top: 40px;
  background: whitesmoke;
  /* border: 1px solid lightgray; */
  /* border-radius: 12px; */
  /* padding: 16px; */
  height: 120px;
}

.composer-input {
  position: relative;
}

.composer-input textarea {
  padding-right: 114px;
  border: 1px solid lightgray;
  height: 120px;
}

.composer-input.has-voice-controls textarea {
  padding-right: 264px;
}

.composer-input .send-icon {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  appearance: none;
  background: var(--chat-accent, #0032a8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.08s ease;
  box-shadow: 0 4px 10px rgba(25, 25, 112, 0.25);
}

.composer-input .send-icon[hidden] {
  display: none !important;
}

.composer-input .send-icon:hover {
  background: var(--chat-accent, #0032a8);
}

.composer-input .send-icon:active {
  transform: translateY(-50%) scale(0.96);
}

.composer-input .send-icon:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

.composer-input .send-icon img,
.composer-input .send-icon .chat-material-symbol {
  width: 20px;
  height: 20px;
}

.composer-input .send-icon img {
  filter: brightness(0) invert(1);
}
.composer-input .webchat-attach-btn {
  right: 62px;
}
.composer-input .voice-send-icon {
  right: 112px;
}
.composer-input .voice-send-icon.is-recording {
  background: #ef4444;
}
.composer-input .voice-send-icon:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}
.composer-input .voice-call-icon {
  right: 162px;
}
.composer-input .voice-call-icon svg {
  width: 20px;
  height: 20px;
  color: #ffffff;
}
.composer-input .voice-call-icon.is-active {
  background: #16a34a;
}
.voice-record-timer {
  position: absolute;
  top: 50%;
  right: 212px;
  transform: translateY(-50%);
  min-width: 44px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #b91c1c;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
}
.voice-record-timer.is-visible {
  opacity: 1;
  visibility: visible;
}

.voice-call-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(17, 24, 39, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.voice-call-confirm-dialog {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.18);
  padding: 16px;
}

.voice-call-confirm-text {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 14px;
}

.voice-call-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.composer textarea {
  min-height: 72px;
  resize: vertical;
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}

.composer textarea:focus,
.composer textarea:focus-visible {
  outline: none;
  box-shadow: none;
}

.task-form-card {
  box-sizing: border-box;
  display: grid;
  gap: 14px;
  width: min(100%, 640px);
  padding: 12px 16px;
  border: 1px solid lightgray;
  border-radius: 14px;
  background: whitesmoke;
  color: black;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.task-form-card.is-inactive {
  opacity: 0.72;
}

.task-form-note {
  margin: 0;
  color: #4b5563;
  font-size: 13px;
}

.task-form-field {
  display: grid;
  gap: 6px;
}

.task-form-field label {
  font-size: 14px;
  font-weight: 700;
}

.task-form-requirement {
  font-weight: 800;
  color: #b91c1c;
}

.task-form-validation-summary {
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 13px;
  font-weight: 700;
}

.task-form-validation-summary[hidden] {
  display: none;
}

.task-form-control {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  font: inherit;
}

textarea.task-form-control {
  min-height: 92px;
  resize: vertical;
}

.task-form-control:focus {
  outline: 2px solid color-mix(in srgb, var(--chat-accent, #0032a8) 28%, transparent);
  border-color: var(--chat-accent, #0032a8);
}

.task-form-field.is-invalid .task-form-control {
  border-color: #dc2626;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.16);
}

.task-form-error {
  color: #b91c1c;
  font-size: 12px;
}

.task-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 2px;
}

.task-form-actions button {
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.task-form-cancel {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
}

.task-form-submit {
  border: 1px solid var(--chat-accent, #0032a8);
  background: var(--chat-accent, #0032a8);
  color: #ffffff;
}

.task-form-actions button:disabled,
.task-form-control:disabled {
  cursor: not-allowed;
}

@keyframes bubbleSlideInLeft {
  0% {
    opacity: 0;
    transform: translateX(-14px) scale(0.98);
  }
  50% {
    opacity: 1;
    transform: translateX(3px) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes bubbleSlideInRight {
  0% {
    opacity: 0;
    transform: translateX(14px) scale(0.98);
  }
  50% {
    opacity: 1;
    transform: translateX(-3px) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}
