/* ============================================================
   SXMeets Mobile — AI Co-pilot bar (WS-F)
   ------------------------------------------------------------
   Two surfaces:
     1. Floating action button (FAB) — bottom-right of host page
     2. Bottom sheet — full-height chat OR settings panel

   Skin: respects body[data-os="…"] tokens (--coral as the FAB
   accent). Falls back to literal values when tokens.css is
   absent.
   ============================================================ */

/* ── FAB ─────────────────────────────────────────────────── */
.sx-cp-fab {
  position: fixed;
  right: 16px;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  width: 54px;
  height: 54px;
  border-radius: 27px;
  background: var(--coral, #FF5533);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, .35),
    0 0 0 1.5px rgba(255, 255, 255, .08) inset;
  transition: transform .12s, box-shadow .2s;
  font-family: inherit;
}
.sx-cp-fab:active { transform: scale(.92); }
.sx-cp-fab:hover { box-shadow: 0 8px 26px rgba(0, 0, 0, .45), 0 0 0 1.5px rgba(255,255,255,.10) inset; }

.sx-cp-fab .sx-cp-fab-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 0 0 #4ADE80;
  animation: sx-cp-pulse 1.6s ease-out infinite;
}
.sx-cp-fab.no-key .sx-cp-fab-dot {
  background: #FFB020;
}
@keyframes sx-cp-pulse {
  0%   { box-shadow: 0 0 0 0 currentColor; }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .sx-cp-fab .sx-cp-fab-dot { animation: none; }
}

/* ── Sheet backdrop ──────────────────────────────────────── */
.sx-cp-bd {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  animation: sx-cp-fade-in .18s ease-out;
}
.sx-cp-bd.open { display: flex; }
@keyframes sx-cp-fade-in { from { opacity: 0 } to { opacity: 1 } }

.sx-cp-sheet {
  background: var(--surface, #1A1F2E);
  color: var(--text, #F4F6FB);
  width: 100%;
  height: 86vh;
  max-height: 86vh;
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--border, rgba(255, 255, 255, .10));
  border-bottom: none;
  display: flex;
  flex-direction: column;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  animation: sx-cp-slide-up .25s cubic-bezier(.2, .9, .3, 1);
  overflow: hidden;
}
@keyframes sx-cp-slide-up { from { transform: translateY(100%) } to { transform: none } }

.sx-cp-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, .22);
  border-radius: 2px;
  margin: 10px auto 8px;
  flex-shrink: 0;
}
body.bright .sx-cp-handle { background: rgba(10, 26, 46, .22); }

