/* FreelanceHub Live Chat — modern product UI */
:root {
  --lc-primary: var(--brand-primary, #14b8a6);
  --lc-primary-dark: #0d9488;
  --lc-surface: #ffffff;
  --lc-surface-2: #f8fafc;
  --lc-border: #e2e8f0;
  --lc-text: #0f172a;
  --lc-muted: #64748b;
  --lc-agent-bg: #f1f5f9;
  --lc-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  --lc-radius: 20px;
}

html[data-theme="dark"] {
  --lc-surface: #111827;
  --lc-surface-2: #0f172a;
  --lc-border: #1f2a3a;
  --lc-text: #e5e7eb;
  --lc-muted: #94a3b8;
  --lc-agent-bg: #1e293b;
  --lc-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.55);
}

/* Launcher */
#lc-root {
  font-family: Inter, system-ui, -apple-system, sans-serif;
}
#lc-toggle {
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, var(--lc-primary) 0%, var(--lc-primary-dark) 100%);
  box-shadow: 0 10px 25px -5px rgba(20, 184, 166, 0.45), 0 4px 10px rgba(15, 23, 42, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}
#lc-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 14px 30px -5px rgba(20, 184, 166, 0.5);
}
#lc-toggle svg { width: 24px; height: 24px; }
#lc-toggle .lc-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 9999px;
  background: #ef4444;
  border: 2px solid #fff;
  display: none;
}
#lc-toggle.has-unread .lc-badge { display: block; }

/* Panel */
#lc-panel {
  width: 370px;
  max-width: calc(100vw - 1.5rem);
  height: 520px;
  max-height: calc(100vh - 6rem);
  border-radius: var(--lc-radius);
  background: var(--lc-surface);
  border: 1px solid var(--lc-border);
  box-shadow: var(--lc-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  animation: lc-panel-in 0.22s ease-out;
}
@keyframes lc-panel-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
#lc-panel.hidden { display: none !important; }

.lc-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, var(--lc-primary-dark) 160%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.lc-header-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.lc-header-sub { font-size: 11px; color: rgba(255,255,255,0.7); margin-top: 2px; }
.lc-header-close {
  width: 32px; height: 32px; border-radius: 9999px;
  border: none; background: rgba(255,255,255,0.1); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.lc-header-close:hover { background: rgba(255,255,255,0.2); }
.lc-header-close svg { width: 16px; height: 16px; }

/* Identity */
#lc-identity {
  padding: 16px;
  background: var(--lc-surface-2);
  border-bottom: 1px solid var(--lc-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#lc-identity.hidden { display: none !important; }
.lc-id-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--lc-muted);
}
.lc-field {
  display: flex; flex-direction: column; gap: 4px;
}
.lc-field label {
  font-size: 12px; font-weight: 600; color: var(--lc-text);
}
#lc-identity input,
#lc-identity select,
#lc-identity textarea {
  width: 100%;
  border: 1px solid var(--lc-border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  background: var(--lc-surface);
  color: var(--lc-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#lc-identity input:focus,
#lc-identity select:focus,
#lc-identity textarea:focus {
  border-color: var(--lc-primary);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}
#lc-start {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--lc-primary) 0%, var(--lc-primary-dark) 100%);
  cursor: pointer;
  margin-top: 4px;
  transition: transform 0.15s, box-shadow 0.15s;
}
#lc-start:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px -4px rgba(20, 184, 166, 0.4);
}

/* Messages */
#lc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--lc-surface-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lc-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--lc-muted);
  gap: 10px;
}
.lc-empty svg { width: 72px; height: 72px; opacity: 0.85; }
.lc-empty p { font-size: 13px; margin: 0; max-width: 200px; line-height: 1.45; }

.lc-row {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: lc-msg-in 0.18s ease-out;
}
@keyframes lc-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.lc-row.mine { align-self: flex-end; align-items: flex-end; }
.lc-row.theirs { align-self: flex-start; align-items: flex-start; }

