/* ============================================================
   WEBBURNS CHAT — COMPONENTS
   Buttons, modals, avatars, toasts, forms, context menus
   ============================================================ */

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 600;
  transition: all var(--dur-normal) var(--ease-out);
  white-space: nowrap; position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 0; height: 0; background: rgba(255,255,255,0.15);
  border-radius: 50%; transform: translate(-50%,-50%);
  transition: width .4s ease, height .4s ease;
}
.btn:active::after { width: 300px; height: 300px; }

.btn-primary {
  background: var(--gradient-primary); color: #fff;
  box-shadow: 0 4px 15px rgba(102,126,234,0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 25px rgba(102,126,234,0.4); }

.btn-secondary {
  background: var(--color-base-600); color: var(--color-base-white);
  border: 1px solid var(--glass-border);
}
.btn-secondary:hover { background: var(--color-base-500); border-color: var(--glass-border-hover); }

.btn-danger { background: var(--gradient-danger); color: #fff; }
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(239,68,68,0.4); }

.btn-success { background: var(--gradient-success); color: #fff; }
.btn-ghost {
  background: transparent; color: var(--color-base-100);
  border: 1px solid var(--glass-border);
}
.btn-ghost:hover { background: var(--color-base-700); color: #fff; border-color: var(--glass-border-hover); }

.btn-sm { padding: 6px 14px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 28px; font-size: var(--text-base); border-radius: var(--radius-lg); }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: var(--radius-md); }
.btn-icon.sm { width: 32px; height: 32px; }

/* ── Form Inputs ───────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: var(--text-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--color-base-100);
}
.form-input {
  width: 100%; padding: 12px 14px;
  background: var(--color-base-700); border: 1px solid var(--glass-border);
  border-radius: var(--radius-md); font-size: var(--text-base);
  color: var(--color-base-white);
  transition: all var(--dur-normal) var(--ease-out);
}
.form-input::placeholder { color: var(--color-base-400); }
.form-input:focus {
  outline: none; border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(102,126,234,0.25);
}
.form-input.error { border-color: var(--color-danger); }
.form-error { font-size: var(--text-xs); color: var(--color-danger); margin-top: 4px; }
.form-hint { font-size: var(--text-xs); color: var(--color-base-400); margin-top: 4px; }

/* ── Avatar ────────────────────────────────────────────────── */
.avatar {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 700; color: #fff;
  background: var(--gradient-primary); flex-shrink: 0; overflow: hidden;
  position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.avatar.sm { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar.md { width: 40px; height: 40px; font-size: var(--text-sm); }
.avatar.lg { width: 56px; height: 56px; font-size: var(--text-lg); }
.avatar.xl { width: 80px; height: 80px; font-size: var(--text-2xl); }
.avatar .status-badge {
  position: absolute; bottom: 0; right: 0;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--color-base-800);
}
.avatar .status-badge.online { background: var(--color-success); box-shadow: 0 0 6px var(--color-success); }
.avatar .status-badge.idle { background: var(--color-warning); }
.avatar .status-badge.dnd { background: var(--color-danger); }
.avatar .status-badge.offline { background: var(--color-base-400); }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: var(--z-modal); opacity: 0; pointer-events: none;
  transition: opacity var(--dur-normal) var(--ease-out);
}
.modal-overlay.show { opacity: 1; pointer-events: all; }

.modal {
  background: var(--color-base-800);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 480px; max-height: 90vh;
  overflow-y: auto; margin: 16px;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--dur-slow) var(--ease-spring);
}
.modal-overlay.show .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 20px 24px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: var(--text-xl); font-weight: 700; }
.modal-close {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-base-200);
  transition: all var(--dur-fast) var(--ease-out);
}
.modal-close:hover { background: var(--color-base-600); color: #fff; }

.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px; display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--glass-border);
}

