/* =========================================================
   Widget Frida Kapellmann v2.3.0
   Archivo independiente para asistente visual + WhatsApp
   ========================================================= */

:root {
  --fk-widget-blue: #2f6fca;
  --fk-widget-blue-strong: #2056a5;
  --fk-widget-green: #25d366;
  --fk-widget-red: #d84a4a;
  --fk-widget-radius: 24px;
  --fk-widget-shadow: 0 22px 70px rgba(18, 52, 103, 0.22);
}

.floating-bot {
  right: 20px;
  bottom: 20px;
  background: linear-gradient(180deg, #f8fbff, #dceaff);
  border: 1px solid rgba(72, 130, 220, 0.22);
  overflow: hidden;
}

.floating-bot:hover,
.floating-bot:focus {
  transform: translateY(-3px);
}

.floating-bot img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.fk-widget {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 380px;
  max-width: calc(100vw - 28px);
  height: min(640px, calc(100vh - 116px));
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--fk-widget-radius);
  box-shadow: var(--fk-widget-shadow);
  overflow: hidden;
  z-index: 1200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  transition: opacity .22s ease, visibility .22s ease, transform .22s ease;
}

.fk-widget.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.fk-widget-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.98), rgba(250, 253, 255, 0.98));
  border-bottom: 1px solid var(--line);
}

.fk-widget-header-info {
  min-width: 0;
}

.fk-widget-header-info img {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.fk-widget-header-info strong {
  display: block;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
}

.fk-widget-header-info small {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  color: var(--text-soft);
  font-size: .82rem;
}

.fk-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--fk-widget-green);
  box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.12);
  flex: 0 0 auto;
}

.fk-widget-close {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: var(--text-soft);
  transition: background .18s ease, color .18s ease;
}

.fk-widget-close:hover,
.fk-widget-close:focus {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.fk-widget-messages {
  padding: 18px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 10% 0%, rgba(104, 166, 255, 0.10), transparent 30%),
    linear-gradient(180deg, rgba(247, 250, 255, 0.72), rgba(255,255,255,0.72));
}

.fk-message-row {
  display: flex;
  margin-bottom: 12px;
}

.fk-message-row.is-user {
  justify-content: flex-end;
}

.fk-message {
  max-width: 86%;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: .93rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.fk-message.is-bot {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top-left-radius: 8px;
  color: var(--text);
  box-shadow: 0 10px 26px rgba(30, 80, 150, 0.08);
}

.fk-message.is-user {
  background: var(--primary-strong);
  color: #fff;
  border-top-right-radius: 8px;
}

.fk-message.is-alert {
  border-color: rgba(216, 74, 74, 0.24);
  background: rgba(216, 74, 74, 0.08);
}

.fk-whatsapp-card {
  margin-top: 10px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(37, 211, 102, 0.10);
  border: 1px solid rgba(37, 211, 102, 0.24);
}

.fk-case-id {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.76);
  color: var(--primary-strong);
  font-weight: 800;
  font-size: .82rem;
}

.fk-whatsapp-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--fk-widget-green);
  color: #fff !important;
  text-decoration: none;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(37, 211, 102, 0.22);
}

.fk-whatsapp-link:hover,
.fk-whatsapp-link:focus {
  filter: brightness(.96);
}

.fk-widget-form {
  display: grid;
  grid-template-columns: 1fr 46px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.fk-widget-form textarea {
  width: 100%;
  min-height: 46px;
  max-height: 110px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  line-height: 1.45;
}

.fk-widget-form textarea:focus {
  border-color: rgba(60, 121, 216, 0.48);
  box-shadow: 0 0 0 4px rgba(60, 121, 216, 0.10);
}

.fk-widget-form button {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 16px;
  background: var(--primary-strong);
  color: #fff;
  display: grid;
  place-items: center;
  transition: transform .18s ease, filter .18s ease;
}

.fk-widget-form button:hover,
.fk-widget-form button:focus {
  transform: translateY(-1px);
  filter: brightness(.96);
}

.fk-widget-form button:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.fk-widget-footer {
  padding: 0 16px 14px;
  background: var(--surface);
}

.fk-widget-footer small {
  display: block;
  color: var(--text-soft);
  font-size: .76rem;
  line-height: 1.45;
}

html[data-theme="dark"] .floating-bot {
  background: linear-gradient(180deg, #142d52, #081d38);
  border-color: rgba(128, 183, 255, 0.18);
}

html[data-theme="dark"] .fk-widget {
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
}

html[data-theme="dark"] .fk-widget-header {
  background: linear-gradient(135deg, rgba(12, 32, 60, 0.98), rgba(7, 23, 44, 0.98));
}

html[data-theme="dark"] .fk-widget-messages {
  background:
    radial-gradient(circle at 10% 0%, rgba(67, 138, 242, 0.14), transparent 32%),
    linear-gradient(180deg, rgba(7, 22, 42, 0.92), rgba(4, 17, 34, 0.96));
}

html[data-theme="dark"] .fk-case-id {
  background: rgba(11, 29, 54, 0.88);
}

html[data-theme="dark"] .fk-whatsapp-card {
  background: rgba(37, 211, 102, 0.08);
}

@media (max-width: 767px) {
  .fk-widget {
    right: 10px;
    bottom: 82px;
    width: calc(100vw - 20px);
    height: min(620px, calc(100vh - 106px));
    border-radius: 22px;
  }

  .fk-widget-messages {
    padding: 14px;
  }

  .fk-message {
    max-width: 90%;
  }


  .fk-widget-form {
    padding: 12px;
  }
}