.lc-agent-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  padding-left: 2px;
}
.lc-avatar {
  width: 22px; height: 22px; border-radius: 9999px;
  background: linear-gradient(135deg, var(--lc-primary), var(--lc-primary-dark));
  color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.lc-agent-name {
  font-size: 11px; font-weight: 600; color: var(--lc-muted);
}

.lc-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}
.lc-row.mine .lc-bubble {
  background: linear-gradient(135deg, var(--lc-primary) 0%, var(--lc-primary-dark) 100%);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.lc-row.theirs .lc-bubble {
  background: var(--lc-agent-bg);
  color: var(--lc-text);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--lc-border);
}
.lc-time {
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.55;
  padding: 0 4px;
}
.lc-row.mine .lc-time { text-align: right; color: var(--lc-muted); }
.lc-row.theirs .lc-time { color: var(--lc-muted); }

.lc-bubble img {
  border-radius: 12px;
  max-height: 160px;
  max-width: 100%;
  display: block;
  border: 1px solid rgba(0,0,0,0.06);
  margin-bottom: 4px;
}
.lc-bubble video {
  border-radius: 12px;
  max-height: 160px;
  max-width: 100%;
  display: block;
  margin-bottom: 4px;
}
.lc-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  font-size: 12px;
  text-decoration: none;
}
.lc-row.theirs .lc-file-chip {
  background: var(--lc-surface);
  color: var(--lc-primary-dark);
  border: 1px solid var(--lc-border);
}
.lc-row.mine .lc-file-chip { color: #fff; }

/* Composer */
.lc-composer-wrap {
  border-top: 1px solid var(--lc-border);
  background: var(--lc-surface);
  padding: 10px 12px;
}
#lc-share-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 8px;
  font-size: 11px;
}
#lc-share-bar.hidden { display: none !important; }
.lc-share-btn {
  border: none;
  background: transparent;
  color: var(--lc-primary-dark);
  font-weight: 600;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
}
.lc-share-btn.stop { color: #dc2626; }
#lc-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lc-attach {
  width: 36px; height: 36px; border-radius: 9999px;
  display: flex; align-items: center; justify-content: center;
  color: var(--lc-muted); cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.lc-attach:hover { background: var(--lc-surface-2); color: var(--lc-text); }
.lc-attach svg { width: 18px; height: 18px; }
#lc-input {
  flex: 1;
  border: 1px solid var(--lc-border);
  border-radius: 9999px;
  padding: 10px 14px;
  font-size: 13px;
  background: var(--lc-surface-2);
  color: var(--lc-text);
  outline: none;
}
#lc-input:focus {
  border-color: var(--lc-primary);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}
