/* ==========================================================================
   Inland Web Services — widget-chat.css
   Public popout chat widget. Reuses the site's existing design tokens
   (styles.css :root variables) rather than defining its own palette, so it
   stays visually in sync if the site's tokens ever change.

   Launcher sits bottom-RIGHT -- this replaced the site's previous Tawk.to
   live-chat widget (removed) in that same corner. See COORDINATION.md.

   To disable the widget entirely, see the WIDGET_ENABLED switch at the top
   of widget-chat.js -- this stylesheet does not need to change.
   ========================================================================== */

#iws-widget-root {
  --iws-z: 400; /* above the site's skip-link (200) and header (60); below nothing we control */
  font-family: var(--font-body);
}

/* ----------------------------------------------------------------------
   Launcher
   ---------------------------------------------------------------------- */
#iws-widget-launcher {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: var(--iws-z);
  width: 56px;
  height: 56px;
  border-radius: var(--pill);
  background: var(--amber);
  color: #151003;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform 0.12s ease, background 0.2s ease;
  padding: 0;
}
#iws-widget-launcher:hover { background: var(--amber-d); }
#iws-widget-launcher:active { transform: scale(0.96); }
#iws-widget-launcher svg { width: 26px; height: 26px; }
#iws-widget-launcher[aria-expanded="true"] .iws-icon-chat { display: none; }
#iws-widget-launcher[aria-expanded="true"] .iws-icon-close { display: block; }
#iws-widget-launcher:not([aria-expanded="true"]) .iws-icon-close { display: none; }

@supports (bottom: env(safe-area-inset-bottom)) {
  #iws-widget-launcher {
    right: calc(18px + env(safe-area-inset-right));
    bottom: calc(18px + env(safe-area-inset-bottom));
  }
}

/* ----------------------------------------------------------------------
   Panel
   ---------------------------------------------------------------------- */
#iws-widget-panel {
  position: fixed;
  right: 18px;
  bottom: 88px;
  z-index: var(--iws-z);
  width: 380px;
  max-width: calc(100vw - 36px);
  height: min(600px, calc(100vh - 110px));
  max-height: calc(100vh - 110px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#iws-widget-panel[hidden] { display: none; }

@supports (bottom: env(safe-area-inset-bottom)) {
  #iws-widget-panel {
    right: calc(18px + env(safe-area-inset-right));
    bottom: calc(88px + env(safe-area-inset-bottom));
  }
}

.iws-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  flex: none;
}
.iws-widget-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--txt);
  display: flex;
  align-items: center;
  gap: 8px;
}
.iws-widget-title .iws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  flex: none;
}
.iws-widget-subtitle {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}
#iws-widget-close {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  min-width: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#iws-widget-close:hover { border-color: var(--amber); color: var(--amber); }
#iws-widget-close svg { width: 16px; height: 16px; }

#iws-widget-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.iws-msg {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
  line-height: 1.45;
}
.iws-msg.iws-msg--assistant {
  align-self: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--txt);
}
.iws-msg.iws-msg--user {
  align-self: flex-end;
  background: var(--amber);
  color: #151003;
}
.iws-msg.iws-msg--error {
  align-self: flex-start;
  background: var(--panel-2);
  border: 1px solid #aa6269;
  color: #e8b7bc;
}
.iws-msg.iws-msg--pending {
  align-self: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 11px 14px;
}
.iws-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: iws-typing-pulse 1.1s ease-in-out infinite;
}
.iws-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.iws-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes iws-typing-pulse {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  .iws-typing-dot { animation: none; opacity: 0.7; }
}

.iws-msg-link {
  display: inline-flex;
  margin-top: 8px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #151003;
  background: var(--amber);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.iws-msg-link:hover { background: var(--amber-d); text-decoration: none; }

#iws-widget-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 12px;
  flex: none;
}
.iws-quick-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: var(--pill);
  padding: 7px 12px;
  font-size: 12.5px;
  font-family: var(--font-body);
  cursor: pointer;
  min-height: 32px;
}
.iws-quick-btn:hover { border-color: var(--amber); color: var(--amber); }

.iws-widget-disclosure {
  margin: 0;
  padding: 0 14px 8px;
  font-size: 11px;
  color: var(--muted);
  flex: none;
}

#iws-widget-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  flex: none;
}
#iws-widget-input {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  background: var(--panel-2);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: inherit;
  font-size: 13.5px;
}
#iws-widget-input:focus { outline: none; border-color: var(--amber); }
#iws-widget-send {
  background: var(--amber);
  color: #151003;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 16px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
  min-width: 64px;
  min-height: 40px;
}
#iws-widget-send:disabled { background: var(--panel-2); color: var(--muted); cursor: not-allowed; }
#iws-widget-send:not(:disabled):hover { background: var(--amber-d); }

/* ----------------------------------------------------------------------
   Small mobile: near-full-screen panel, safe-area aware.
   ---------------------------------------------------------------------- */
@media (max-width: 480px) {
  #iws-widget-panel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    top: 10px;
    width: auto;
    max-width: none;
    height: auto;
    max-height: none;
  }
  @supports (bottom: env(safe-area-inset-bottom)) {
    #iws-widget-panel {
      left: calc(10px + env(safe-area-inset-left));
      right: calc(10px + env(safe-area-inset-right));
      top: calc(10px + env(safe-area-inset-top));
      bottom: calc(10px + env(safe-area-inset-bottom));
    }
  }
  #iws-widget-launcher {
    right: calc(14px + env(safe-area-inset-right, 0px));
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  #iws-widget-launcher, #iws-widget-send, #iws-widget-close { transition: none; }
}
