/* ════════════════════════════════════════════════════════════════════
   TALMA Chat — floating glossy mini-app, bottom-left, dark gold palette
   Self-contained widget. Replaces the broken yasserelsaid plugin.
   ════════════════════════════════════════════════════════════════════ */

.talma-chat-root {
  --tc-gold: #d2ae5f;
  --tc-gold-light: #f1d58c;
  --tc-gold-dark: #a3822f;
  --tc-bg: #0a0805;
  --tc-bg-2: #14110a;
  --tc-text: #f4ecd8;
  --tc-text-dim: #b9ad8d;
  --tc-border: rgba(210, 174, 95, 0.22);
  --tc-border-strong: rgba(210, 174, 95, 0.45);
  /* !important defeats any Nicepage/WP rule that sets position on its
     descendants and ensures the launcher stays glued to the viewport. */
  position: fixed !important;
  left: max(18px, env(safe-area-inset-left)) !important;
  bottom: max(18px, env(safe-area-inset-bottom)) !important;
  top: auto !important;
  right: auto !important;
  z-index: 2147483600 !important;
  margin: 0 !important;
  padding: 0 !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  transform: none !important;
  font-family: Inter, Manrope, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--tc-text);
  -webkit-font-smoothing: antialiased;
  pointer-events: auto;
}

.talma-chat-root * {
  box-sizing: border-box;
}

/* ─── Floating launcher button ──────────────────────────────── */
.talma-chat-launcher {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px 14px 16px;
  border-radius: 999px;
  background:
    radial-gradient(120% 160% at 0% 0%, rgba(255, 245, 212, 0.30), transparent 60%),
    linear-gradient(140deg, var(--tc-gold-light) 0%, var(--tc-gold) 60%, var(--tc-gold-dark) 100%);
  color: #1b1607;
  font-weight: 700;
  font-size: 0.96rem;
  letter-spacing: -0.01em;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(0, 0, 0, 0.30),
    0 22px 50px -18px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(0, 0, 0, 0.25),
    0 0 36px -6px rgba(210, 174, 95, 0.65);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.talma-chat-launcher:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.05);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -1px 0 rgba(0, 0, 0, 0.30),
    0 28px 64px -18px rgba(0, 0, 0, 0.92),
    0 0 0 1px rgba(0, 0, 0, 0.3),
    0 0 50px -4px rgba(241, 213, 140, 0.85);
}

.talma-chat-launcher:active {
  transform: translateY(0) scale(0.99);
}

.talma-chat-launcher__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1b1607;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 2px 6px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}

.talma-chat-launcher__avatar img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(241, 213, 140, 0.7));
}

.talma-chat-launcher__label {
  white-space: nowrap;
}

.talma-chat-launcher__pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #21d07a;
  box-shadow: 0 0 0 0 rgba(33, 208, 122, 0.55);
  animation: talma-chat-pulse 2.2s ease-out infinite;
}

@keyframes talma-chat-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(33, 208, 122, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(33, 208, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(33, 208, 122, 0); }
}

.talma-chat-root[data-open="true"] .talma-chat-launcher {
  transform: scale(0.92) translateY(2px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: transform 0.18s ease, opacity 0.16s ease, visibility 0s linear 0.2s;
}

/* ─── Panel ──────────────────────────────────────────────────── */
.talma-chat-panel {
  position: absolute;
  left: 0;
  bottom: 0;
  width: min(380px, calc(100vw - 36px));
  height: min(580px, calc(100vh - 100px));
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  border-radius: 24px;
  overflow: hidden;
  background:
    radial-gradient(140% 80% at 0% 0%, rgba(241, 213, 140, 0.10), transparent 60%),
    radial-gradient(120% 70% at 100% 100%, rgba(120, 88, 22, 0.18), transparent 60%),
    linear-gradient(160deg, rgba(20, 17, 10, 0.90) 0%, rgba(10, 8, 5, 0.92) 100%);
  border: 1px solid var(--tc-border);
  -webkit-backdrop-filter: blur(36px) saturate(180%);
  backdrop-filter: blur(36px) saturate(180%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    0 36px 80px -20px rgba(0, 0, 0, 0.95),
    0 0 0 1px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transform-origin: 8% calc(100% - 24px);
  pointer-events: none;
  visibility: hidden;
  transition:
    transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.24s ease,
    visibility 0s linear 0.4s;
}

.talma-chat-root[data-open="true"] .talma-chat-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
  transition:
    transform 0.36s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.24s ease,
    visibility 0s linear 0s;
}

/* Header */
.talma-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0)) ,
    linear-gradient(180deg, rgba(20, 17, 10, 0.6), rgba(20, 17, 10, 0));
  border-bottom: 1px solid var(--tc-border);
  position: relative;
}

.talma-chat-header::after {
  content: "";
  position: absolute;
  left: 16px; right: 16px; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(241, 213, 140, 0.45) 50%, transparent);
  pointer-events: none;
}

.talma-chat-header__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background:
    linear-gradient(140deg, var(--tc-gold-light) 0%, var(--tc-gold) 50%, var(--tc-gold-dark) 100%);
  display: grid;
  place-items: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 4px 12px -2px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
}

.talma-chat-header__avatar img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.talma-chat-header__title {
  flex: 1;
  min-width: 0;
}

.talma-chat-header__title strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--tc-text);
  line-height: 1.2;
}

