/* Inidel site chat widget — stacks with .to-top (see ICW-001) */

:root {
  --icw-size: 56px;
  --icw-gap: 12px;
  --icw-edge: max(var(--gutter, 20px), 24px);
  --icw-bottom: 24px;
  --icw-z-launcher: 240;
  --icw-z-panel: 260;
}

html.inidel-chat-stack .to-top--live:not(.to-top--demo) {
  bottom: calc(var(--icw-bottom) + var(--icw-size) + var(--icw-gap));
  z-index: 150;
}

@media (max-width: 767px) {
  html.inidel-chat-open .to-top--live:not(.to-top--demo) {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

.inidel-chat-launcher {
  position: fixed;
  right: var(--icw-edge);
  bottom: var(--icw-bottom);
  z-index: var(--icw-z-launcher);
  width: var(--icw-size);
  height: var(--icw-size);
  border: 1px solid var(--fab-border, rgb(255 255 255 / 0.12));
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fab-icon, var(--white, #fff));
  background: var(--fab-fill, rgb(15, 20, 24));
  box-shadow: var(--fab-shadow, 0 4px 20px rgb(0 0 0 / 0.35));
  transition: background-color 200ms ease, transform 200ms ease, box-shadow 200ms ease;
  font-family: var(--font-sans, system-ui, sans-serif);
}

.inidel-chat-launcher:hover,
.inidel-chat-launcher:focus-visible {
  background: var(--fab-fill, rgb(15, 20, 24));
  box-shadow: var(--fab-shadow-hover, 0 0 0 1px rgb(76 125 255 / 0.35), 0 6px 24px rgb(0 0 0 / 0.4));
  transform: translateY(-1px);
}

.inidel-chat-launcher:focus-visible {
  outline: 2px solid var(--focus, var(--slate-300, #b8c5ce));
  outline-offset: 3px;
}

.inidel-chat-launcher__icon {
  width: 26px;
  height: 26px;
  display: block;
}

html.inidel-chat-open .inidel-chat-launcher {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.inidel-chat-busy {
  align-self: stretch;
  padding: 12px;
  border-radius: var(--radius-3, 8px);
  background: rgb(230 126 34 / 0.1);
  border: 1px solid rgb(230 126 34 / 0.35);
  text-align: center;
}

.inidel-chat-busy__text {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--slate-200, #d8e0e5);
}

.inidel-chat-busy__retry {
  border: 1px solid var(--signal-blue, #4c7dff);
  border-radius: var(--radius-2, 4px);
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
  color: var(--white, #fff);
  background: var(--ink-800, #172026);
}

.inidel-chat-busy__retry:hover,
.inidel-chat-busy__retry:focus-visible {
  background: var(--ink-700, #232d33);
  outline: 2px solid var(--focus, var(--slate-300));
  outline-offset: 2px;
}

.inidel-chat-panel {
  position: fixed;
  right: var(--icw-edge);
  bottom: calc(var(--icw-bottom) + var(--icw-size) + var(--icw-gap));
  z-index: var(--icw-z-panel);
  width: min(360px, calc(100vw - 2 * var(--icw-edge)));
  max-height: 70vh;
  display: none;
  flex-direction: column;
  border-radius: var(--radius-3, 8px);
  border: 1px solid var(--ink-700, #232d33);
  background: var(--ink-900, #0f1418);
  color: var(--slate-200, #d8e0e5);
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.45);
  font-family: var(--font-sans, system-ui, sans-serif);
  font-size: 0.9375rem;
  line-height: 1.45;
  overflow: hidden;
}

.inidel-chat-panel.is-open {
  display: flex;
}

@media (max-width: 767px) {
  .inidel-chat-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 75vh;
    border-radius: var(--radius-3, 8px) var(--radius-3, 8px) 0 0;
  }
}

.inidel-chat-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--ink-700, #232d33);
  background: var(--ink-800, #172026);
}

.inidel-chat-panel__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--white, #fff);
}

.inidel-chat-panel__close {
  border: none;
  background: transparent;
  color: var(--slate-400, #9aa8b2);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-2, 4px);
}

.inidel-chat-panel__close:hover,
.inidel-chat-panel__close:focus-visible {
  color: var(--white, #fff);
  background: rgb(255 255 255 / 0.06);
}

.inidel-chat-panel__close:focus-visible {
  outline: 2px solid var(--focus, var(--slate-300));
  outline-offset: 2px;
}

.inidel-chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
}

.inidel-chat-msg {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: var(--radius-3, 8px);
  white-space: pre-wrap;
  word-break: break-word;
}

.inidel-chat-msg--assistant {
  align-self: flex-start;
  background: rgb(76 125 255 / 0.12);
  border: 1px solid rgb(76 125 255 / 0.25);
  color: var(--slate-100, #eef2f4);
}

.inidel-chat-msg--visitor {
  align-self: flex-end;
  background: var(--ink-700, #232d33);
  border: 1px solid rgb(255 255 255 / 0.08);
  color: var(--slate-200, #d8e0e5);
}

.inidel-chat-msg--system a {
  color: var(--signal-blue, #4c7dff);
  text-decoration: underline;
}

.inidel-chat-msg--system {
  align-self: center;
  font-size: 0.85rem;
  color: var(--slate-400, #9aa8b2);
  background: transparent;
  border: none;
  padding: 4px 0;
  text-align: center;
}

.inidel-chat-typing {
  align-self: flex-start;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--slate-400, #9aa8b2);
}

.inidel-chat-panel__foot {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--ink-700, #232d33);
  background: var(--ink-800, #172026);
}

.inidel-chat-panel__input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--ink-700, #232d33);
  border-radius: var(--radius-2, 4px);
  padding: 10px 12px;
  font: inherit;
  color: var(--white, #fff);
  background: var(--ink-900, #0f1418);
}

.inidel-chat-panel__input:focus {
  outline: 2px solid var(--signal-blue, #4c7dff);
  outline-offset: 1px;
  border-color: var(--signal-blue, #4c7dff);
}

.inidel-chat-panel__input:disabled {
  opacity: 0.6;
}

.inidel-chat-panel__send {
  border: none;
  border-radius: var(--radius-2, 4px);
  padding: 10px 16px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  color: var(--white, #fff);
  background: linear-gradient(90deg, var(--slate-500, #6b7c88) 0%, var(--signal-blue, #4c7dff) 50%, var(--signal-violet, #9b6bff) 100%);
  background-size: 100% 100%;
  background-color: var(--signal-blue, #4c7dff);
}

.inidel-chat-panel__send:hover:not(:disabled) {
  filter: brightness(1.08);
}

.inidel-chat-panel__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.inidel-chat-panel__send:focus-visible {
  outline: 2px solid var(--focus, var(--slate-300));
  outline-offset: 2px;
}

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