/* ============================================================
   SuperSimple V2 — Design System
   COSS Origin + shadcn-inspired
   ============================================================ */

/* ─── Reset & Base ──────────────────────────────────────────── */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Oxygen, Ubuntu, sans-serif;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img, video { display: block; max-width: 100%; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input, textarea { font: inherit; border: none; outline: none; background: none; }

/* ─── Theme: Dark (Admin) ───────────────────────────────────── */

:root,
[data-theme="dark"] {
  --bg:               #0a0a0b;
  --surface:          #141416;
  --surface-elevated: #1c1c1f;
  --surface-hover:    #222225;
  --border:           #2a2a2e;
  --border-subtle:    #1f1f23;

  --text-primary:     #e4e4e7;
  --text-secondary:   #71717a;
  --text-muted:       #52525b;
  --text-inverse:     #09090b;

  --accent:           #3b82f6;
  --accent-hover:     #2563eb;
  --accent-muted:     rgba(59, 130, 246, 0.12);
  --accent-text:      #93c5fd;

  --success:          #22c55e;
  --success-muted:    rgba(34, 197, 94, 0.12);
  --warning:          #f59e0b;
  --warning-muted:    rgba(245, 158, 11, 0.12);
  --danger:           #ef4444;
  --danger-hover:     #dc2626;
  --danger-muted:     rgba(239, 68, 68, 0.12);

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full: 9999px;

  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 0 1px var(--accent), 0 0 12px rgba(59, 130, 246, 0.25);

  --transition-fast:   120ms ease;
  --transition-base:   200ms ease;
  --transition-slow:   300ms cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-width:   250px;
  --ai-panel-width:  300px;

  --scrollbar-bg:    transparent;
  --scrollbar-thumb: #2a2a2e;
  --scrollbar-hover: #3f3f46;
}

/* ─── Theme: Light (Client) ─────────────────────────────────── */

[data-theme="light"],
.light-theme {
  --bg:               #f8fafc;
  --surface:          #ffffff;
  --surface-elevated: #ffffff;
  --surface-hover:    #f1f5f9;
  --border:           #e2e8f0;
  --border-subtle:    #f1f5f9;

  --text-primary:     #1e293b;
  --text-secondary:   #64748b;
  --text-muted:       #94a3b8;
  --text-inverse:     #ffffff;

  --accent:           #3b82f6;
  --accent-hover:     #2563eb;
  --accent-muted:     rgba(59, 130, 246, 0.08);
  --accent-text:      #2563eb;

  --success:          #22c55e;
  --success-muted:    rgba(34, 197, 94, 0.08);
  --warning:          #f59e0b;
  --warning-muted:    rgba(245, 158, 11, 0.08);
  --danger:           #ef4444;
  --danger-hover:     #dc2626;
  --danger-muted:     rgba(239, 68, 68, 0.08);

  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 0 1px var(--accent), 0 0 12px rgba(59, 130, 246, 0.15);

  --scrollbar-bg:    transparent;
  --scrollbar-thumb: #cbd5e1;
  --scrollbar-hover: #94a3b8;
}


/* ─── Scrollbar ─────────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-bg);
}


/* ============================================================
   LAYOUT
   ============================================================ */

/* ─── Admin 3-Column Layout ─────────────────────────────────── */

.app {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--transition-slow), width var(--transition-slow);
}

.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sidebar-search {
  padding: 8px 12px;
  flex-shrink: 0;
}

.sidebar-search .input {
  width: 100%;
  font-size: 13px;
}

.main-chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.ai-panel {
  width: var(--ai-panel-width);
  min-width: var(--ai-panel-width);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-slow), min-width var(--transition-slow),
              opacity var(--transition-base), transform var(--transition-slow);
}

.ai-panel.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
  pointer-events: none;
  border-left: none;
}

/* ─── Client Single-Column Layout ───────────────────────────── */

.client-app {
  width: 100vw;
  height: 100vh;
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.client-header {
  flex-shrink: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
}

.client-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.session-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}


/* ============================================================
   SIDEBAR — CLIENT LIST
   ============================================================ */

.client-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.client-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
  border-left: 2px solid transparent;
}

.client-item:hover {
  background: var(--surface-hover);
}

.client-item.active {
  background: var(--accent-muted);
  border-left-color: var(--accent);
}

.client-item-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--surface-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  position: relative;
}

.client-item-avatar img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.client-item-info {
  flex: 1;
  min-width: 0;
}

.client-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.client-item-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-top: 1px;
}

