/* ICT Shift livechat widget — lightweight custom widget (no Chatwoot SDK).
   All colors use Astra global color variables (--ast-global-color-0..8) so the
   widget automatically matches the site's light/dark theme. */
.ictss-widget {
  /* Theme palette (Astra global variables — auto-adapt to light/dark mode). */
  --ictss-text: var(--ast-global-color-3);
  --ictss-heading: var(--ast-global-color-2);
  --ictss-muted: var(--ast-global-color-6);
  --ictss-bg: var(--ast-global-color-5);
  --ictss-surface: var(--ast-global-color-4);
  --ictss-accent: var(--ast-global-color-1);
  /* High-contrast text on the accent (UI contrast, not a palette color). */
  --ictss-on-accent: #fff;
  --ictss-border: var(--ast-global-color-6);
  --ictss-border: color-mix(in srgb, var(--ast-global-color-6) 35%, transparent);
  --ictss-border-soft: var(--ast-global-color-6);
  --ictss-border-soft: color-mix(in srgb, var(--ast-global-color-6) 22%, transparent);
  --ictss-surface-hover: var(--ast-global-color-4);
  --ictss-surface-hover: color-mix(in srgb, var(--ast-global-color-6) 14%, var(--ast-global-color-5));
  --ictss-accent-soft: var(--ast-global-color-4);
  --ictss-accent-soft: color-mix(in srgb, var(--ast-global-color-1) 12%, var(--ast-global-color-5));
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999999;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ictss-text);
}

/* Launcher button */
.ictss-launcher {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--ictss-accent);
  color: var(--ictss-on-accent);
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.ictss-launcher:hover { transform: scale(1.06); filter: brightness(0.9); }
.ictss-launcher svg { width: 26px; height: 26px; flex: none; }
.ictss-launcher .ictss-badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  /* Standard notification red — intentionally not a theme palette color. */
  background: #e5484d;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--ictss-bg);
}

/* Panel */
.ictss-panel {
  display: none;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 40px);
  background: var(--ictss-bg);
  color: var(--ictss-text);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  flex-direction: column;
  overflow: hidden;
}
.ictss-panel.open { display: flex; }

/* Header */
.ictss-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--ictss-accent);
  color: var(--ictss-on-accent);
}
.ictss-header .ictss-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.ictss-header .ictss-meta { flex: 1; min-width: 0; }
.ictss-header .ictss-name { font-weight: 700; font-size: 15px; }
.ictss-header .ictss-status { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 6px; }
.ictss-header .ictss-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 2px rgba(255,255,255,0.35); flex: none; }
.ictss-header .ictss-status.is-away::before { background: #f5b82e; }
.ictss-header .ictss-status.is-offline::before { background: #b8bcc2; }
.ictss-header button {
  background: transparent;
  border: 0;
  color: var(--ictss-on-accent);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 6px;
  border-radius: 6px;
}
.ictss-header button:hover { background: rgba(255,255,255,0.15); }
.ictss-header button svg { width: 20px; height: 20px; display: block; }

/* Conversation switcher */
.ictss-convs {
  display: none;
  max-height: 220px;
  overflow-y: auto;
  border-bottom: 1px solid var(--ictss-border);
}
.ictss-convs.open { display: block; }
.ictss-convs .ictss-conv {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--ictss-border-soft);
}
.ictss-convs .ictss-conv:hover { background: var(--ictss-surface-hover); }
.ictss-convs .ictss-conv .t { font-weight: 600; }
.ictss-convs .ictss-conv .d { font-size: 12px; color: var(--ictss-muted); }
.ictss-convs .ictss-conv .s { font-size: 11px; text-transform: capitalize; color: var(--ictss-accent); }
.ictss-newconv {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  color: var(--ictss-accent);
  border-top: 1px solid var(--ictss-border);
}
.ictss-newconv:hover { background: var(--ictss-accent-soft); }

/* Messages area */
.ictss-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--ictss-surface);
}
.ictss-day { text-align: center; font-size: 11px; color: var(--ictss-muted); margin: 8px 0; }
.ictss-msg { margin-bottom: 12px; display: flex; gap: 8px; align-items: flex-start; }
.ictss-msg.user { flex-direction: row-reverse; }
.ictss-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex: none;
  display: flex; align-items: center; justify-content: center;
}
.ictss-msg.bot .ictss-msg-avatar { background: var(--ictss-accent); color: var(--ictss-on-accent); }
.ictss-msg.user .ictss-msg-avatar { background: var(--ictss-surface-hover); color: var(--ictss-muted); }
.ictss-msg-avatar svg { width: 16px; height: 16px; }
.ictss-msg.bot .ictss-msg-avatar.agent { position: relative; overflow: hidden; background: var(--ictss-surface-hover); color: var(--ictss-accent); font-size: 13px; font-weight: 700; }
.ictss-msg-avatar.agent img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ictss-agent-name { font-size: 11px; font-weight: 600; color: var(--ictss-muted); margin: 0 0 3px 2px; }
.ictss-msg-body { max-width: 80%; min-width: 0; display: flex; flex-direction: column; }
.ictss-msg.user .ictss-msg-body { align-items: flex-end; }
.ictss-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ictss-msg.bot .ictss-bubble {
  background: var(--ictss-bg);
  border: 1px solid var(--ictss-border);
  border-bottom-left-radius: 4px;
  color: var(--ictss-text);
}
.ictss-msg.user .ictss-bubble {
  background: var(--ictss-accent);
  color: var(--ictss-on-accent);
  border-bottom-right-radius: 4px;
}
.ictss-bubble a { color: var(--ictss-accent); text-decoration: underline; }
.ictss-msg.user .ictss-bubble a { color: var(--ictss-on-accent); }
.ictss-attach { margin-top: 8px; max-width: 100%; border-radius: 8px; display: block; }
.ictss-file { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 6px 10px; border-radius: 8px; background: var(--ictss-surface-hover, rgba(0,0,0,.05)); font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ictss-time { font-size: 10px; color: #8e8e93; margin-top: 3px; }

/* Typing indicator */
.ictss-typing .ictss-bubble { display: inline-flex; gap: 4px; padding: 14px 16px; }
.ictss-typing .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ictss-muted);
  animation: ictss-blink 1.2s infinite both;
}
.ictss-typing .dot:nth-child(2) { animation-delay: 0.2s; }
.ictss-typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ictss-blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* Quick replies */
.ictss-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 10px;
  background: var(--ictss-surface);
}
.ictss-quick button {
  border: 1px solid var(--ictss-accent);
  background: var(--ictss-bg);
  color: var(--ictss-accent);
  border-radius: 16px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}
