/* MKFE website assistant widget.
   Load before /assets/chat-widget.js. Palette matches styles.css tokens. */

.mkfe-chat-root {
  --mc-navy: #0e2a47;
  --mc-navy-deep: #0a2038;
  --mc-bronze: #b0894f;
  --mc-bronze-bright: #cfa963;
  --mc-ink: #1a1f26;
  --mc-slate: #556070;
  --mc-line: #e2ddd4;
  --mc-paper: #f7f5f1;
  position: fixed;
  z-index: 9999;
  right: 20px;
  bottom: 20px;
  font-family: "Source Sans 3", "Segoe UI", Arial, sans-serif;
}

/* ===== Launcher button ===== */
.mkfe-chat-launcher { position: relative; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }

.mkfe-chat-button {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--mc-navy); color: #fff;
  border: 1px solid var(--mc-navy-deep);
  box-shadow: 0 4px 14px rgba(14,42,71,.25);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, background .15s ease;
}
.mkfe-chat-button:hover { transform: scale(1.06); background: var(--mc-navy-deep); }
.mkfe-chat-button svg { width: 26px; height: 26px; }
.mkfe-chat-button.is-pulsing { animation: mkfe-chat-pulse 2s ease-out 2; }
@keyframes mkfe-chat-pulse {
  0% { box-shadow: 0 0 0 0 rgba(176,137,79,.5); }
  70% { box-shadow: 0 0 0 16px rgba(176,137,79,0); }
  100% { box-shadow: 0 0 0 0 rgba(176,137,79,0); }
}

/* ===== Teaser card ===== */
.mkfe-chat-teaser {
  display: none; width: 300px; background: #fff;
  border: 1px solid var(--mc-line); border-radius: 12px;
  box-shadow: 0 14px 40px rgba(14,42,71,.18);
  padding: 14px 16px; position: relative;
}
.mkfe-chat-teaser.is-visible { display: block; animation: mkfe-chat-fadein .3s ease; }
@keyframes mkfe-chat-fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.mkfe-chat-teaser__close {
  position: absolute; top: 6px; right: 10px; border: 0; background: none;
  font-size: 18px; color: var(--mc-slate); cursor: pointer; line-height: 1;
}
.mkfe-chat-teaser__head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mkfe-chat-teaser__avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--mc-navy);
  color: var(--mc-bronze-bright); font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center; letter-spacing: .5px;
}
.mkfe-chat-teaser__name { display: block; font-weight: 700; color: var(--mc-ink); font-size: 14px; }
.mkfe-chat-teaser__label { display: block; font-size: 11px; color: var(--mc-slate); }
.mkfe-chat-teaser__msg { margin: 0 0 10px; font-size: 13.5px; color: var(--mc-ink); line-height: 1.45; }
.mkfe-chat-teaser__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mkfe-chat-teaser__chip {
  border: 1px solid var(--mc-line); background: var(--mc-paper); color: var(--mc-navy);
  border-radius: 999px; padding: 5px 11px; font-size: 12.5px; cursor: pointer;
}
.mkfe-chat-teaser__chip:hover { border-color: var(--mc-bronze); }

/* ===== Modal ===== */
.mkfe-chat-modal {
  display: none; position: fixed; right: 20px; bottom: 90px;
  width: 380px; max-width: calc(100vw - 32px); height: 560px; max-height: calc(100vh - 120px);
  background: #fff; border: 1px solid var(--mc-line); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(14,42,71,.28);
  flex-direction: column; overflow: hidden;
}
.mkfe-chat-root.is-open .mkfe-chat-modal { display: flex; }