.client-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.client-item-time {
  font-size: 11px;
  color: var(--text-muted);
}

/* ─── Status Badge ──────────────────────────────────────────── */

.status-badge {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  display: inline-block;
  flex-shrink: 0;
}

.status-badge.online  { background: var(--success); box-shadow: 0 0 6px rgba(34, 197, 94, 0.4); }
.status-badge.idle    { background: var(--warning); box-shadow: 0 0 6px rgba(245, 158, 11, 0.3); }
.status-badge.offline { background: var(--text-muted); }

/* Status badge positioned on avatar */
.client-item-avatar .status-badge {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--surface);
}


/* ============================================================
   CHAT
   ============================================================ */

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ─── Chat Header ───────────────────────────────────────────── */

.chat-header {
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-header-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ─── Chat Messages ─────────────────────────────────────────── */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-messages-date {
  text-align: center;
  padding: 12px 0;
}

.chat-messages-date span {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

/* ─── Message Bubble ────────────────────────────────────────── */

.message {
  max-width: 65%;
  padding: 8px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  animation: messageIn var(--transition-slow) both;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.message.sent {
  align-self: flex-end;
  background: var(--accent);
  color: #ffffff;
  border-bottom-right-radius: var(--radius-sm);
}

.message.received {
  align-self: flex-start;
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: var(--radius-sm);
}

.message-time {
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.6;
}

.message.sent .message-time {
  text-align: right;
  color: rgba(255, 255, 255, 0.7);
}

.message.received .message-time {
  color: var(--text-muted);
}

/* ─── File Attachment in Message ─────────────────────────────── */

.message .file-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-top: 6px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.message.received .file-attachment {
  background: var(--surface-hover);
  border: 1px solid var(--border);
}

.message .file-attachment:hover {
  background: rgba(0, 0, 0, 0.15);
}

.file-attachment-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.message.received .file-attachment-icon {
  background: var(--accent-muted);
  color: var(--accent);
}

.file-attachment-info {
  flex: 1;
  min-width: 0;
}

.file-attachment-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-attachment-size {
  font-size: 11px;
  opacity: 0.6;
}

.file-attachment img {
  width: 100%;
  max-width: 240px;
  border-radius: var(--radius-md);
  margin-top: 6px;
}

/* ─── Typing Indicator ──────────────────────────────────────── */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  align-self: flex-start;
  flex-shrink: 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  animation: typingBounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.typing-indicator-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* ─── Chat Input ────────────────────────────────────────────── */

.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-input-area .input {
  flex: 1;
  min-width: 0;
}

.chat-input-area .btn,
.chat-input-area .btn-icon {
  flex-shrink: 0;
}

.chat-input {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 16px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.chat-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.chat-input-wrapper textarea {
  flex: 1;
  resize: none;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  max-height: 120px;
  min-height: 20px;
  padding: 4px 0;
}

.chat-input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.chat-input-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}


/* ============================================================
   CALL BAR & VIDEO
   ============================================================ */

.call-bar {
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideDown var(--transition-slow) both;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-100%); }
  to   { opacity: 1; transform: translateY(0); }
}

.call-bar-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.call-bar-timer {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.call-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.video-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 20px;
  background: #000;
}

.video-container.single {
  grid-template-columns: 1fr;
}

.video-feed {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  background: #18181b;
  object-fit: cover;
  border: 1px solid var(--border);
}

.video-feed.self {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 180px;
  z-index: 10;
  box-shadow: var(--shadow-lg);
}


/* ============================================================
   AI PANEL
   ============================================================ */

.ai-panel-header {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-panel-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-panel-header h3::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-message {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
}

.ai-message.suggestion {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.ai-message code {
  font-size: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

.ai-input {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-input .input-group {
  font-size: 13px;
}


/* ============================================================
   FILE UPLOAD
   ============================================================ */

.dropzone {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: pointer;
  transition: background var(--transition-base);
}

.dropzone.hidden {
  display: none !important;
}

.dropzone-content {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 64px;
  text-align: center;
  transition: border-color var(--transition-base), background var(--transition-base);
  color: var(--text-primary);
}

.dropzone-content p {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.dropzone:hover .dropzone-content,
.dropzone.dragover .dropzone-content {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.dropzone-icon {
  font-size: 28px;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.dropzone-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.dropzone-text strong {
  color: var(--accent);
}

.upload-progress {
  width: 100%;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--surface-elevated);
  overflow: hidden;
  margin-top: 8px;
}

.upload-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

.file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
}

.file-preview-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.file-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-preview-info {
  flex: 1;
  min-width: 0;
}

.file-preview-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-preview-size {
  font-size: 11px;
  color: var(--text-muted);
}

.file-preview-remove {
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.file-preview-remove:hover {
  color: var(--danger);
}


/* ============================================================
   NOTIFICATIONS
   ============================================================ */

.notification-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  background: var(--danger);
  border-radius: var(--radius-full);
  line-height: 1;
}

.notification-badge.small {
  min-width: 8px;
  height: 8px;
  padding: 0;
  font-size: 0;
}

/* ─── Toast ─────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text-primary);
  pointer-events: auto;
  animation: toastIn var(--transition-slow) both;
  max-width: 380px;
}

.toast.leaving {
  animation: toastOut var(--transition-base) both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(24px); }
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info    .toast-icon { color: var(--accent); }

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 13px;
}

.toast-message {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.toast-close {
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.toast-close:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}


/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Danger */
.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: var(--danger-hover);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* Icon button */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.btn-icon.active {
  background: var(--accent-muted);
  color: var(--accent);
}

.btn-icon.danger:hover {
  background: var(--danger-muted);
  color: var(--danger);
}

/* Small variant */
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-icon.btn-sm {
  width: 28px;
  height: 28px;
}


/* ============================================================
   FORM INPUTS
   ============================================================ */

.input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input::placeholder {
  color: var(--text-muted);
}

.input:hover {
  border-color: var(--text-muted);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
  outline: none;
}

.input-group {
  display: flex;
  align-items: center;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.input-group .input {
  border: none;
  background: none;
  box-shadow: none;
}

.input-group .input:focus {
  box-shadow: none;
}

.input-group-icon {
  padding: 0 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.input-group .btn {
  border-radius: 0;
  flex-shrink: 0;
}

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-group {
  margin-bottom: 16px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
}


/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}

.login-card-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-card-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.login-card-logo span {
  color: var(--accent);
}

.login-card-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.login-card .form-group:last-of-type {
  margin-bottom: 24px;
}

.login-card .btn-primary {
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}


/* ============================================================
   UTILITIES
   ============================================================ */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* ─── Focus States (keyboard nav) ───────────────────────────── */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:focus-visible,
.input:focus-visible {
  box-shadow: var(--shadow-glow);
}

/* ─── Selection ─────────────────────────────────────────────── */

::selection {
  background: rgba(59, 130, 246, 0.3);
  color: inherit;
}

/* ─── Placeholder empty state ───────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  flex: 1;
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.empty-state-text {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 280px;
}


/* ─── Notes Panel (overlay drawer) ─────────────────────────── */

.notes-panel {
  position: absolute;
  top: 56px;
  right: 0;
  width: 320px;
  max-width: 100%;
  bottom: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  box-shadow: var(--shadow-lg);
  animation: slideInRight var(--transition-slow) both;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.notes-header h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.notes-textarea {
  flex: 1;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--surface);
  border: none;
  resize: none;
}

.notes-textarea::placeholder {
  color: var(--text-muted);
}

.notes-panel .btn {
  margin: 0 16px 12px;
}

/* ─── Clipboard Panel ──────────────────────────────────────── */

.clipboard-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-elevated);
  flex-shrink: 0;
}

.clipboard-panel .input {
  flex: 1;
  min-width: 0;
}

.clipboard-panel .btn {
  flex-shrink: 0;
}

/* ─── Active Chat Layout ───────────────────────────────────── */

.active-chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ─── Join Screen (client) ─────────────────────────────────── */

.join-screen {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.join-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.join-card h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.join-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.join-card .input {
  margin-bottom: 16px;
}

.join-card .btn {
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
}

/* ─── Incoming Call ────────────────────────────────────────── */

.incoming-call {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--accent-muted);
  border-bottom: 1px solid var(--accent);
  flex-shrink: 0;
  animation: fadeInUp var(--transition-slow) both;
}

.incoming-call-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.incoming-call-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Call Bar ─────────────────────────────────────────────── */

.call-status {
  font-size: 13px;
  color: var(--text-secondary);
}

.local-video {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 160px;
  z-index: 10;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* ─── Empty State Large ────────────────────────────────────── */

.empty-state-large {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-large h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state-large p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ─── Modal ────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  padding: 20px;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-content h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.modal-large {
  max-width: 640px;
}

/* ─── History Item ─────────────────────────────────────────── */

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.history-item:hover {
  background: var(--surface-hover);
}

.history-item strong {
  font-size: 14px;
  color: var(--text-primary);
}

.history-item span {
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Quick Replies ────────────────────────────────────────── */

.quick-replies {
  padding: 4px 0;
}

/* ─── AI Panel Content ─────────────────────────────────────── */

.ai-panel-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.ai-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ai-input-area .input {
  flex: 1;
  min-width: 0;
}

.ai-input-area .btn {
  flex-shrink: 0;
}

.ai-welcome {
  padding: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.ai-settings {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-settings h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.ai-settings label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ─── Toggle Switch ────────────────────────────────────────── */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: var(--radius-full);
  transition: transform var(--transition-fast);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ─── Sidebar Section ──────────────────────────────────────── */

.sidebar-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ─── Badge ────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius-full);
  line-height: 1;
}

/* ─── Version Tag ──────────────────────────────────────────── */

.version {
  font-size: 10px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-left: 4px;
}

/* ─── Admin Info ───────────────────────────────────────────── */

.admin-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ─── Read Status ──────────────────────────────────────────── */

.read-status {
  font-size: 11px;
  opacity: 0.6;
  margin-left: 4px;
}

/* ─── System Message ───────────────────────────────────────── */

.message.system {
  align-self: center;
  max-width: none;
  background: none;
  border: none;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 12px;
}

/* ─── Chat Client Name/Status ──────────────────────────────── */

.chat-client-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-client-status {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ─── Dropzone subtitle ────────────────────────────────────── */

.dropzone-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── Upload progress inside dropzone ──────────────────────── */

.dropzone .upload-progress {
  margin-top: 16px;
}

.progress-bar {
  height: 4px;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
  .ai-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    opacity: 0;
  }

  .ai-panel.open {
    transform: translateX(0);
    opacity: 1;
  }

  .ai-panel.collapsed {
    transform: translateX(100%);
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-chat {
    width: 100vw;
  }

  .message {
    max-width: 85%;
  }

  .video-container {
    grid-template-columns: 1fr;
  }

  .video-feed.self {
    width: 120px;
  }

  .chat-header {
    padding: 0 12px;
  }

  .chat-messages {
    padding: 12px;
  }

  .chat-input {
    padding: 8px 12px 12px;
  }
}

/* Backdrop for mobile overlays */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.overlay-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}


/* ============================================================
   ANIMATIONS (general purpose)
   ============================================================ */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.animate-fade-in    { animation: fadeIn var(--transition-slow) both; }
.animate-fade-in-up { animation: fadeInUp var(--transition-slow) both; }
.animate-pulse      { animation: pulse 2s infinite; }
.animate-spin       { animation: spin 1s linear infinite; }


/* ============================================================
   SKELETON LOADING
   ============================================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-elevated) 25%,
    var(--surface-hover) 50%,
    var(--surface-elevated) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }

.skeleton-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
}


/* ============================================================
   NEON ICON BUTTONS
   ============================================================ */

.btn-icon-neon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon-neon:hover {
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.08);
}

.btn-icon-neon.active {
    color: #22c55e;
    border-color: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.08);
}

.btn-icon-neon.danger {
    color: #ef4444;
    border-color: #ef4444;
}

.btn-icon-neon.danger:hover {
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.1);
}

.btn-icon-neon.muted {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

/* Light theme overrides for neon buttons */
.light-theme .btn-icon-neon,
[data-theme="light"] .btn-icon-neon {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #64748b;
}

.light-theme .btn-icon-neon:hover,
[data-theme="light"] .btn-icon-neon:hover {
    color: #3b82f6;
    border-color: #3b82f6;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
    background: rgba(59, 130, 246, 0.05);
}


/* ============================================================
   AI MESSAGES
   ============================================================ */

.ai-message {
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.ai-message-user {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    text-align: right;
}

.ai-message-assistant {
    background: var(--surface-elevated);
    color: var(--text-primary);
}

.ai-message-error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Drag overlay for file upload */
.drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(59, 130, 246, 0.08);
    border: 2px dashed var(--accent);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(4px);
}

.drag-overlay-content {
    text-align: center;
    color: var(--accent);
}

.drag-overlay-content p {
    margin-top: 8px;
    font-size: 14px;
    font-weight: 500;
}

/* Inline upload progress */
.upload-inline-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(59, 130, 246, 0.06);
    border-radius: 8px;
    margin-bottom: 4px;
}

.upload-inline-bar {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.upload-inline-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.2s ease;
    width: 0%;
}

.upload-inline-text {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}