/* ── Toast Notifications ───────────────────────────────────── */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: all;
  padding: 14px 20px; border-radius: var(--radius-lg);
  background: var(--color-base-700);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 12px;
  animation: notifSlide var(--dur-slow) var(--ease-out);
  min-width: 300px; max-width: 420px;
  backdrop-filter: blur(20px);
}
.toast-icon { font-size: var(--text-lg); flex-shrink: 0; }
.toast-text { flex: 1; font-size: var(--text-sm); }
.toast-close { color: var(--color-base-200); cursor: pointer; flex-shrink: 0; }
.toast.success { border-color: rgba(16,185,129,0.3); }
.toast.success .toast-icon { color: var(--color-success); }
.toast.error { border-color: rgba(239,68,68,0.3); }
.toast.error .toast-icon { color: var(--color-danger); }
.toast.info .toast-icon { color: var(--color-info); }

/* ── Tooltip ───────────────────────────────────────────────── */
.tooltip {
  position: relative;
}
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: var(--color-base-900);
  color: var(--color-base-white);
  padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 600;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: all var(--dur-fast) var(--ease-out);
  box-shadow: var(--shadow-md);
  z-index: var(--z-tooltip);
}
.tooltip:hover::after { opacity: 1; transform: translateX(-50%) scale(1); }

/* ── Context Menu ──────────────────────────────────────────── */
.context-menu {
  position: fixed;
  background: var(--color-base-800);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px; min-width: 200px;
  z-index: var(--z-popover);
  animation: fadeInScale var(--dur-fast) var(--ease-out);
}

.context-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--color-base-100);
  cursor: pointer; transition: all var(--dur-fast) var(--ease-out);
}
.context-menu-item:hover { background: var(--accent-indigo); color: #fff; }
.context-menu-item.danger { color: var(--color-danger); }
.context-menu-item.danger:hover { background: var(--color-danger); color: #fff; }
.context-menu-item i { width: 20px; text-align: center; }
.context-menu-separator {
  height: 1px; background: var(--glass-border); margin: 4px 8px;
}

/* ── Badge ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 700;
  background: var(--color-danger); color: #fff;
}
.badge.success { background: var(--color-success); }
.badge.info { background: var(--color-info); }
.badge.warning { background: var(--color-warning); }

/* ── Loading Spinner ───────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--color-base-600);
  border-top-color: var(--accent-indigo);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
.spinner.lg { width: 40px; height: 40px; border-width: 3px; }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--glass-border); gap: 4px; }
.tab {
  padding: 10px 16px; font-size: var(--text-sm); font-weight: 600;
  color: var(--color-base-200); border-bottom: 2px solid transparent;
  transition: all var(--dur-fast) var(--ease-out); cursor: pointer;
}
.tab:hover { color: var(--color-base-white); }
.tab.active { color: var(--accent-indigo); border-bottom-color: var(--accent-indigo); }

/* ── Toggle / Switch ───────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--color-base-600); border-radius: var(--radius-full);
  transition: all var(--dur-normal) var(--ease-out);
}
.toggle-slider::before {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform var(--dur-normal) var(--ease-spring);
}
.toggle input:checked + .toggle-slider { background: var(--accent-indigo); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Divider ───────────────────────────────────────────────── */
.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0; color: var(--color-base-400); font-size: var(--text-xs); font-weight: 600;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--glass-border);
}

/* ── Emoji Picker ──────────────────────────────────────────── */
.emoji-picker-popup {
  position: absolute; bottom: calc(100% + 8px); right: 0;
  background: var(--color-base-800);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 320px; max-height: 340px;
  z-index: var(--z-dropdown);
  animation: fadeInUp var(--dur-fast) var(--ease-out);
  overflow: hidden;
}
.emoji-picker-search {
  padding: 10px; border-bottom: 1px solid var(--glass-border);
}
.emoji-picker-search input {
  width: 100%; padding: 8px 12px;
  background: var(--color-base-700);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--color-base-white); font-size: var(--text-sm);
  outline: none;
}
.emoji-picker-grid {
  padding: 8px; display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px; max-height: 260px; overflow-y: auto;
}
.emoji-picker-item {
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; width: 36px; height: 36px;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.emoji-picker-item:hover { background: var(--color-base-600); transform: scale(1.15); }
