/* =================================================================
   Lopez SW Construction — Floating AI Chatbot
   Branded widget, vanilla CSS, no external dependencies
   ================================================================= */

:root {
  --lsw-dark: #13243A;
  --lsw-azul: #114473;
  --lsw-celeste: #00B5FE;
  --lsw-light: #E6F4F1;
  --lsw-white: #FFFFFF;
  --lsw-text: #272F3C;
  --lsw-muted: #6B7486;
  --lsw-border: #E1E8EF;
  --lsw-user-bg: linear-gradient(135deg, #00B5FE 0%, #0089D6 100%);
  --lsw-bot-bg: #F3F6FA;
  --lsw-gradient: linear-gradient(135deg, #114473 0%, #13243A 100%);
  --lsw-gradient-btn: linear-gradient(135deg, #00B5FE 0%, #114473 100%);
  --lsw-shadow-lg: 0 20px 60px rgba(19, 36, 58, 0.28), 0 4px 14px rgba(19, 36, 58, 0.14);
  --lsw-shadow-md: 0 8px 24px rgba(0, 181, 254, 0.35);
  --lsw-radius-lg: 20px;
  --lsw-radius-md: 14px;
  --lsw-radius-sm: 10px;
  --lsw-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --lsw-z: 2147483000;
}

/* ---------- Root host ---------- */
.lsw-chat-host,
.lsw-chat-host * {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

.lsw-chat-host {
  position: fixed;
  inset: auto auto 0 0;
  z-index: var(--lsw-z);
  font-family: var(--lsw-font);
  color: var(--lsw-text);
  pointer-events: none;
}

.lsw-chat-host > * {
  pointer-events: auto;
}

/* ---------- Floating Launcher Button ---------- */
.lsw-launcher {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--lsw-gradient-btn);
  border: none;
  cursor: pointer;
  box-shadow: var(--lsw-shadow-md), 0 0 0 0 rgba(0, 181, 254, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(.2,.9,.3,1.2), box-shadow 0.25s ease;
  animation: lsw-pulse 2.6s ease-in-out infinite;
  z-index: var(--lsw-z);
}

.lsw-launcher:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 14px 30px rgba(0, 181, 254, 0.5);
}

.lsw-launcher:active {
  transform: scale(0.96);
}

.lsw-launcher svg {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.2));
}

.lsw-launcher.lsw-hidden {
  opacity: 0;
  transform: scale(0.7) translateY(10px);
  pointer-events: none;
}

@keyframes lsw-pulse {
  0%, 100% { box-shadow: var(--lsw-shadow-md), 0 0 0 0 rgba(0, 181, 254, 0.45); }
  50% { box-shadow: var(--lsw-shadow-md), 0 0 0 14px rgba(0, 181, 254, 0); }
}

/* ---------- Notification badge ---------- */
.lsw-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ff3b52;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  opacity: 0;
  transform: scale(0);
  transition: all 0.25s cubic-bezier(.2,.9,.3,1.4);
}

.lsw-badge.lsw-show {
  opacity: 1;
  transform: scale(1);
}

/* ---------- Chat Container ---------- */
.lsw-chat {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 48px);
  background: #fff;
  border-radius: var(--lsw-radius-lg);
  box-shadow: var(--lsw-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom left;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(.2,.9,.3,1.2), opacity 0.22s ease;
  z-index: var(--lsw-z);
}

.lsw-chat.lsw-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Header ---------- */
.lsw-header {
  background: var(--lsw-gradient);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.lsw-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 110% -20%, rgba(0,181,254,0.35) 0%, transparent 50%);
  pointer-events: none;
}

.lsw-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.lsw-avatar svg {
  width: 28px;
  height: 28px;
}

.lsw-header-info {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.lsw-header-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.1px;
}

.lsw-header-sub {
  font-size: 12px;
  opacity: 0.88;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.lsw-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2FD97E;
  box-shadow: 0 0 0 0 rgba(47, 217, 126, 0.55);
  animation: lsw-ping 2s infinite;
}