.lc-send {
  width: 36px; height: 36px; border-radius: 9999px;
  border: none;
  background: linear-gradient(135deg, var(--lc-primary), var(--lc-primary-dark));
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.lc-send:hover { transform: scale(1.06); }
.lc-send svg { width: 16px; height: 16px; }

/* Admin desk live chat */
.lc-admin-layout { display: grid; gap: 1.25rem; }
@media (min-width: 1024px) {
  .lc-admin-layout { grid-template-columns: 2fr 3fr; }
}
.lc-admin-list-item {
  display: block;
  padding: 14px 16px;
  border-bottom: 1px solid var(--lc-border, #e2e8f0);
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}
.lc-admin-list-item:hover { background: #f8fafc; }
html[data-theme="dark"] .lc-admin-list-item:hover { background: #1e293b; }
.lc-admin-list-item.active {
  background: #f0fdfa;
  border-left: 3px solid var(--lc-primary, #14b8a6);
}
html[data-theme="dark"] .lc-admin-list-item.active { background: rgba(20,184,166,0.1); }
.lc-admin-unread {
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.lc-admin-thread-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--lc-border, #e2e8f0);
  display: flex;
  align-items: center;
  gap: 12px;
}
.lc-admin-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 320px;
  max-height: 480px;
}
html[data-theme="dark"] .lc-admin-messages { background: #0f172a; }
.lc-admin-composer {
  border-top: 1px solid var(--lc-border, #e2e8f0);
  padding: 12px 16px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
html[data-theme="dark"] .lc-admin-composer { background: #111827; }
.lc-admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.lc-reason-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 9999px;
  background: #ecfdf5;
  color: #0f766e;
}
html[data-theme="dark"] .lc-reason-chip {
  background: rgba(20,184,166,0.15);
  color: #5eead4;
}
.lc-ss-panel {
  border-top: 1px solid var(--lc-border, #e2e8f0);
  padding: 12px 16px;
  background: #0f172a;
  color: #e2e8f0;
}
.lc-ss-panel video {
  width: 100%;
  max-height: 220px;
  border-radius: 12px;
  background: #000;
}


/* ── Dashboard Messages (user-to-user) ── */
.dm-shell {
  background: var(--lc-surface, #fff);
  border: 1px solid var(--lc-border, #e2e8f0);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 4px 24px -8px rgba(15, 23, 42, 0.08);
  height: calc(100vh - 180px);
  min-height: 480px;
}
.dm-list {
  border-right: 1px solid var(--lc-border, #e2e8f0);
  background: var(--lc-surface, #fff);
}
.dm-list-item {
  display: block;
  padding: 14px 16px;
  border-bottom: 1px solid var(--lc-border, #e2e8f0);
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
  position: relative;
}
.dm-list-item:hover { background: var(--lc-surface-2, #f8fafc); }
.dm-list-item.active {
  background: #f0fdfa;
  border-left: 3px solid var(--lc-primary, #14b8a6);
}
html[data-theme="dark"] .dm-list-item.active { background: rgba(20,184,166,0.1); }
.dm-thread-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--lc-border, #e2e8f0);
  background: var(--lc-surface, #fff);
  display: flex;
  align-items: center;
  gap: 12px;
}
.dm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: var(--lc-surface-2, #f8fafc);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
html[data-theme="dark"] .dm-messages { background: #0f172a; }
.dm-composer {
  border-top: 1px solid var(--lc-border, #e2e8f0);
  padding: 12px 14px;
  background: var(--lc-surface, #fff);
  display: flex;
  align-items: center;
  gap: 8px;
}
.dm-composer input[type="text"] {
  flex: 1;
  border: 1px solid var(--lc-border, #e2e8f0);
  border-radius: 9999px;
  padding: 10px 16px;
  font-size: 13px;
  background: var(--lc-surface-2, #f8fafc);
  color: var(--lc-text, #0f172a);
  outline: none;
}
.dm-composer input[type="text"]:focus {
  border-color: var(--lc-primary, #14b8a6);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}
.dm-send {
  width: 40px; height: 40px; border-radius: 9999px; border: none;
  background: linear-gradient(135deg, var(--lc-primary, #14b8a6), var(--lc-primary-dark, #0d9488));
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.dm-send:hover { transform: scale(1.06); }
.dm-attach {
  width: 40px; height: 40px; border-radius: 9999px;
  display: flex; align-items: center; justify-content: center;
  color: var(--lc-muted, #64748b); cursor: pointer;
  flex-shrink: 0;
}
.dm-attach:hover { background: var(--lc-surface-2, #f8fafc); color: var(--lc-text, #0f172a); }
/* reuse .lc-row / .lc-bubble / .lc-avatar from live chat for dashboard bubbles */

/* —— Verified staff seal (messaging) —— */
.fh-verified-tick {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 18px !important;
  height: 18px !important;
  min-width: 18px;
  min-height: 18px;
  flex-shrink: 0 !important;
  line-height: 0;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: visible !important;
  vertical-align: middle;
}
.fh-verified-tick svg {
  width: 18px !important;
  height: 18px !important;
  display: block !important;
  flex-shrink: 0;
}
.fh-verified-tick--sm {
  width: 15px !important;
  height: 15px !important;
  min-width: 15px;
  min-height: 15px;
}
.fh-verified-tick--sm svg {
  width: 15px !important;
  height: 15px !important;
}
#chat-display-name {
  overflow: visible;
}
.dm-thread-header .fh-verified-tick,
.dm-list-item .fh-verified-tick {
  margin-left: 2px;
}
.fh-verified-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.fh-verified-tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 7px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #1d4ed8;
  border: 1px solid #93c5fd;
  flex-shrink: 0;
}
.fh-staff-id-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px 2px 4px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #60a5fa;
  color: #1e40af;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
  max-width: 100%;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.12);
}
.fh-staff-id-badge__text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lc-avatar--staff {
  background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
  color: #fff !important;
  box-shadow: 0 0 0 2px #93c5fd;
}
.lc-agent-meta .fh-verified-tick {
  margin-left: 2px;
}
html[data-theme="dark"] .fh-verified-tag {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border-color: rgba(96, 165, 250, 0.4);
}
html[data-theme="dark"] .fh-staff-id-badge {
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.45), rgba(37, 99, 235, 0.35));
  border-color: rgba(96, 165, 250, 0.5);
  color: #bfdbfe;
  box-shadow: none;
}
