/*
  Support Widget Styles (Visitor side)
  - Floating circular launcher button
  - Slide-up chat panel with header, messages list, and composer
  - Dark theme to match invoice tool; fully responsive
*/

:root {
  --sw-bg: #0e1326;
  --sw-panel: #141a33;
  --sw-panel-2: #0f1631;
  --sw-text: #e9edf7;
  --sw-muted: #a7b0c9;
  --sw-accent: #4f7cff;
  --sw-accent-2: #00b7ff;
  --sw-border: #263156;
  --sw-danger: #ff5d5d;
  --sw-shadow: 0 12px 40px rgba(0,0,0,.38);
  --sw-radius: 16px;
}

/* Launcher button */
.support-launcher {
  position: fixed;
  right: 18px; bottom: 18px;
  width: 58px; height: 58px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(140% 140% at 30% 20%, var(--sw-accent) 0%, var(--sw-accent-2) 100%);
  color: #fff; font-weight: 800;
  box-shadow: 0 10px 28px rgba(79,124,255,.45);
  cursor: pointer; z-index: 9999;
  border: 0; outline: none;
  transition: transform .12s ease, box-shadow .2s ease;
}
.support-launcher:hover { transform: translateY(-1px); box-shadow: 0 14px 36px rgba(79,124,255,.55); }
.support-launcher svg { width: 28px; height: 28px; }
.support-launcher .icon-x { display: none; }
.support-launcher.open .icon-chat { display: none; }
.support-launcher.open .icon-x { display: inline; }

/* Panel container */
.support-widget {
  position: fixed;
  right: 18px; bottom: 86px;
  width: min(92vw, 360px);
  height: min(70vh, 560px);
  background: linear-gradient(180deg, var(--sw-panel) 0%, var(--sw-panel-2) 100%);
  color: var(--sw-text);
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius);
  box-shadow: var(--sw-shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: 64px 1fr auto;
  transform: translateY(24px) scale(.98);
  opacity: 0; pointer-events: none;
  transition: transform .22s ease, opacity .22s ease;
  z-index: 9998;
}
.support-widget.open { transform: translateY(0) scale(1); opacity: 1; pointer-events: auto; }

