/* ── Chat agent widget (main page) ── */
.agent-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  font-family: var(--sans);
}

.agent-toggle {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--dark-blue);
  color: var(--yellow);
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 62, 116, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  transition: transform 0.2s, box-shadow 0.2s;
}

/* Intro mascot: pops from button, waves, returns (see agent.js for --play class) */
.agent-mascot-wrap {
  position: absolute;
  left: 50%;
  bottom: 24px;
  width: 76px;
  height: 106px;
  margin-left: -38px;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transform: translate3d(0, 16px, 0) scale(0.12);
  transform-origin: 50% 100%;
}

.agent-mascot {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.2));
}

.agent-mascot__arm {
  transform-origin: 36px 36px;
  transform-box: fill-box;
}

.agent-mascot-wrap--play {
  animation: agentMascotPop 3.4s cubic-bezier(0.34, 1.35, 0.64, 1) forwards;
}

.agent-mascot-wrap--play .agent-mascot__arm {
  animation: agentMascotWave 0.42s ease-in-out 5;
  animation-delay: 0.55s;
}

.agent-toggle--mascot-intro .agent-toggle-icon {
  animation: agentMascotIconHide 3.4s ease forwards;
}

@keyframes agentMascotPop {
  0% {
    opacity: 0;
    transform: translate3d(0, 20px, 0) scale(0.1);
  }
  9% {
    opacity: 1;
    transform: translate3d(0, -72px, 0) scale(1.06);
  }
  14% {
    transform: translate3d(0, -64px, 0) scale(1);
  }
  78% {
    opacity: 1;
    transform: translate3d(0, -64px, 0) scale(1);
  }
  90% {
    opacity: 0.9;
    transform: translate3d(0, -8px, 0) scale(0.32);
  }
  100% {
    opacity: 0;
    transform: translate3d(0, 12px, 0) scale(0.08);
  }
}

@keyframes agentMascotWave {
  0%,
  100% {
    transform: rotate(6deg);
  }
  50% {
    transform: rotate(-32deg);
  }
}

@keyframes agentMascotIconHide {
  0%,
  8% {
    opacity: 0;
    transform: scale(0.85);
  }
  10%,
  86% {
    opacity: 0;
  }
  92%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .agent-mascot-wrap--play,
  .agent-mascot-wrap--play .agent-mascot__arm,
  .agent-toggle--mascot-intro .agent-toggle-icon {
    animation: none !important;
  }
  .agent-mascot-wrap {
    opacity: 0;
    transform: translate3d(0, 10px, 0) scale(0);
    display: none;
  }
}

.agent-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(0, 62, 116, 0.5);
}

.agent-toggle:focus {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

.agent-toggle-icon {
  font-size: 26px;
  line-height: 1;
}

.agent-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 480px;
  max-height: calc(100vh - 120px);
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--light-gray);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-panel.hidden {
  display: none !important;
}

.agent-panel-header {
  background: var(--dark-blue);
  color: var(--yellow);
  padding: 12px 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}

