/* Live chat widget (bottom-right bubble) */

.chat-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 90;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: var(--white);
  box-shadow: 0 10px 30px rgba(36, 112, 196, 0.45);
  display: grid;
  place-items: center;
  transition: transform 0.25s var(--ease), box-shadow 0.25s;
}
.chat-launcher:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 14px 36px rgba(36, 112, 196, 0.55); }
.chat-launcher svg { width: 28px; height: 28px; }
.chat-launcher .icon-close { display: none; }
.chat-launcher.open .icon-chat { display: none; }
.chat-launcher.open .icon-close { display: block; }
.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--white);
}
.chat-badge.show { display: inline-flex; animation: chatpop 0.3s var(--ease); }
@keyframes chatpop { from { transform: scale(0.4); } to { transform: scale(1); } }

.chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 6rem;
  z-index: 90;
  width: 370px;
  max-width: calc(100vw - 2.5rem);
  height: 540px;
  max-height: calc(100vh - 7.5rem);
  background: var(--white);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(6, 24, 46, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.chat-panel.open { opacity: 1; transform: none; pointer-events: auto; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(135deg, var(--blue-900), var(--blue-600));
  color: var(--white);
}
.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: grid;
  place-items: center;
  font-weight: 800;
  flex-shrink: 0;
}
.chat-head strong { display: block; font-size: 1rem; line-height: 1.2; }
.chat-status { font-size: 0.8rem; color: rgba(255,255,255,0.8); display: flex; align-items: center; gap: 0.4rem; }
.chat-status::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}
.chat-status.online::before { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,0.3); }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: var(--blue-50);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-start { margin: auto 0; }
.chat-start h3 { margin-bottom: 0.25rem; }
.chat-start p { color: var(--gray-700); font-size: 0.92rem; margin-bottom: 1rem; }
.chat-start .field { margin-bottom: 0.8rem; }
.chat-start .field label { font-size: 0.85rem; }
.chat-start .field input { padding: 0.7rem 0.85rem; }
.chat-start .btn { width: 100%; }

.chat-msg {
  max-width: 82%;
  padding: 0.6rem 0.85rem;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: rise 0.25s var(--ease);
}
.chat-msg.visitor {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: var(--white);
  border-bottom-right-radius: 4px;
}
.chat-msg.admin {
  align-self: flex-start;
  background: var(--white);
  color: var(--gray-900);
  border: 1px solid var(--gray-200);
  border-bottom-left-radius: 4px;
}
.chat-msg time {
  display: block;
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 0.25rem;
}
.chat-note {
  align-self: center;
  text-align: center;
  font-size: 0.8rem;
  color: var(--gray-500);
  padding: 0.25rem 0.5rem;
}
.chat-offline {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font-size: 0.85rem;
}
.chat-offline form { display: flex; gap: 0.4rem; margin-top: 0.5rem; }
.chat-offline input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.7rem;
  border: 1px solid #fdba74;
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
}
.chat-offline button {
  padding: 0.5rem 0.8rem;
  border: none;
  border-radius: 8px;
  background: #ea580c;
  color: var(--white);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.chat-foot {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}
.chat-foot textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--gray-300);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  font: inherit;
  font-size: 0.92rem;
  max-height: 120px;
  min-height: 42px;
}
.chat-foot textarea:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(36,112,196,0.15); }
.chat-send {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: var(--blue-600);
  color: var(--white);
  cursor: pointer;
  display: grid;
  place-items: center;
  align-self: flex-end;
}
.chat-send:hover { background: var(--blue-700); }
.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.chat-send svg { width: 20px; height: 20px; }
.chat-foot[hidden] { display: none; }

@media (max-width: 480px) {
  .chat-panel {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    bottom: 5.5rem;
    height: calc(100vh - 7rem);
  }
  .chat-launcher { right: 1rem; bottom: 1rem; }
}
