/* LauritaChat widget — visitor front-end
   Accent is injected as --lauritachat-accent (configurable). Everything else is
   neutral so the widget adapts to any site. */

.lauritachat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99998;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 18px;
  border: none;
  border-radius: 999px;
  background: var(--lauritachat-accent, #d6006e);
  color: #fff;
  font: 600 14px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
  transition: transform .15s ease, box-shadow .15s ease;
}
.lauritachat-launcher:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.28); }
.lauritachat-launcher:focus-visible { outline: 3px solid rgba(255,255,255,.6); outline-offset: 2px; }
.lauritachat-launcher svg { flex: none; }

.lauritachat-panel {
  --pc-bg: #ffffff;
  --pc-fg: #1a1a1f;
  --pc-muted: #6b7280;
  --pc-line: #e6e7eb;
  --pc-visitor: var(--lauritachat-accent, #d6006e);
  --pc-staff: #f1f2f5;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--pc-fg);
  box-sizing: border-box;
}
.lauritachat-panel *, .lauritachat-panel *::before, .lauritachat-panel *::after { box-sizing: border-box; }

/* Floating panel */
.lauritachat-panel-floating {
  position: fixed;
  right: 22px;
  bottom: 88px;
  z-index: 99999;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: var(--pc-bg);
  border: 1px solid var(--pc-line);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.lauritachat-panel-floating.lauritachat-open { display: flex; }

/* Inline (shortcode) panel */
.lauritachat-panel-inline {
  width: 100%;
  max-width: 480px;
  height: 560px;
  margin: 16px 0;
  background: var(--pc-bg);
  border: 1px solid var(--pc-line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lauritachat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--lauritachat-accent, #d6006e);
  color: #fff;
  flex: none;
}
.lauritachat-title { font-weight: 600; font-size: 15px; }
.lauritachat-close {
  background: none; border: none; color: #fff; font-size: 24px; line-height: 1;
  cursor: pointer; padding: 0 4px; opacity: .85;
}
.lauritachat-close:hover { opacity: 1; }

.lauritachat-screen { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.lauritachat-panel .lauritachat-screen-off { display: none !important; }

/* Start screen */
.lauritachat-start { padding: 22px 18px; gap: 12px; justify-content: center; }
.lauritachat-start-prompt { margin: 0 0 4px; color: var(--pc-muted); font-size: 14px; }

.lauritachat-input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--pc-line);
  border-radius: 10px;
  font-size: 14px;
  color: var(--pc-fg);
  background: #fff;
}
.lauritachat-input:focus { outline: none; border-color: var(--lauritachat-accent, #d6006e); }

.lauritachat-btn {
  width: 100%;
  padding: 11px 14px;
  border: none;
  border-radius: 10px;
  background: var(--lauritachat-accent, #d6006e);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.lauritachat-btn:hover { filter: brightness(1.05); }
.lauritachat-btn:disabled { opacity: .6; cursor: default; }

/* Messages */
.lauritachat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fafafb;
}
.lauritachat-msg { display: flex; }
.lauritachat-msg-visitor { justify-content: flex-end; }
.lauritachat-msg-staff, .lauritachat-msg-system { justify-content: flex-start; }
.lauritachat-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  word-wrap: break-word;
}
.lauritachat-msg-visitor .lauritachat-bubble {
  background: var(--pc-visitor);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.lauritachat-msg-staff .lauritachat-bubble {
  background: var(--pc-staff);
  color: var(--pc-fg);
  border-bottom-left-radius: 4px;
}
.lauritachat-msg-system .lauritachat-bubble {
  background: transparent;
  color: var(--pc-muted);
  font-size: 12.5px;
  font-style: italic;
  max-width: 100%;
  text-align: center;
  margin: 0 auto;
  padding: 4px 8px;
}

/* Identify / save */
.lauritachat-panel [hidden] { display: none !important; }
.lauritachat-identify { border-top: 1px solid var(--pc-line); padding: 8px 14px; background: #fff; flex: none; }
.lauritachat-save-toggle {
  background: none; border: none; color: var(--lauritachat-accent, #d6006e);
  font-size: 13px; font-weight: 600; cursor: pointer; padding: 2px 0;
  display: inline-flex; align-items: center; gap: 5px;
}
.lauritachat-save-toggle::before { content: "✚"; font-size: 12px; }
.lauritachat-save-form { display: flex; flex-direction: column; gap: 7px; margin-top: 9px; }
.lauritachat-save-hint { margin: 0; font-size: 12.5px; color: var(--pc-muted); }

/* Composer */
.lauritachat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--pc-line);
  background: #fff;
  flex: none;
}
.lauritachat-textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--pc-line);
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
}
.lauritachat-textarea:focus { outline: none; border-color: var(--lauritachat-accent, #d6006e); }
.lauritachat-send {
  flex: none;
  width: 42px; height: 42px;
  border: none; border-radius: 50%;
  background: var(--lauritachat-accent, #d6006e);
  color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.lauritachat-send:hover { filter: brightness(1.05); }

/* Mobile */
@media (max-width: 480px) {
  .lauritachat-panel-floating {
    right: 0; bottom: 0;
    width: 100vw; max-width: 100vw;
    height: 100vh; max-height: 100vh;
    border-radius: 0;
  }
  .lauritachat-launcher-text { display: none; }
  .lauritachat-launcher { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .lauritachat-launcher { transition: none; }
}

/* Closed-conversation notice */
.lauritachat-closed-note {
  margin: 12px auto 4px;
  padding: 14px;
  text-align: center;
  background: #fff;
  border: 1px dashed var(--pc-line);
  border-radius: 12px;
}
.lauritachat-closed-text { margin: 0 0 10px; color: var(--pc-muted); font-size: 13.5px; }
.lauritachat-closed-note .lauritachat-btn { width: auto; padding: 9px 18px; }

/* Support avatar beside staff messages */
.lauritachat-msg-staff { align-items: flex-end; gap: 6px; }
.lauritachat-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  align-self: flex-end;
  margin-bottom: 2px;
}

/* Emoji picker */
.lauritachat-emoji-btn {
  flex: none;
  width: 38px; height: 38px;
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  border-radius: 50%;
  line-height: 1;
}
.lauritachat-emoji-btn:hover { background: rgba(0,0,0,.05); }
.lauritachat-emoji-panel {
  position: absolute;
  bottom: 64px;
  left: 12px;
  right: 12px;
  background: #fff;
  border: 1px solid var(--pc-line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 5;
}
.lauritachat-emoji-item {
  border: none;
  background: transparent;
  font-size: 20px;
  padding: 4px;
  cursor: pointer;
  border-radius: 6px;
  line-height: 1;
}
.lauritachat-emoji-item:hover { background: rgba(0,0,0,.06); }

/* Composer needs relative positioning for the emoji panel */
.lauritachat-composer { position: relative; }

/* ── Adjuntos ────────────────────────────────────────────────────────────── */
.lauritachat-atts {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}
.lauritachat-atts:first-child { margin-top: 0; }

.lauritachat-att-img {
    display: block;
    line-height: 0;
    border-radius: 8px;
    overflow: hidden;
}
.lauritachat-att-img img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

.lauritachat-att-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(0, 0, 0, .12);
    border-radius: 8px;
    background: rgba(255, 255, 255, .6);
    text-decoration: none;
    color: inherit;
    font-size: 13px;
}
.lauritachat-att-file:hover { background: rgba(0, 0, 0, .04); }
.lauritachat-att-icon {
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    padding: 3px 5px;
    border-radius: 4px;
    background: #dc2626;
    color: #fff;
}
.lauritachat-att-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lauritachat-att-size { flex: 0 0 auto; opacity: .6; font-size: 11px; }

/* ── Borrar de este dispositivo ──────────────────────────────────────────── */
.lauritachat-wipe {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 12px 0;
    font-size: 11px;
    line-height: 1.4;
}
.lauritachat-wipe-btn {
    border: 0;
    background: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    color: #b91c1c;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.lauritachat-wipe-btn:hover { color: #7f1d1d; }
.lauritachat-wipe-note { opacity: .65; }

.lauritachat-wiped {
    padding: 24px 16px;
    text-align: center;
}
.lauritachat-wiped-title {
    margin: 0 0 6px;
    font-weight: 600;
}
.lauritachat-wiped-note {
    margin: 0;
    font-size: 13px;
    opacity: .7;
}

/* El aviso de cierre ocupa el sitio del composer: separador arriba para que
   se lea como parte del pie del widget y no como un mensaje mas del hilo. */
.lauritachat-closed-note {
    border-top: 1px solid rgba(0, 0, 0, .08);
    background: rgba(0, 0, 0, .015);
}

/* ── Blindaje del boton de enviar ────────────────────────────────────────────
   Algunos temas aplican estilos globales a `button` (padding, color, ancho
   minimo) que deforman el boton o dejan la flecha del mismo color que el
   fondo, porque el SVG usa currentColor. Se fija todo de forma explicita. */
.lauritachat-panel .lauritachat-send {
    padding: 0 !important;
    margin: 0 !important;
    min-width: 42px !important;
    max-width: 42px !important;
    width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
    text-transform: none !important;
    line-height: 1 !important;
    color: #fff !important;
    flex: 0 0 42px !important;
}
.lauritachat-panel .lauritachat-send svg {
    width: 20px !important;
    height: 20px !important;
    display: block !important;
    pointer-events: none;
}
.lauritachat-panel .lauritachat-send svg path {
    fill: #fff !important;
}
.lauritachat-panel .lauritachat-send[disabled] { opacity: .5; cursor: default; }

/* El pie de borrado, ya bajo el composer, se lee como nota al margen. */
.lauritachat-panel .lauritachat-wipe {
    padding: 8px 12px 10px;
    border-top: 1px solid rgba(0, 0, 0, .06);
}

/* Mismo blindaje que el boton de enviar: los temas suelen aplicar padding y
   min-width a todos los `button`, y eso deforma el circulo del emoji. */
.lauritachat-panel .lauritachat-emoji-btn {
    padding: 0 !important;
    margin: 0 !important;
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    line-height: 1 !important;
    font-size: 20px !important;
    text-transform: none !important;
    flex: 0 0 38px !important;
}
.lauritachat-panel .lauritachat-emoji-btn:hover {
    background: rgba(0, 0, 0, .05) !important;
}

/* ── Burbuja del staff ───────────────────────────────────────────────────────
   Se redefinen las variables dentro de la propia burbuja, no en :root, para
   no arrastrar el cambio al color de texto del panel ni a los campos. */
.lauritachat-msg-staff .lauritachat-bubble {
    --pc-staff: #aff;
    --pc-fg: #000;
    background: var(--pc-staff);
    color: var(--pc-fg);
}

/* ── Aviso de conversacion cerrada ───────────────────────────────────────── */
.lauritachat-closed-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 16px;
    color: var(--lauritachat-accent, #d6006e);
    font-weight: 600;
}
.lauritachat-closed-text::before {
    content: "";
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    /* Aspa en circulo, como mascara: hereda el color del texto. */
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm3.54 13.54a1 1 0 0 1-1.42 0L12 13.41l-2.12 2.13a1 1 0 1 1-1.42-1.42L10.59 12 8.46 9.88a1 1 0 0 1 1.42-1.42L12 10.59l2.12-2.13a1 1 0 1 1 1.42 1.42L13.41 12l2.13 2.12a1 1 0 0 1 0 1.42z'/></svg>") no-repeat center / contain;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm3.54 13.54a1 1 0 0 1-1.42 0L12 13.41l-2.12 2.13a1 1 0 1 1-1.42-1.42L10.59 12 8.46 9.88a1 1 0 0 1 1.42-1.42L12 10.59l2.12-2.13a1 1 0 1 1 1.42 1.42L13.41 12l2.13 2.12a1 1 0 0 1 0 1.42z'/></svg>") no-repeat center / contain;
}

/* Con la conversacion cerrada no hay nada que guardar. */
.lauritachat-panel.lauritachat-is-closed .lauritachat-save-toggle,
.lauritachat-panel.lauritachat-is-closed #lauritachat-identify {
    display: none !important;
}

/* El saludo puede ocupar varias lineas. */
.lauritachat-start-prompt { white-space: pre-line; }

.lauritachat-start-prompt { white-space: pre-line; line-height: .8; }
.lauritachat-setnick { padding: 8px 14px; }