.ictss-quick button:hover { background: var(--ictss-accent); color: var(--ictss-on-accent); }

/* Composer (modern chat layout: icon buttons flank a flexible input) */
.ictss-composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px 10px;
  background: var(--ictss-bg);
  border-top: 1px solid var(--ictss-border);
}
.ictss-composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 1px solid var(--ictss-border);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  max-height: 100px;
  min-height: 38px;
  background: var(--ictss-surface);
  color: var(--ictss-text);
}
.ictss-composer textarea:focus { outline: 2px solid var(--ictss-accent); border-color: transparent; }
.ictss-attach-btn, .ictss-send-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.ictss-attach-btn { background: transparent; color: var(--ictss-muted); }
.ictss-attach-btn:hover { background: var(--ictss-surface-hover); color: var(--ictss-text); }
.ictss-send-btn { background: var(--ictss-accent); color: var(--ictss-on-accent); }
.ictss-send-btn:hover { filter: brightness(0.9); }
.ictss-send-btn:disabled { background: var(--ictss-muted); cursor: default; }
.ictss-send-btn svg, .ictss-attach-btn svg { width: 20px; height: 20px; flex: none; }
/* Emoji button: hidden until the user types a trigger (: or ?) */
.ictss-emoji-btn { display: none; }
.ictss-emoji-btn.show { display: flex; }

/* Attachment previews */
.ictss-previews {
  display: none;
  gap: 8px;
  padding: 8px 12px 0;
  background: var(--ictss-bg);
  flex-wrap: wrap;
}
.ictss-previews.open { display: flex; }
.ictss-previews .prev {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 8px;
  background: var(--ictss-surface);
  overflow: hidden;
}
.ictss-previews .prev img { width: 100%; height: 100%; object-fit: cover; }
.ictss-previews .prev .rm {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff;
  border: 0; cursor: pointer; font-size: 12px; line-height: 1;
}

/* Emoji picker (simple grid) */
.ictss-emoji {
  display: none;
  padding: 8px 12px;
  background: var(--ictss-bg);
  border-top: 1px solid var(--ictss-border);
  max-height: 140px;
  overflow-y: auto;
}
.ictss-emoji.open { display: block; }
.ictss-emoji .grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.ictss-emoji button {
  border: 0; background: transparent; font-size: 20px;
  cursor: pointer; padding: 4px; border-radius: 6px;
}
.ictss-emoji button:hover { background: var(--ictss-surface); }

/* Footer note */
.ictss-foot {
  text-align: center;
  font-size: 11px;
  color: #8e8e93;
  padding: 6px;
  background: var(--ictss-bg);
}

/* Mobile */
@media (max-width: 480px) {
  .ictss-panel {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    bottom: 0; right: 0;
  }
  .ictss-widget { bottom: 0; right: 0; }
}

/* Drag & drop files onto the panel */
.ictss-panel { position: relative; }
.ictss-panel.ictss-dropping::after {
  content: attr(data-drop-label);
  position: absolute;
  inset: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--ictss-accent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--ictss-bg) 88%, transparent);
  color: var(--ictss-heading);
  font-weight: 600;
  pointer-events: none;
  z-index: 20;
}