.mkfe-chat-header {
  background: var(--mc-navy); color: #fff; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.mkfe-chat-header__left { display: flex; align-items: center; gap: 10px; }
.mkfe-chat-header__avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--mc-navy-deep);
  color: var(--mc-bronze-bright); font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.mkfe-chat-header__dot {
  position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px;
  border-radius: 50%; background: #2ecc71; border: 2px solid var(--mc-navy);
}
.mkfe-chat-header__title { font-weight: 700; font-size: 14.5px; }
.mkfe-chat-header__subtitle { font-size: 11.5px; color: #c9d4e2; }
.mkfe-chat-header__badge {
  display: inline-block; background: var(--mc-bronze); color: #fff; border-radius: 4px;
  font-size: 9.5px; font-weight: 700; padding: 1px 4px; margin-right: 4px; letter-spacing: .5px;
}
.mkfe-chat-header__close { border: 0; background: none; color: #c9d4e2; cursor: pointer; }
.mkfe-chat-header__close:hover { color: #fff; }
.mkfe-chat-header__close svg { width: 20px; height: 20px; }

.mkfe-chat-quickbar {
  padding: 8px 14px; background: var(--mc-paper); border-bottom: 1px solid var(--mc-line);
  font-size: 12.5px; color: var(--mc-slate);
}
.mkfe-chat-quickbar a { color: var(--mc-navy); font-weight: 600; text-decoration: underline; }

.mkfe-chat-thread { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }

.mkfe-chat-msg {
  max-width: 85%; padding: 9px 12px; border-radius: 12px;
  font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
}
.mkfe-chat-msg--bot { background: var(--mc-paper); border: 1px solid var(--mc-line); color: var(--mc-ink); align-self: flex-start; border-bottom-left-radius: 4px; }
.mkfe-chat-msg--user { background: var(--mc-navy); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.mkfe-chat-msg a { color: var(--mc-bronze-dark, #8f6d38); word-break: break-all; }
.mkfe-chat-msg--user a { color: var(--mc-bronze-bright); }

.mkfe-chat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mkfe-chat-chip {
  border: 1px solid var(--mc-line); background: #fff; color: var(--mc-navy);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; cursor: pointer;
}
.mkfe-chat-chip:hover { border-color: var(--mc-bronze); background: var(--mc-paper); }

.mkfe-chat-typing { display: inline-flex; gap: 4px; padding: 2px 0; }
.mkfe-chat-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--mc-slate);
  animation: mkfe-chat-bounce 1.2s infinite;
}
.mkfe-chat-typing span:nth-child(2) { animation-delay: .15s; }
.mkfe-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes mkfe-chat-bounce { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.mkfe-chat-input-area { border-top: 1px solid var(--mc-line); padding: 10px 12px 8px; background: #fff; }
.mkfe-chat-input-wrap { display: flex; align-items: flex-end; gap: 8px; }
.mkfe-chat-textarea {
  flex: 1; resize: none; border: 1px solid var(--mc-line); border-radius: 10px;
  padding: 9px 11px; font: inherit; font-size: 13.5px; color: var(--mc-ink);
  max-height: 120px; outline: none;
}
.mkfe-chat-textarea:focus { border-color: var(--mc-bronze); }
.mkfe-chat-send {
  width: 38px; height: 38px; border-radius: 10px; border: 0;
  background: var(--mc-navy); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.mkfe-chat-send:disabled { opacity: .5; cursor: default; }
.mkfe-chat-send svg { width: 17px; height: 17px; }
.mkfe-chat-footer {
  margin-top: 6px; font-size: 10.5px; color: var(--mc-slate); line-height: 1.4; text-align: center;
}

/* ===== Mobile: full screen ===== */
@media (max-width: 640px) {
  .mkfe-chat-modal {
    right: 0; bottom: 0; left: 0; top: 0;
    width: 100%; height: 100%; max-width: none; max-height: none; border-radius: 0;
  }
  .mkfe-chat-teaser { width: min(300px, calc(100vw - 90px)); }
}

@media print { .mkfe-chat-root { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .mkfe-chat-button.is-pulsing, .mkfe-chat-teaser.is-visible, .mkfe-chat-typing span { animation: none; }
}