.talma-chat-header__title span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--tc-text-dim);
  margin-top: 2px;
}

.talma-chat-header__title span::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #21d07a;
  box-shadow: 0 0 10px rgba(33, 208, 122, 0.7);
}

.talma-chat-close {
  appearance: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
  color: var(--tc-text-dim);
  font-size: 18px;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.talma-chat-close:hover {
  background: rgba(210, 174, 95, 0.18);
  color: var(--tc-gold-light);
  transform: scale(1.04);
}

.talma-chat-close:active {
  transform: scale(0.96);
}

/* Messages */
.talma-chat-messages {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(210, 174, 95, 0.4) transparent;
}

.talma-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.talma-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(210, 174, 95, 0.35);
  border-radius: 999px;
}

.talma-chat-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 18px;
  font-size: 0.93rem;
  line-height: 1.55;
  word-wrap: break-word;
  animation: talma-chat-msg-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes talma-chat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.talma-chat-msg--bot {
  align-self: flex-start;
  background:
    linear-gradient(150deg, rgba(255, 248, 220, 0.06), rgba(255, 248, 220, 0.02)),
    rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 6px;
  color: var(--tc-text);
}

.talma-chat-msg--user {
  align-self: flex-end;
  background:
    linear-gradient(140deg, var(--tc-gold-light) 0%, var(--tc-gold) 100%);
  color: #1b1607;
  font-weight: 600;
  border-bottom-right-radius: 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 6px 18px -8px rgba(210, 174, 95, 0.6);
}

.talma-chat-msg a {
  color: var(--tc-gold-light);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(241, 213, 140, 0.4);
  transition: border-color 0.15s ease;
}

.talma-chat-msg a:hover {
  border-color: var(--tc-gold-light);
}

.talma-chat-msg--user a {
  color: #1b1607;
  border-bottom-color: rgba(27, 22, 7, 0.45);
}

.talma-chat-msg--user a:hover {
  border-bottom-color: #1b1607;
}

.talma-chat-msg ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.talma-chat-msg ul li {
  margin-bottom: 2px;
}

.talma-chat-msg strong {
  color: var(--tc-gold-light);
  font-weight: 700;
}

.talma-chat-msg--user strong {
  color: #1b1607;
}

.talma-chat-typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.talma-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tc-gold);
  opacity: 0.4;
  animation: talma-chat-typing 1.2s ease-in-out infinite;
}

.talma-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.talma-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes talma-chat-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1; transform: translateY(-3px); }
}

/* Suggestion chips */
.talma-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 14px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 12px;
}

.talma-chat-chip {
  appearance: none;
  cursor: pointer;
  font: 600 0.82rem/1.2 inherit;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--tc-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--tc-text);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
}

.talma-chat-chip:hover {
  background: rgba(210, 174, 95, 0.16);
  border-color: var(--tc-border-strong);
  transform: translateY(-1px);
}

.talma-chat-chip:active {
  transform: translateY(0);
}

/* Input */
.talma-chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.35));
  border-top: 1px solid var(--tc-border);
}

.talma-chat-input {
  flex: 1;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
  color: var(--tc-text);
  border-radius: 14px;
  padding: 10px 14px;
  font: 400 0.95rem/1.4 inherit;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.talma-chat-input::placeholder {
  color: var(--tc-text-dim);
}

.talma-chat-input:focus {
  border-color: var(--tc-border-strong);
  background: rgba(255, 255, 255, 0.07);
}

.talma-chat-send {
  appearance: none;
  border: 0;
  cursor: pointer;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(140deg, var(--tc-gold-light) 0%, var(--tc-gold) 60%, var(--tc-gold-dark) 100%);
  color: #1b1607;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 8px 20px -10px rgba(210, 174, 95, 0.7);
  transition: transform 0.15s ease, filter 0.15s ease;
  flex-shrink: 0;
}

.talma-chat-send:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.talma-chat-send:active {
  transform: scale(0.96);
}

.talma-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ─── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 575px) {
  /* Override the desktop !important left:auto/right:auto so the root
     spans the full screen width on small viewports. Without this the
     panel collapses to the launcher width and gets cropped. */
  .talma-chat-root {
    left: max(12px, env(safe-area-inset-left)) !important;
    right: max(12px, env(safe-area-inset-right)) !important;
    bottom: max(12px, env(safe-area-inset-bottom)) !important;
  }

  .talma-chat-launcher {
    padding: 12px 18px 12px 14px;
    font-size: 0.92rem;
  }

  .talma-chat-launcher__avatar {
    width: 28px;
    height: 28px;
  }

  .talma-chat-launcher__avatar img {
    width: 22px;
    height: 22px;
  }

  /* Panel takes the whole width of the now-fluid root and a comfortable
     viewport height, with a small bottom inset so the input bar stays
     above the home indicator on iOS. */
  .talma-chat-panel {
    width: 100% !important;
    max-width: none !important;
    height: min(78vh, 600px) !important;
    max-height: calc(100vh - 24px) !important;
    border-radius: 22px !important;
  }
}

/* Hide every previous chatbot widget the WordPress site might still inject */
[id^="talmamadrid-es-"],
[class*="yasser-chatbot"],
[id*="yasser"],
.talma-chatbot-toggle,
.talma-chatbot-container,
.talma-chatbot-initial-message {
  display: none !important;
}