.agent-panel-header-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.agent-panel-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-panel-sub {
  font-size: 12px;
  opacity: 0.95;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.agent-btn-icon {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.agent-fullscreen-btn {
  font-size: 20px;
}

.agent-btn-icon:hover {
  background: rgba(255, 255, 255, 0.25);
}

.agent-close {
  width: 36px;
  min-width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.agent-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Full AI mode: nearly full screen, fixed to viewport so it centers properly */
.agent-panel.agent-panel--fullscreen {
  position: fixed;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(92vw, 900px);
  height: min(88vh, 800px);
  max-width: none;
  max-height: none;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  z-index: 10000;
}

.agent-panel-body {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-panel-body-stack {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-messages-outer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-panel--list .agent-back {
  display: none !important;
}

.agent-panel--thread .agent-new-chat-btn {
  display: none !important;
}

.agent-panel--list .agent-fullscreen-btn {
  display: none !important;
}

.agent-panel--list .agent-panel-sub {
  white-space: normal;
  line-height: 1.35;
}

.agent-panel--thread .agent-panel-sub {
  white-space: nowrap;
}

.agent-new-chat-btn {
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}

.agent-view-list {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #f0eee6 0%, var(--off-white) 18%, #ebe8df 100%);
}

.agent-view-list.hidden {
  display: none !important;
}

.agent-view-thread.hidden {
  display: none !important;
}

.agent-chat-list-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(0, 62, 116, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.65) 0%, transparent 100%);
}

.agent-chat-list-heading {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  font-style: italic;
  color: var(--dark-blue);
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.agent-chat-list-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dark-blue);
  opacity: 0.55;
  white-space: nowrap;
}

.agent-chat-list-badge--hidden {
  visibility: hidden;
}

.agent-chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-chat-list::-webkit-scrollbar {
  width: 6px;
}

.agent-chat-list::-webkit-scrollbar-thumb {
  background: rgba(0, 62, 116, 0.22);
  border-radius: 99px;
}

.agent-chat-list:focus-within {
  outline: none;
}

.agent-chat-row {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(0, 62, 116, 0.1);
  border-radius: 16px;
  background: var(--white);
  padding: 12px 12px 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--sans);
  box-shadow: 0 2px 8px rgba(0, 62, 116, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.agent-chat-row:hover {
  border-color: rgba(0, 62, 116, 0.22);
  box-shadow: 0 8px 22px rgba(0, 62, 116, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.agent-chat-row:focus {
  outline: none;
  border-color: var(--dark-blue);
  box-shadow: 0 0 0 2px var(--yellow), 0 8px 22px rgba(0, 62, 116, 0.12);
}

.agent-chat-row:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 62, 116, 0.08);
}

.agent-chat-row-avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(145deg, var(--yellow) 0%, #f5d850 100%);
  color: var(--dark-blue);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 2px 6px rgba(0, 62, 116, 0.15);
}

.agent-chat-row-avatar--home {
  font-size: 22px;
  background: linear-gradient(145deg, #e8f0f8 0%, #d4e4f2 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 2px 6px rgba(0, 62, 116, 0.1);
}

.agent-chat-row-avatar--letter {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.agent-chat-row-avatar--glyph {
  font-size: 22px;
  font-weight: 400;
  background: linear-gradient(145deg, #fff8e0 0%, var(--yellow) 100%);
}

.agent-chat-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agent-chat-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.agent-chat-row-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.agent-chat-row-time {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--mid);
  opacity: 0.85;
}

.agent-chat-row-preview {
  font-size: 13px;
  color: var(--mid);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-chat-row-chevron {
  flex-shrink: 0;
  font-size: 22px;
  font-weight: 300;
  color: var(--dark-blue);
  opacity: 0.35;
  line-height: 1;
  margin-left: 2px;
  transition: opacity 0.15s ease, transform 0.18s ease;
}

.agent-chat-row:hover .agent-chat-row-chevron {
  opacity: 0.65;
  transform: translateX(2px);
}

.agent-list-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 22px 32px;
  text-align: center;
  min-height: 220px;
}

.agent-list-empty.hidden {
  display: none !important;
}

.agent-list-empty-visual {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background: linear-gradient(155deg, var(--white) 0%, rgba(255, 219, 0, 0.35) 100%);
  border: 1px solid rgba(0, 62, 116, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 10px 28px rgba(0, 62, 116, 0.1);
}

.agent-list-empty-icon {
  font-size: 34px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 62, 116, 0.15));
}

.agent-list-empty-title {
  margin: 0 0 8px 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  font-style: italic;
  color: var(--dark-blue);
  letter-spacing: -0.02em;
}

.agent-list-empty-hint {
  margin: 0 0 22px 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--mid);
  max-width: 268px;
}

.agent-list-empty-cta {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: linear-gradient(180deg, var(--dark-blue) 0%, #002d56 100%);
  color: var(--yellow);
  box-shadow: 0 4px 16px rgba(0, 62, 116, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: filter 0.15s ease, transform 0.12s ease;
}

.agent-list-empty-cta:hover {
  filter: brightness(1.08);
}

.agent-list-empty-cta:active {
  transform: scale(0.98);
}

@media (prefers-reduced-motion: reduce) {
  .agent-chat-row,
  .agent-chat-row-chevron,
  .agent-list-empty-cta {
    transition: none;
  }

  .agent-chat-row:hover {
    transform: none;
  }

  .agent-chat-row:hover .agent-chat-row-chevron {
    transform: none;
  }
}

.agent-session-btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.agent-session-btn--primary {
  background: var(--dark-blue);
  color: var(--yellow);
}

.agent-session-btn--primary:hover {
  filter: brightness(1.06);
}

.agent-session-btn--ghost {
  background: var(--white);
  color: var(--dark-blue);
  border: 1px solid var(--light-gray);
}

.agent-session-btn--ghost:hover {
  background: var(--off-white);
}

.agent-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--off-white);
}

.agent-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 90%;
}

.agent-msg-user {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.agent-msg-bot .agent-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.agent-msg-user .agent-msg-bubble {
  background: var(--dark-blue);
  color: var(--white);
  border-radius: 12px 12px 4px 12px;
}

.agent-msg-user .agent-msg-image-wrap {
  margin-left: auto;
  margin-top: 8px;
}

.agent-msg-bot .agent-msg-bubble {
  background: var(--white);
  color: var(--dark);
  border: 1px solid var(--light-gray);
  border-radius: 12px 12px 12px 4px;
}

.agent-msg-body {
  flex: 1;
  min-width: 0;
}

.agent-msg-bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}

.agent-msg-image-wrap {
  margin-top: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--light-gray);
  max-width: 100%;
}

.agent-msg-image {
  display: block;
  max-width: 100%;
  max-height: 280px;
  width: auto;
  height: auto;
  object-fit: contain;
  vertical-align: top;
}

.agent-links {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.agent-link-btn {
  display: inline-block;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--dark-blue);
  background: rgba(0, 88, 163, 0.08);
  border: 1px solid rgba(0, 88, 163, 0.25);
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.agent-link-btn:hover {
  background: rgba(0, 88, 163, 0.15);
  border-color: var(--blue);
}

.agent-suggestions {
  padding: 8px 16px;
  background: var(--white);
  border-top: 1px solid var(--light-gray);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

.agent-chip {
  padding: 6px 12px;
  font-size: 12px;
  font-family: var(--sans);
  color: var(--dark-blue);
  background: var(--off-white);
  border: 1px solid var(--light-gray);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.agent-chip:hover {
  background: rgba(255, 219, 0, 0.25);
  border-color: var(--yellow);
}

.agent-msg.agent-msg-typing .agent-msg-bubble::after {
  content: '';
  display: inline-block;
  width: 4px;
  height: 14px;
  background: var(--mid);
  margin-left: 4px;
  animation: agent-blink 0.8s infinite;
}

@keyframes agent-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.3; }
}

.agent-image-preview {
  padding: 8px 16px;
  background: var(--off-white);
  border-top: 1px solid var(--light-gray);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-image-preview.hidden {
  display: none !important;
}

.agent-image-preview img {
  max-height: 60px;
  max-width: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--light-gray);
}

.agent-image-preview-remove {
  padding: 4px 8px;
  font-size: 12px;
  background: var(--light-gray);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.agent-file-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.agent-input-wrap {
  padding: 12px 16px;
  background: var(--white);
  border-top: 1px solid var(--light-gray);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.agent-attach {
  flex-shrink: 0;
}

.agent-input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--light-gray);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 14px;
}

.agent-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(0, 88, 163, 0.2);
}

.agent-send {
  padding: 10px 18px;
  background: var(--dark-blue);
  color: var(--yellow);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.agent-send:hover {
  opacity: 0.9;
}

.agent-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .agent-widget {
    bottom: 16px;
    right: 16px;
  }

  .agent-panel {
    width: calc(100vw - 32px);
    right: -8px;
    bottom: 64px;
    height: 420px;
  }
}