/* ── Header (title + actions) ───────────────────────────── */
.sx-cp-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 20px 14px;
  border-bottom: 1px solid var(--border-2, rgba(255, 255, 255, .06));
  flex-shrink: 0;
}
.sx-cp-head-ic {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--coral, #FF5533);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
}
.sx-cp-head-title {
  flex: 1;
  min-width: 0;
}
.sx-cp-head-title b {
  display: block;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.2px;
}
.sx-cp-head-title small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, rgba(255, 255, 255, .55));
  letter-spacing: .3px;
  text-transform: uppercase;
}
.sx-cp-head-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted, rgba(255, 255, 255, .55));
  border: none;
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.sx-cp-head-btn:hover {
  background: rgba(255, 255, 255, .06);
  color: var(--text, #fff);
}
body.bright .sx-cp-head-btn:hover { background: rgba(10, 26, 46, .05); color: #0A1A2E; }

/* ── Chat view ─────────────────────────────────────────── */
.sx-cp-view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.sx-cp-view.active { display: flex; }

.sx-cp-log {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sx-cp-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.sx-cp-msg.user {
  align-self: flex-end;
  background: var(--coral, #FF5533);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.sx-cp-msg.assistant {
  align-self: flex-start;
  background: var(--surface-2, rgba(255, 255, 255, .06));
  border: 1px solid var(--border-2, rgba(255, 255, 255, .06));
  border-bottom-left-radius: 4px;
}
.sx-cp-msg.system {
  align-self: center;
  background: rgba(255, 176, 32, .12);
  color: #FFB020;
  border: 1px solid rgba(255, 176, 32, .35);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  max-width: 92%;
}
.sx-cp-msg.thinking::after {
  content: '▍';
  margin-left: 2px;
  animation: sx-cp-blink 1s steps(2) infinite;
}
@keyframes sx-cp-blink { 0%, 50% { opacity: 1 } 51%, 100% { opacity: 0 } }

/* Empty state */
.sx-cp-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted, rgba(255, 255, 255, .55));
}
.sx-cp-empty-ic {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: .6;
}
.sx-cp-empty strong {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: var(--text, #fff);
  margin-bottom: 6px;
}
.sx-cp-empty p {
  font-size: 13px;
  line-height: 1.5;
  max-width: 280px;
  margin: 0 auto;
}
.sx-cp-empty .chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 18px;
}
.sx-cp-chip {
  font-size: 11.5px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2, rgba(255, 255, 255, .06));
  border: 1px solid var(--border, rgba(255, 255, 255, .10));
  color: var(--text, #fff);
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.sx-cp-chip:hover { background: var(--surface-3, rgba(255, 255, 255, .10)); }
.sx-cp-chip:active { transform: scale(.96); }

/* Composer */
.sx-cp-composer {
  flex-shrink: 0;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-2, rgba(255, 255, 255, .06));
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--surface, #1A1F2E);
}
.sx-cp-input {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2, rgba(255, 255, 255, .06));
  border: 1px solid var(--border, rgba(255, 255, 255, .10));
  color: var(--text, #fff);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
}
.sx-cp-input::placeholder { color: var(--muted-2, rgba(255, 255, 255, .42)); }
.sx-cp-input:focus { border-color: var(--coral, #FF5533); }

.sx-cp-send {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--coral, #FF5533);
  color: #fff;
  border: none;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: opacity .15s, transform .08s;
}
.sx-cp-send:active { transform: scale(.95); }
.sx-cp-send:disabled { opacity: .4; pointer-events: none; }

/* ── Settings view ─────────────────────────────────────── */
.sx-cp-settings { padding: 16px 20px 24px; overflow-y: auto; flex: 1; }
.sx-cp-settings h4 {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted, rgba(255, 255, 255, .55));
  margin: 4px 0 10px;
}
.sx-cp-settings p.sx-cp-help {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted, rgba(255, 255, 255, .65));
  margin: 8px 0 16px;
}
.sx-cp-settings p.sx-cp-help b { color: var(--text, #fff); font-weight: 800; }
.sx-cp-settings p.sx-cp-help a {
  color: var(--coral, #FF5533);
  text-decoration: underline;
  font-weight: 700;
}

.sx-cp-warn {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 176, 32, .10);
  border: 1px solid rgba(255, 176, 32, .35);
  color: #FFB020;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 600;
  margin-bottom: 18px;
}
.sx-cp-warn b { font-weight: 800; }

.sx-cp-field {
  display: block;
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--surface-2, rgba(255, 255, 255, .06));
  border: 1.5px solid var(--border, rgba(255, 255, 255, .10));
  color: var(--text, #fff);
  font-size: 15px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  outline: none;
  letter-spacing: .3px;
}
.sx-cp-field:focus { border-color: var(--coral, #FF5533); }

.sx-cp-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.sx-cp-row .sx-cp-field { flex: 1; }
.sx-cp-eye {
  background: transparent;
  border: 1px solid var(--border, rgba(255, 255, 255, .10));
  border-radius: 12px;
  color: var(--muted, rgba(255, 255, 255, .55));
  cursor: pointer;
  width: 44px;
  flex-shrink: 0;
  font-size: 15px;
  font-family: inherit;
}
.sx-cp-eye:hover { background: var(--surface-2, rgba(255,255,255,.06)); }

.sx-cp-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted, rgba(255, 255, 255, .55));
  margin: 16px 0 8px;
  display: block;
}

.sx-cp-select {
  display: block;
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--surface-2, rgba(255, 255, 255, .06));
  border: 1.5px solid var(--border, rgba(255, 255, 255, .10));
  color: var(--text, #fff);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.sx-cp-select:focus { border-color: var(--coral, #FF5533); }

.sx-cp-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.sx-cp-btn {
  flex: 1;
  min-height: 48px;
  padding: 13px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .2px;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: transform .08s, opacity .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.sx-cp-btn:active { transform: scale(.97); }
.sx-cp-btn:disabled { opacity: .5; pointer-events: none; }
.sx-cp-btn.primary {
  background: var(--coral, #FF5533);
  color: #fff;
  box-shadow: 0 4px 14px rgba(255, 85, 51, .30);
}
.sx-cp-btn.ghost {
  background: rgba(255, 255, 255, .06);
  color: var(--text, #fff);
  border: 1px solid var(--border, rgba(255, 255, 255, .12));
}
.sx-cp-btn.danger {
  background: rgba(255, 77, 61, .14);
  color: #FF4D3D;
  border: 1px solid rgba(255, 77, 61, .35);
}
.sx-cp-btn.loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: sx-cp-spin .8s linear infinite;
}
@keyframes sx-cp-spin { to { transform: rotate(360deg) } }

.sx-cp-current {
  padding: 14px;
  border-radius: 12px;
  background: rgba(74, 222, 128, .10);
  border: 1px solid rgba(74, 222, 128, .35);
  font-size: 13px;
  font-weight: 600;
  color: #4ADE80;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sx-cp-current.bad {
  background: rgba(255, 77, 61, .10);
  border-color: rgba(255, 77, 61, .35);
  color: #FF4D3D;
}
.sx-cp-current b {
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
}

.sx-cp-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 77, 61, .12);
  border: 1px solid rgba(255, 77, 61, .35);
  color: #FF4D3D;
  font-size: 12px;
  font-weight: 700;
  display: none;
}
.sx-cp-error.show { display: block; }

.sx-cp-success {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(74, 222, 128, .12);
  border: 1px solid rgba(74, 222, 128, .35);
  color: #4ADE80;
  font-size: 12px;
  font-weight: 700;
  display: none;
}
.sx-cp-success.show { display: block; }

/* ── Bright mode ───────────────────────────────────────── */
body.bright .sx-cp-sheet { background: #FFFFFF; color: #0A1A2E; border-color: rgba(10, 26, 46, .12); }
body.bright .sx-cp-composer { background: #FFFFFF; }
body.bright .sx-cp-msg.assistant { background: rgba(10, 26, 46, .04); border-color: rgba(10, 26, 46, .08); }
body.bright .sx-cp-input, body.bright .sx-cp-field, body.bright .sx-cp-select { background: rgba(10, 26, 46, .04); border-color: rgba(10, 26, 46, .12); color: #0A1A2E; }
body.bright .sx-cp-chip { background: rgba(10, 26, 46, .04); border-color: rgba(10, 26, 46, .08); color: #0A1A2E; }
body.bright .sx-cp-eye { border-color: rgba(10, 26, 46, .12); color: rgba(10, 26, 46, .55); }
body.bright .sx-cp-btn.ghost { background: rgba(10, 26, 46, .04); border-color: rgba(10, 26, 46, .12); color: #0A1A2E; }
