/* ============================================================================
   IronChat — custom live-chat widget
   Brand: docs/brandbook.md — dark surfaces, amber accent (Amber Rule: amber
   appears only on the launcher icon, unread badge, and the send button —
   single functional amber element group, no competing CTAs).
   ============================================================================ */

.ironchat-launcher {
  position: fixed;
  right: var(--space-3);
  bottom: var(--space-3);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 500;
  transition: filter var(--transition-fast), transform var(--transition-fast);
}

.ironchat-launcher:hover {
  filter: brightness(1.08);
}

.ironchat-launcher:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.ironchat-launcher svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: #0E0E0E;
  stroke-width: 1.75;
}

.ironchat-launcher__icon-close {
  display: none;
}

.ironchat-launcher.is-open .ironchat-launcher__icon-chat {
  display: none;
}

.ironchat-launcher.is-open .ironchat-launcher__icon-close {
  display: block;
}

.ironchat-launcher__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #e05252;
  color: #fff;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-bg-primary);
}

.ironchat-launcher__badge.is-visible {
  display: flex;
}

.ironchat-panel {
  position: fixed;
  right: var(--space-3);
  bottom: calc(56px + var(--space-3) + var(--space-2));
  width: 360px;
  max-width: calc(100vw - (var(--space-3) * 2));
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 500;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.ironchat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ironchat-panel__header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ironchat-panel__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.02em;
  color: var(--color-text-primary);
  text-transform: uppercase;
  margin: 0;
}

.ironchat-panel__close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--color-text-muted);
  display: flex;
  transition: color var(--transition-fast);
}

.ironchat-panel__close:hover {
  color: var(--color-text-primary);
}

.ironchat-panel__close svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
}

.ironchat-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ironchat-panel__intro {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 14px;
  color: var(--color-text-muted);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-1);
}

.ironchat-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ironchat-msg--visitor {
  align-self: flex-end;
  background: var(--color-accent);
  color: #0E0E0E;
  border-bottom-right-radius: 2px;
}

.ironchat-msg--agent {
  align-self: flex-start;
  background: var(--color-bg-elevated);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 2px;
}

.ironchat-panel__form {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
}

.ironchat-panel__input {
  flex: 1;
  resize: none;
  max-height: 96px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 15px;
  padding: 10px 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.ironchat-panel__input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.7;
}

.ironchat-panel__input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(232, 124, 46, 0.25);
}

.ironchat-panel__send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter var(--transition-fast);
}

.ironchat-panel__send:hover {
  filter: brightness(1.08);
}

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

.ironchat-panel__send:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.ironchat-panel__send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #0E0E0E;
  stroke-width: 1.75;
}

/* Mobile: full-width bottom sheet */
@media (max-width: 768px) {
  .ironchat-panel {
    right: var(--space-2);
    left: var(--space-2);
    bottom: calc(56px + var(--space-2) + var(--space-2));
    width: auto;
    max-width: none;
    height: calc(100vh - 160px);
    max-height: none;
  }

  .ironchat-launcher {
    right: var(--space-2);
    bottom: var(--space-2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ironchat-panel,
  .ironchat-launcher {
    transition: none;
  }
}