@keyframes lsw-ping {
  0% { box-shadow: 0 0 0 0 rgba(47, 217, 126, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(47, 217, 126, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 217, 126, 0); }
}

.lsw-header-actions {
  display: flex;
  gap: 6px;
  position: relative;
  z-index: 1;
}

.lsw-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.lsw-icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.lsw-icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ---------- Messages ---------- */
.lsw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  background: linear-gradient(180deg, #FAFBFD 0%, #F3F6FA 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.lsw-messages::-webkit-scrollbar {
  width: 6px;
}
.lsw-messages::-webkit-scrollbar-thumb {
  background: #D3DAE4;
  border-radius: 3px;
}
.lsw-messages::-webkit-scrollbar-track {
  background: transparent;
}

.lsw-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: lsw-fade-up 0.28s ease both;
  position: relative;
}

.lsw-msg a {
  color: inherit;
  text-decoration: underline;
}

.lsw-msg strong { font-weight: 700; }
.lsw-msg em { font-style: italic; }

.lsw-msg ul, .lsw-msg ol {
  margin: 6px 0 2px;
  padding-left: 18px;
}

.lsw-msg.lsw-bot {
  align-self: flex-start;
  background: #fff;
  color: var(--lsw-text);
  border: 1px solid var(--lsw-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(19, 36, 58, 0.04);
}

.lsw-msg.lsw-user {
  align-self: flex-end;
  background: var(--lsw-user-bg);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 137, 214, 0.22);
}

@keyframes lsw-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Typing indicator ---------- */
.lsw-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--lsw-border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: inline-flex;
  gap: 4px;
  animation: lsw-fade-up 0.2s ease both;
}

.lsw-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lsw-celeste);
  opacity: 0.5;
  animation: lsw-bounce 1.2s infinite ease-in-out;
}

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

@keyframes lsw-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Quick buttons ---------- */
.lsw-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 14px 10px;
  background: linear-gradient(180deg, transparent, #F3F6FA);
}

.lsw-quick-btn {
  border: 1px solid var(--lsw-celeste);
  background: #fff;
  color: var(--lsw-azul);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.lsw-quick-btn:hover {
  background: var(--lsw-celeste);
  color: #fff;
  transform: translateY(-1px);
}

/* ---------- Input ---------- */
.lsw-input-wrap {
  padding: 10px 12px 12px;
  background: #fff;
  border-top: 1px solid var(--lsw-border);
  flex-shrink: 0;
}

.lsw-input-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #F3F6FA;
  border: 1px solid var(--lsw-border);
  border-radius: 14px;
  padding: 6px 6px 6px 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.lsw-input-inner:focus-within {
  border-color: var(--lsw-celeste);
  background: #fff;
}

.lsw-textarea {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--lsw-text);
  resize: none;
  min-height: 22px;
  max-height: 110px;
  padding: 7px 0;
  line-height: 1.4;
}

.lsw-textarea::placeholder {
  color: var(--lsw-muted);
}

.lsw-send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--lsw-gradient-btn);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.lsw-send:hover { transform: scale(1.05); }
.lsw-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.lsw-send svg { width: 16px; height: 16px; }

.lsw-footer-note {
  text-align: center;
  font-size: 10.5px;
  color: var(--lsw-muted);
  margin-top: 6px;
  letter-spacing: 0.1px;
}
.lsw-footer-note a { color: var(--lsw-azul); text-decoration: none; font-weight: 600; }

/* ---------- Mobile responsive ---------- */
@media (max-width: 520px) {
  .lsw-chat {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .lsw-launcher {
    right: 16px;
    bottom: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lsw-launcher { animation: none; }
  .lsw-dot { animation: none; }
  .lsw-msg { animation: none; }
  .lsw-typing span { animation: none; }
}