.sw-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--sw-border);
  background: linear-gradient(180deg, #0f1839, #0c1230);
}
.sw-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sw-end-chat {
  background: var(--sw-danger);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s ease;
}
.sw-end-chat:hover {
  background: #ff7d7d;
}
.sw-logo { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: linear-gradient(135deg, var(--sw-accent), var(--sw-accent-2)); color: #fff; font-weight: 800; overflow: hidden; }
.sw-logo img { width: 78%; height: 78%; object-fit: contain; display: block; border-radius: 6px; }
.sw-title { font-weight: 700; letter-spacing: .2px; }
.sw-sub { font-size: 12px; color: var(--sw-muted); }

.sw-body { overflow: auto; padding: 14px; background: linear-gradient(180deg, #0f1430, #0b1024); }
.sw-day { text-align: center; color: var(--sw-muted); font-size: 12px; margin: 10px 0; position: relative; }
.sw-day::before, .sw-day::after { content: ""; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--sw-border); }
.sw-day::before { left: 0; } .sw-day::after { right: 0; }

/* System notices (e.g., chat closed) */
.sw-system { text-align: center; color: var(--sw-muted); font-size: 12.5px; margin: 10px 0; }

/* Restart CTA after close */
.sw-restart { display: grid; place-items: center; margin: 12px 0; }
.sw-restart .sw-btn { padding: 8px 12px; }

.sw-msg { display: flex; gap: 8px; margin: 8px 0; align-items: flex-end; }
.sw-block { display: flex; flex-direction: column; max-width: 78%; }
.sw-bubble { width: fit-content; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--sw-border); box-shadow: var(--sw-shadow); line-height: 1.35; word-wrap: anywhere; }
.sw-time { color: var(--sw-muted); font-size: 11px; margin-top: 4px; }
.sw-from-a { justify-content: flex-start; }
.sw-from-a .sw-bubble { background: #141a31; }
.sw-from-a .sw-time { text-align: left; }
.sw-from-v { justify-content: flex-end; }
.sw-from-v .sw-bubble { background: linear-gradient(135deg, var(--sw-accent), var(--sw-accent-2)); color: #fff; border-color: transparent; }
.sw-from-v .sw-time { text-align: right; }

.sw-composer { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; padding: 12px; border-top: 1px solid var(--sw-border); background: var(--sw-panel-2); }
.sw-attach { border: 1px solid var(--sw-border); background: var(--sw-panel); color: var(--sw-text); border-radius: 12px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; transition: filter .2s ease, transform .1s ease; }
.sw-attach:not(:disabled) { background: linear-gradient(135deg, var(--sw-accent), var(--sw-accent-2)); color: #0e1521; border-color: transparent; }
.sw-attach:not(:disabled):hover { filter: brightness(1.05); transform: translateY(-1px); }
.sw-attach svg { pointer-events: none; }
.sw-attach:disabled { opacity: .5; cursor: not-allowed; }
.sw-attach[disabled] { opacity: .5; cursor: not-allowed; }
.sw-inputbox { display: flex; align-items: center; gap: 8px; background: var(--sw-panel); border: 1px solid var(--sw-border); border-radius: 12px; padding: 8px 10px; }
.sw-textarea { flex: 1; min-height: 42px; max-height: 120px; resize: vertical; background: transparent; border: 0; outline: none; color: var(--sw-text); }
.sw-send { border: 0; background: var(--sw-accent); color: #fff; font-weight: 700; padding: 10px 14px; border-radius: 12px; cursor: pointer; box-shadow: 0 10px 24px rgba(79,124,255,.35); }
.sw-send:disabled { opacity: .6; cursor: not-allowed; box-shadow: none; }

/* Entry mini-card to prompt user */
.sw-entry-card { display: grid; gap: 6px; background: #12183a; border: 1px dashed #2c3866; border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.sw-entry-card .sw-entry-title { font-weight: 700; }
.sw-entry-card .sw-entry-sub { color: var(--sw-muted); font-size: 12px; }
.sw-entry-actions { display: flex; gap: 8px; }
.sw-entry-actions .sw-act { background: #182048; color: #d5defa; border: 1px solid #2b3a70; border-radius: 10px; padding: 6px 10px; cursor: pointer; }

/* Modern inline modal for name set */
.sw-overlay { position: fixed; inset: 0; background: rgba(9,12,24,.55); display: grid; place-items: center; z-index: 10000; opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.sw-overlay.show { opacity: 1; pointer-events: auto; }
.sw-modal { width: min(92vw, 360px); background: linear-gradient(180deg,#101739,#0b1129); color: var(--sw-text); border: 1px solid #27335e; border-radius: 14px; box-shadow: var(--sw-shadow); padding: 14px; }
.sw-modal h4 { margin: 0 0 8px 0; font-weight: 800; }
.sw-modal p { margin: 0 0 10px 0; color: var(--sw-muted); font-size: 13px; }
.sw-field { display: flex; align-items: center; gap: 8px; background: #131a36; border: 1px solid #263156; border-radius: 10px; padding: 8px 10px; }
.sw-field input { flex: 1; background: transparent; border: 0; outline: none; color: var(--sw-text); font-size: 14px; }
.sw-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.sw-btn { border: 1px solid #2b3764; background: #171f42; color: #d0dbff; border-radius: 10px; padding: 8px 12px; font-weight: 700; cursor: pointer; }
.sw-btn.primary { background: var(--sw-accent); border-color: transparent; color: #fff; box-shadow: 0 10px 22px rgba(79,124,255,.35); }

/* Mobile tweaks */
@media (max-width: 520px) {
  .support-widget { right: 10px; left: 10px; width: auto; height: min(76vh, 620px); }
  .support-launcher { right: 14px; bottom: 14px; }
}
