@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ===================================================================
   DESIGN SYSTEM — WhatsCRM Professional
   =================================================================== */

:root {
  /* Backgrounds */
  --bg-dark: #000000;
  /* OLED Black */
  --bg-primary: #0F1115;
  /* Deep Gray */
  --bg-secondary: #161B22;
  /* Sidebar/Headers */
  --bg-tertiary: #21262D;
  /* Inputs/Active */
  --bg-surface: #161B22;
  --bg-hover: #30363D;
  --bg-active: #238636;
  /* GitHub-like active state */

  --chat-wallpaper-bg: #0D1117;
  --chat-wallpaper-pattern: url('/chat-wallpaper-doodle-dark.svg');
  --chat-wallpaper-repeat: repeat;
  --chat-wallpaper-size: 320px 320px;
  --chat-wallpaper-position: top left;

  /* Accent - High Contrast Blue/Green */
  --accent: #3B82F6;
  /* Primary Blue */
  --accent-hover: #60A5FA;
  --accent-muted: rgba(59, 130, 246, 0.15);
  --accent-dark: #2563EB;

  /* Function Colors */
  --cta: #F97316;
  /* Orange for Actions */

  /* Borders */
  --border: #30363D;
  --border-light: #21262D;

  /* Text */
  --text: #F0F6FC;
  /* High contrast white */
  --text-secondary: #8B949E;
  --text-muted: #6E7681;
  --text-on-accent: #FFFFFF;

  /* Bubbles */
  --bubble-in: #21262D;
  --bubble-out: #1F6FEB;
  /* GitHub Blue */

  /* Status */
  --danger: #DA3633;
  --danger-muted: rgba(218, 54, 51, 0.15);
  --warning: #D29922;
  --info: #388BFD;
  --success: #238636;

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 8px;
  /* Standard small */
  --radius-md: 12px;
  /* Standard medium */
  --radius-lg: 16px;
  --radius-xl: 32px;
  --radius-full: 9999px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.7);

  /* Layout */
  --topbar-height: 59px;
  --rail-width: 60px;
  /* Adjusted for icon strip */
  --sidebar-width: 400px;
  /* Wider sidebar like WhatsApp Web */
  --message-max-width-desktop: 83.2%;
  --message-max-width-mobile: 94%;
  --message-media-max-width-desktop: 83.2%;
  --message-media-max-width-mobile: 94%;
  --message-font-size: 14.1px;
  --message-line-height: 1.25;
  --message-meta-font-size: 11px;
  --messages-inline-padding: clamp(12px, 2.2vw, 28px);

  /* Motion */
  --transition-fast: 0.1s ease-out;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.3s ease;
}

/* ===================================================================
   LIGHT THEME
   =================================================================== */

[data-theme="light"] {
  /* Backgrounds */
  --bg-dark: #f6f1e7;
  --bg-primary: #fffaf1;
  --bg-secondary: #f9f3e7;
  --bg-tertiary: #efe5d5;
  --bg-surface: #f4ebdd;
  --bg-hover: #f0e7d8;
  --bg-active: #e6d9c3;
  --chat-wallpaper-bg: #fbf6ea;
  --chat-wallpaper-pattern: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPScyMjAnIGhlaWdodD0nMjIwJyB2aWV3Qm94PScwIDAgMjIwIDIyMCc+CiAgPGcgZmlsbD0nbm9uZScgc3Ryb2tlPScjN2FhZWE1JyBzdHJva2Utd2lkdGg9JzInIHN0cm9rZS1saW5lY2FwPSdyb3VuZCcgc3Ryb2tlLWxpbmVqb2luPSdyb3VuZCcgb3BhY2l0eT0nLjU4Jz4KICAgIDxwYXRoIGQ9J00xNiAyNmgzNGE4IDggMCAwIDEgOCA4djE0YTggOCAwIDAgMS04IDhIMzVsLTkgOXYtOUgxNmE4IDggMCAwIDEtOC04VjM0YTggOCAwIDAgMSA4LTh6Jy8+CiAgICA8cmVjdCB4PSc3NCcgeT0nMjQnIHdpZHRoPSczOCcgaGVpZ2h0PScyNicgcng9JzQnLz4KICAgIDxwYXRoIGQ9J003NCAyN2wxOSAxNCAxOS0xNCcvPgogICAgPHBhdGggZD0nTTE0MCA1MmMwLTggMTAtMTAgMTQtMyA0LTcgMTQtNSAxNCAzIDAgOS0xNCAxNy0xNCAxN3MtMTQtOC0xNC0xN3onLz4KICAgIDxwYXRoIGQ9J00xODYgMjhsMTggMTItMTggMTIgNC0xMnonLz4KICAgIDxwYXRoIGQ9J00yOCA5MmMwLTkgOC0xNiAxOC0xNiA4IDAgMTQgNSAxNCAxMiAwIDYtNCAxMC05IDEyLTUgMi01IDQtNSA5Jy8+CiAgICA8Y2lyY2xlIGN4PSc0NScgY3k9JzExOCcgcj0nMicvPgogICAgPHBhdGggZD0nTTgwIDc2bDE4IDE4TTk4IDc2TDgwIDk0Jy8+CiAgICA8Y2lyY2xlIGN4PScxMzInIGN5PSc5MCcgcj0nMTEnLz4KICAgIDxwYXRoIGQ9J00xMzIgNzl2MjJNMTIxIDkwaDIyJy8+CiAgICA8cGF0aCBkPSdNMTY0IDc2aDMwdjIwaC0zMHonLz4KICAgIDxwYXRoIGQ9J00xNjQgOTZsMTAtOCAxMCA4Jy8+CiAgICA8cGF0aCBkPSdNMTggMTQ2aDIwJy8+CiAgICA8cGF0aCBkPSdNMjggMTM2djIwJy8+CiAgICA8cGF0aCBkPSdNNTYgMTM2aDI4bC0xNCAxNnonLz4KICAgIDxwYXRoIGQ9J00xMDAgMTMybDggMTYgOC0xNicvPgogICAgPHBhdGggZD0nTTkyIDE0OGgzMicvPgogICAgPHBhdGggZD0nTTEzNiAxMzZoMzAnLz4KICAgIDxwYXRoIGQ9J00xNTEgMTM2djIwJy8+CiAgICA8Y2lyY2xlIGN4PScxODgnIGN5PScxNDgnIHI9JzEwJy8+CiAgICA8cGF0aCBkPSdNMTg0IDE0OGwzIDMgNi02Jy8+CiAgICA8cGF0aCBkPSdNMTQgMTg2aDM0YTggOCAwIDAgMSA4IDh2MTJhOCA4IDAgMCAxLTggOEgzMGwtOCA4di04SDE0YTggOCAwIDAgMS04LTh2LTEyYTggOCAwIDAgMSA4LTh6Jy8+CiAgICA8cGF0aCBkPSdNNzIgMTg4YzEyLTEwIDI0LTEwIDM2IDAnLz4KICAgIDxwYXRoIGQ9J004MCAyMDZjOC03IDE2LTcgMjQgMCcvPgogICAgPHBhdGggZD0nTTEzMiAxODRsMTQgMTAtMTQgMTAgMy0xMHonLz4KICAgIDxwYXRoIGQ9J00xNjIgMTg2aDM0Jy8+CiAgICA8cGF0aCBkPSdNMTYyIDIwNmgzNCcvPgogIDwvZz4KPC9zdmc+");
  --chat-wallpaper-repeat: repeat;
  --chat-wallpaper-size: 220px 220px;
  --chat-wallpaper-position: top left;

  /* Accent */
  --accent: #0b8f6a;
  --accent-hover: #0ea274;
  --accent-muted: rgba(11, 143, 106, 0.12);
  --accent-dark: #08785a;

  /* Borders */
  --border: #e6d8c1;
  --border-light: #d7c8ae;

  /* Text */
  --text: #2f2a22;
  --text-secondary: #6a5f4d;
  --text-muted: #9f927c;
  --text-on-accent: #ffffff;

  /* Bubbles */
  --bubble-in: #fffdf8;
  --bubble-out: #e6ecf4;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.12);
}

/* Light theme overrides for hardcoded dark colors */
[data-theme="light"] .login-view {
  background:
    radial-gradient(ellipse at 15% 50%, rgba(5, 150, 105, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 20%, rgba(59, 130, 246, 0.04) 0%, transparent 50%),
    var(--bg-dark);
}

[data-theme="light"] .login-error {
  color: #dc2626;
}

[data-theme="light"] .side-rail {
  background: linear-gradient(180deg, #fbf6ea 0%, #f3e9d8 100%);
}

[data-theme="light"] .side-rail-btn {
  color: #7f745f;
}

[data-theme="light"] .side-rail-btn:hover {
  background: rgba(11, 143, 106, 0.12);
  color: #0a6f54;
}

[data-theme="light"] .side-rail-btn.active {
  background: #dc2626;
  border-color: rgba(239, 68, 68, 0.4);
  color: #ffffff;
}

[data-theme="light"] .side-rail-badge {
  border-color: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .side-rail-foot {
  border-top-color: #e6d8c1;
}

[data-theme="light"] .side-rail-online {
  color: #059669;
}

[data-theme="light"] .side-rail-online span {
  background: #059669;
  box-shadow: 0 0 6px rgba(5, 150, 105, 0.5);
}

[data-theme="light"] .side-rail-user {
  color: #ffffff;
  border-color: rgba(59, 130, 246, 0.3);
  background: #2563eb;
}

[data-theme="light"] .chat-item {
  border-bottom-color: #efe4d2;
}

[data-theme="light"] .chat-item:hover {
  background: #f7efe1;
}

[data-theme="light"] .chat-item.active {
  background: #f2e7d4;
  border-left-color: var(--accent);
}

[data-theme="light"] .chat-time-unread {
  color: #16a34a;
}

[data-theme="light"] .chat-preview-unread {
  color: #2f2a22;
  font-weight: 500;
}

[data-theme="light"] .unread,
[data-theme="light"] .unread-whatsapp {
  background: #16a34a;
  color: #ffffff;
  border-color: rgba(22, 163, 74, 0.35);
  box-shadow: 0 1px 4px rgba(5, 150, 105, 0.25);
}

[data-theme="light"] .quick-filter-tab.active {
  background: rgba(11, 143, 106, 0.14);
  border-color: rgba(11, 143, 106, 0.35);
  color: #0a6f54;
}

[data-theme="light"] .workspace {
  background:
    radial-gradient(1200px 620px at 8% 10%, rgba(170, 138, 80, 0.08), transparent 58%),
    radial-gradient(1000px 540px at 92% 84%, rgba(11, 143, 106, 0.08), transparent 56%),
    linear-gradient(180deg, #faf4e8 0%, #f2e9da 100%);
}

[data-theme="light"] .chat-list-panel {
  background: #fffaf1;
  border-right-color: #e6d8c1;
}

[data-theme="light"] .sidebar-search {
  background: #fffaf1;
  border-bottom-color: #e6d8c1;
}

[data-theme="light"] .chat-list-title {
  color: #2f2a22;
}

[data-theme="light"] .quick-filter-tab {
  background: #f9f1e3;
  border-color: #dcccb1;
  color: #6a5f4d;
}

[data-theme="light"] .quick-filter-tab:hover {
  background: #f2e8d6;
  color: #2f2a22;
}

[data-theme="light"] .search-icon {
  color: #9f927c;
}

[data-theme="light"] .search-wrapper input {
  background: #f9f1e3;
  border-color: #dcccb1;
  color: #2f2a22;
}

[data-theme="light"] .search-wrapper input::placeholder {
  color: #9f927c;
}

[data-theme="light"] .chat-sort-control,
[data-theme="light"] .chat-simple-filter-btn {
  background: #f9f1e3;
  border-color: #dcccb1;
  color: #6a5f4d;
}

[data-theme="light"] .chat-simple-filter-btn:hover {
  background: #f2e8d6;
  color: #2f2a22;
}

[data-theme="light"] .chat-archive-row {
  background: #f9f1e3;
  color: #625745;
}

[data-theme="light"] .chat-archive-row:hover {
  background: #f2e8d6;
}

[data-theme="light"] .chat-archive-row.active,
[data-theme="light"] .chat-archive-count {
  color: #0a6f54;
}

[data-theme="light"] .conversation-panel {
  background: var(--chat-wallpaper-bg);
}

[data-theme="light"] .conversation-panel::before {
  display: none;
}

[data-theme="light"] .conversation-panel::after {
  display: none;
}

[data-theme="light"] .messages {
  background-color: var(--chat-wallpaper-bg);
  background-image: var(--chat-wallpaper-pattern);
  background-repeat: var(--chat-wallpaper-repeat, repeat);
  background-size: var(--chat-wallpaper-size, 220px 220px);
  background-position: var(--chat-wallpaper-position, top left);
}

[data-theme="light"] .contact-subtitle {
  color: #877b67;
}

[data-theme="light"] .contact-subtitle.typing-status {
  color: #0f8c4a;
}

[data-theme="light"] .chat-preview-typing {
  color: #0f8c4a;
}

[data-theme="light"] .typing-bubble {
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .typing-dot {
  background: #0f8c4a;
}

[data-theme="light"] .typing-bubble-label {
  color: #0f8c4a;
}

[data-theme="light"] .composer {
  background: #f7efdf;
  border-top-color: #e6d8c1;
}

[data-theme="light"] .composer-input-icon {
  color: #7f745f;
}

[data-theme="light"] .composer-input-icon:hover {
  background: rgba(106, 95, 77, 0.12);
  color: #2f2a22;
}

[data-theme="light"] .composer-input-attach {
  color: #7f745f;
}

[data-theme="light"] .message-input-shell {
  background: #fffaf1;
  border-color: #dcccb1;
}

[data-theme="light"] .composer-main textarea {
  background: transparent;
  border-color: transparent;
  color: #2f2a22;
}

[data-theme="light"] .message-input-shell:focus-within {
  border-color: #c2b292;
  box-shadow: 0 0 0 2px rgba(167, 145, 109, 0.2);
}

[data-theme="light"] .attachment-preview-title {
  color: #625745;
}

[data-theme="light"] .attachment-preview-stage {
  border-color: #dcccb1;
  background: #f8efde;
}

[data-theme="light"] .attachment-preview-image,
[data-theme="light"] .attachment-preview-video {
  background: #e9dcc5;
}

[data-theme="light"] .attachment-preview-file {
  color: #2f2a22;
}

[data-theme="light"] .message-row.incoming .message-bubble {
  background: var(--bubble-in);
  color: #2f2a22;
  border: 1px solid #e5d7c0;
}

[data-theme="light"] .message-row.outgoing .message-bubble {
  background: linear-gradient(145deg, #d7f1ea 0%, #cfe8ec 58%, #c8deee 100%);
  color: #203447;
  border: 1px solid #bdd2df;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 1px 2px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .message-link {
  color: #1d4ed8;
}

[data-theme="light"] .message-link:hover {
  color: #1e40af;
}

[data-theme="light"] .wa-link-preview-card {
  background: #f8f5ed;
  border-color: #dfd2bc;
}

[data-theme="light"] .wa-link-preview-card:hover {
  border-color: #9cb8de;
}

[data-theme="light"] .wa-link-preview-thumb {
  background: #f0e6d6;
  border-right-color: #dfd2bc;
}

[data-theme="light"] .wa-link-preview-title {
  color: #2f2a22;
}

[data-theme="light"] .wa-link-preview-desc {
  color: #625745;
}

[data-theme="light"] .wa-link-preview-domain {
  color: #8a7d67;
}

[data-theme="light"] .message-row.outgoing .message-time {
  color: #64748b;
}

[data-theme="light"] .message-row.outgoing .message-edited {
  color: #64748b;
}

[data-theme="light"] .message-time {
  color: rgba(71, 61, 47, 0.62);
}

[data-theme="light"] .message-date-divider span {
  background: rgba(248, 245, 237, 0.96);
  color: #625745;
  border: 1px solid #dfd2bc;
  box-shadow: 0 1px 2px rgba(74, 62, 45, 0.1);
}

[data-theme="light"] .message-edited {
  color: #877b67;
}

[data-theme="light"] .msg-ticks-sent {
  color: rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .msg-ticks-delivered {
  color: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .msg-ticks-read {
  color: #2563eb;
}

[data-theme="light"] .msg-ticks-failed {
  color: #dc2626;
}

[data-theme="light"] .message-action-button {
  background: rgba(50, 50, 50, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .message-action-button:hover {
  background: rgba(20, 20, 20, 0.95);
}

[data-theme="light"] .message-action-menu {
  background: #fffaf1;
  border-color: #e6d8c1;
  box-shadow: var(--shadow-lg);
}

[data-theme="light"] .message-action-menu button {
  color: #625745;
}

[data-theme="light"] .message-action-menu button:hover {
  background: #f4ead8;
}

[data-theme="light"] .message-action-menu button.message-menu-danger {
  color: #dc2626;
}

[data-theme="light"] .message-reaction-picker {
  background: #fffaf1;
  border-color: #e6d8c1;
  box-shadow: var(--shadow-md);
}

[data-theme="light"] .message-reaction-picker button:hover {
  background: #f4ead8;
}

[data-theme="light"] .message-reaction-chip {
  border-color: #e6d8c1;
  background: #fffaf1;
  color: #2f2a22;
}

[data-theme="light"] .message-reaction-chip.mine {
  border-color: rgba(5, 150, 105, 0.4);
  background: rgba(5, 150, 105, 0.08);
}

[data-theme="light"] .message-reaction-count {
  color: #475569;
}

[data-theme="light"] .message-reply-ref {
  border-left-color: rgba(37, 99, 235, 0.6);
  background: rgba(241, 245, 249, 0.8);
}

[data-theme="light"] .message-reply-label {
  color: #1d4ed8;
}

[data-theme="light"] .message-reply-text {
  color: #475569;
}

[data-theme="light"] .reply-preview {
  border-color: rgba(37, 99, 235, 0.3);
  background: #f0f9ff;
}

[data-theme="light"] .reply-preview-body strong {
  color: #1d4ed8;
}

[data-theme="light"] .reply-preview-body span {
  color: #334155;
}

[data-theme="light"] .reply-preview-close {
  border-color: #cbd5e1;
  background: #ffffff;
  color: #475569;
}

[data-theme="light"] .recording-bar {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .recording-timer-wrap {
  color: #1e293b;
}

[data-theme="light"] .recording-wave {
  background: #94a3b8;
}

[data-theme="light"] .recording-action {
  background: #f8f9fa;
  border-color: #e2e8f0;
  color: #475569;
}

[data-theme="light"] .recording-action:hover {
  background: #e9ecef;
  color: #1e293b;
}

[data-theme="light"] .recording-action.recording-send {
  color: #059669;
  border-color: rgba(5, 150, 105, 0.35);
  background: rgba(5, 150, 105, 0.08);
}

[data-theme="light"] .recording-action.recording-send:hover {
  color: #047857;
  background: rgba(5, 150, 105, 0.15);
}

[data-theme="light"] .recording-action.recording-danger {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.06);
}

[data-theme="light"] .recording-action.recording-danger:hover {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.12);
}

[data-theme="light"] .wa-audio-player {
  background: transparent;
}

[data-theme="light"] .wa-audio-toggle {
  background: rgba(0, 0, 0, 0.06);
  color: #334155;
}

[data-theme="light"] .wa-audio-toggle:hover {
  background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .wa-audio-avatar {
  border-color: rgba(15, 23, 42, 0.14);
  color: #f8fafc;
}

[data-theme="light"] .wa-audio-speed {
  background: rgba(0, 0, 0, 0.06);
  color: #334155;
}

[data-theme="light"] .wa-audio-speed:hover {
  background: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .wa-audio-bar {
  background: rgba(0, 0, 0, 0.18);
}

[data-theme="light"] .wa-audio-bar.active {
  background: #2563eb;
}

[data-theme="light"] .wa-audio-meta {
  color: #64748b;
}

[data-theme="light"] .wa-audio-dot {
  background: #2563eb;
}

[data-theme="light"] .wa-media-card {
  background: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .wa-media-image-card {
  background: transparent;
  border: none;
}

[data-theme="light"] .message-row.outgoing .wa-media-card {
  border-color: rgba(5, 150, 105, 0.35);
  box-shadow: 0 0 0 1px rgba(5, 150, 105, 0.1);
}

[data-theme="light"] .message-row.outgoing .wa-media-image-card {
  border: none;
  box-shadow: none;
}

[data-theme="light"] .wa-media-image,
[data-theme="light"] .wa-media-video {
  background: #f1f5f9;
}

[data-theme="light"] .wa-media-image {
  background: transparent;
}

[data-theme="light"] .presence-chip-online {
  background: rgba(5, 150, 105, 0.1);
  border-color: rgba(5, 150, 105, 0.3);
  color: #047857;
}

[data-theme="light"] .presence-chip-offline {
  background: rgba(100, 116, 139, 0.08);
  border-color: rgba(100, 116, 139, 0.25);
  color: #64748b;
}

[data-theme="light"] .presence-item.presence-online .presence-badge {
  color: #047857;
  border-color: rgba(5, 150, 105, 0.3);
  background: rgba(5, 150, 105, 0.08);
}

[data-theme="light"] .presence-item.presence-offline .presence-badge {
  color: #64748b;
  border-color: rgba(100, 116, 139, 0.25);
  background: rgba(100, 116, 139, 0.06);
}

[data-theme="light"] .bot-workspace-tab {
  background: #ffffff;
  border-color: #dbe4ee;
  color: #475569;
}

[data-theme="light"] .bot-workspace-tab.active {
  color: #047857;
  border-color: rgba(5, 150, 105, 0.4);
  background: rgba(5, 150, 105, 0.08);
}

[data-theme="light"] .bot-agent-card {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .bot-agent-name {
  color: #0f172a;
}

[data-theme="light"] .bot-agent-subtitle {
  color: #475569;
}

[data-theme="light"] .bot-agent-status.online {
  color: #047857;
  border-color: rgba(5, 150, 105, 0.35);
  background: rgba(5, 150, 105, 0.08);
}

[data-theme="light"] .bot-agent-status.offline {
  color: #64748b;
  border-color: rgba(100, 116, 139, 0.28);
  background: rgba(100, 116, 139, 0.07);
}

[data-theme="light"] .tag-status-open {
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
}

[data-theme="light"] .tag-status-pending {
  background: rgba(217, 119, 6, 0.08);
  color: #b45309;
}

[data-theme="light"] .tag-status-resolved {
  background: rgba(5, 150, 105, 0.08);
  color: #047857;
}

[data-theme="light"] .danger {
  background: rgba(220, 38, 38, 0.06);
  border-color: rgba(220, 38, 38, 0.2);
  color: #dc2626;
}

[data-theme="light"] .danger:hover {
  background: rgba(220, 38, 38, 0.12);
}

[data-theme="light"] .seed-password {
  background: rgba(5, 150, 105, 0.08);
  border-color: rgba(5, 150, 105, 0.25);
  color: #047857;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

[data-theme="light"] .message-file {
  border-color: #e2e8f0;
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .message-pdf-card {
  border-color: #d7e0ea;
  background: linear-gradient(164deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .message-pdf-preview {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
  border-bottom-color: #c7d2e0;
}

[data-theme="light"] .message-pdf-preview::after {
  background:
    radial-gradient(circle at 85% 24%, rgba(255, 255, 255, 0.35) 0%, transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(248, 250, 252, 0.2) 100%);
}

[data-theme="light"] .message-pdf-preview-placeholder {
  color: #475569;
}

[data-theme="light"] .message-pdf-name {
  color: #0f172a;
}

[data-theme="light"] .message-pdf-meta {
  color: #475569;
}

[data-theme="light"] .message-pdf-actions {
  border-top-color: #dbe4ef;
}

[data-theme="light"] .message-pdf-open {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #334155;
}

[data-theme="light"] .message-pdf-open:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

[data-theme="light"] .message-pdf-download {
  border-color: rgba(5, 150, 105, 0.32);
  background: rgba(5, 150, 105, 0.1);
  color: #047857;
}

[data-theme="light"] .message-pdf-download:hover {
  background: rgba(5, 150, 105, 0.16);
  border-color: rgba(5, 150, 105, 0.45);
  color: #065f46;
}

[data-theme="light"] .message-row.outgoing .message-pdf-card {
  border-color: #b8d7d0;
  background: #e4f3f0;
}

[data-theme="light"] .message-row.outgoing .message-pdf-meta {
  color: #334155;
}

[data-theme="light"] .delete-message-modal,
[data-theme="light"] .edit-message-modal {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .delete-message-modal h3,
[data-theme="light"] .edit-message-modal h3 {
  color: #0f172a;
}

[data-theme="light"] .edit-message-input {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

[data-theme="light"] .delete-message-cancel,
[data-theme="light"] .edit-message-cancel {
  color: #059669;
}

[data-theme="light"] .delete-message-me,
[data-theme="light"] .edit-message-save {
  background: #059669;
  color: #ffffff;
}

/* Theme Toggle Button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  padding: 0;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon,
:root:not([data-theme="light"]) .theme-toggle .icon-moon {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: none;
}

/* ===================================================================
   RESET
   =================================================================== */

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

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: 'Fira Code', monospace;
  font-weight: 600;
  letter-spacing: -0.5px;
}

/* ===================================================================
   CUSTOM SCROLLBAR
   =================================================================== */

::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}

/* ===================================================================
   UTILITY
   =================================================================== */

.hidden {
  display: none !important;
}

.management-open {
  overflow: hidden;
}

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

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
  font-size: 13px;
  line-height: 1.6;
}

/* ===================================================================
   GLOBAL FORM CONTROLS
   =================================================================== */

input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text);
  background: var(--bg-tertiary);
  outline: none;
  transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

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

textarea {
  resize: none;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group>label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  background: var(--cta);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-light);
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  padding: 0;
  flex-shrink: 0;
}

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

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

.btn-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: #00a884;
  color: #0b141a;
  padding: 0;
  flex-shrink: 0;
}

.btn-send:hover {
  background: #01c79d;
  transform: none;
  box-shadow: none;
}

.danger {
  background: var(--danger-muted);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

.danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

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

.layout-root {
  height: 100%;
  position: relative;
}

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

.login-view {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at 15% 50%, rgba(16, 185, 129, 0.07) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
    var(--bg-dark);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 20px;
  background: transparent;
  border: none;
  box-shadow: none;
}

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

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-lg);
  background: var(--accent-muted);
  color: var(--accent);
  margin-bottom: 16px;
}

.login-brand h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form input {
  padding: 11px 14px;
  font-size: 14px;
}

.login-form .btn-primary {
  margin-top: 8px;
}

.seed-help {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.seed-label {
  font-size: 11px;
  color: var(--text-muted);
  width: 100%;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.seed-item {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.seed-password {
  background: var(--accent-muted);
  border-color: rgba(16, 185, 129, 0.25);
  color: var(--accent);
  font-weight: 500;
}

.login-error {
  margin-top: 12px;
  font-size: 13px;
  color: #fca5a5;
  min-height: 18px;
  text-align: center;
}

/* ===================================================================
   APP SHELL
   =================================================================== */

.app-shell {
  height: 100%;
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  grid-template-rows: 1fr;
  grid-template-areas:
    "rail workspace";
  background: var(--bg-dark);
}

.side-rail {
  grid-area: rail;
  border-right: 1px solid var(--border);
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
}

.side-rail-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.side-rail-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  position: relative;
}

.side-rail-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  transform: none;
}

.side-rail-btn.active {
  background: var(--bg-tertiary);
  /* Active state in WA web is subtle or icon color change */
  color: var(--accent);
  box-shadow: none;
}

.side-rail-btn.active:hover {
  transform: none;
}

.side-rail-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  background: #ef4444;
  color: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.95);
}

.side-rail-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  width: 100%;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.side-rail-online {
  font-size: 9px;
  font-weight: 600;
  color: #86efac;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  line-height: 1;
}

.side-rail-online span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.65);
}

.side-rail-online strong {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1px;
}

.side-rail-user {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #2563eb;
  flex-shrink: 0;
}

.side-rail-btn-ghost {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
}

/* ===================================================================
   TOP BAR
   =================================================================== */

.app-topbar {
  grid-area: topbar;
  display: none;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: var(--accent-muted);
  color: var(--accent);
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.topbar-center {
  flex: 1;
  max-width: 260px;
  margin: 0 24px;
}

.instance-select {
  width: 100%;
  font-size: 13px;
  background: var(--bg-secondary);
}

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

.user-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  padding: 0;
}

.topbar-btn:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

.topbar-btn-text {
  width: auto;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
}

/* ===================================================================
   WORKSPACE
   =================================================================== */

.workspace {
  grid-area: workspace;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  flex: 1;
  min-height: 0;
  position: relative;
  background:
    radial-gradient(1200px 620px at 8% 12%, rgba(148, 163, 184, 0.08), transparent 58%),
    radial-gradient(1000px 540px at 92% 86%, rgba(100, 116, 139, 0.06), transparent 56%),
    linear-gradient(180deg, #20252b 0%, #1b2025 100%);
}

/* ===================================================================
   SIDEBAR
   =================================================================== */

.chat-list-panel {
  background: var(--bg-primary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-search {
  padding: 12px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 4;
}

.chat-list-title {
  margin: 0;
  padding: 0 2px;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 700;
  color: #e9edef;
}

.quick-filter-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 0;
  overflow-x: auto;
}

.quick-filter-tab {
  padding: 6px 13px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition-fast);
  min-height: 34px;
  white-space: nowrap;
}

.quick-filter-tab:hover {
  background: var(--bg-tertiary);
  color: #e9edef;
  transform: none;
}

.quick-filter-tab.active {
  background: #2f7bfd;
  border-color: #2f7bfd;
  color: #ffffff;
  box-shadow: none;
}

.search-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #8796a1;
  pointer-events: none;
}

.search-wrapper input {
  padding: 10px 12px 10px 34px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 14px;
  color: #e9edef;
}

.search-wrapper input::placeholder {
  color: #8696a0;
}

.chat-list-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-sort-control {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 7px;
  color: #d4dde2;
  font-size: 12.5px;
  padding: 6px 9px;
  min-height: 32px;
}

.chat-simple-filter-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: #b7c3ca;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.chat-simple-filter-btn:hover {
  background: var(--bg-tertiary);
  color: #e9edef;
}

.chat-simple-filter-btn.active {
  background: rgba(47, 123, 253, 0.22);
  border-color: rgba(47, 123, 253, 0.65);
  color: #9ec4ff;
}

.chat-promo-card {
  position: relative;
  border: 1px solid #2b3a43;
  border-radius: 10px;
  background: #1c2429;
  padding: 10px 12px 10px;
  color: #dbe4e8;
}

.chat-promo-card h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: #f2f6f8;
}

.chat-promo-card p {
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 1.35;
  color: #c9d4d9;
}

.chat-promo-link {
  color: #3ddc84;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.chat-promo-link:hover {
  text-decoration: underline;
}

.chat-promo-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #98a8b1;
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.chat-promo-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e9edef;
}

.chat-archive-row {
  width: 100%;
  border: none;
  border-radius: 8px;
  background: var(--bg-primary);
  color: #d2dbe0;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px;
  font-size: 14px;
  font-weight: 600;
}

.chat-archive-row:hover {
  background: var(--bg-hover);
}

.chat-archive-row.active {
  color: #84b2ff;
}

.chat-archive-count {
  font-size: 13px;
  color: #84b2ff;
}

.category-filter {
  display: none;
}

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

.chat-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  background: var(--bg-primary);
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  height: 62px;
  cursor: pointer;
  border-bottom: none;
  transition: background var(--transition-fast);
  border-left: none;
}

.chat-item:hover {
  background: var(--bg-hover);
}

.chat-item.active {
  background: var(--bg-active);
}

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

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-avatar {
  width: 38px;
  height: 38px;
  font-size: 13px;
}

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

.chat-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chat-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.chat-name {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.chat-main-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  flex-shrink: 0;
}

.chat-time {
  font-size: 11px;
  color: #8696a0;
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-time-unread {
  color: #25d366;
  font-weight: 600;
}

.chat-preview {
  font-size: 13px;
  color: #aebac1;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.chat-preview-unread {
  color: #e9edef;
  font-weight: 500;
}

.chat-preview-typing {
  color: #25d366;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.chat-meta {
  margin-top: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.chat-meta:empty {
  display: none;
  margin-top: 0;
}

.chat-meta .tag,
.chat-meta .tag-status {
  display: none;
}

/* ===================================================================
   TAGS & BADGES
   =================================================================== */

.tag {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.tag-status {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border: none;
}

.tag-status-open {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.tag-status-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.tag-status-resolved {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.unread {
  font-size: 12px;
  font-weight: 700;
  border-radius: var(--radius-full);
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dc2626;
  color: #ffffff;
  border: 1px solid rgba(220, 38, 38, 0.42);
  box-shadow: none;
}

.unread-whatsapp {
  background: #dc2626;
  color: #ffffff;
  border-color: rgba(220, 38, 38, 0.42);
}

/* ===================================================================
   CONVERSATION PANEL
   =================================================================== */

.conversation-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--chat-wallpaper-bg);
  position: relative;
}

.conversation-panel::before {
  display: none;
}

.conversation-panel::after {
  display: none;
}

.conversation-header {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 60px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

[data-theme="dark"] .conversation-header {
  background: var(--bg-secondary);
}

.conversation-contact {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.conversation-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-back-btn {
  display: none;
}

.contact-info {
  min-width: 0;
}

.contact-info h3 {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.contact-subtitle {
  font-size: 12px;
  color: #aebac1;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-subtitle.typing-status {
  color: #25d366;
  font-weight: 700;
}

/* --- Typing bubble in messages area --- */

.typing-bubble-row {
  display: flex;
  justify-content: flex-start;
  padding: 2px var(--messages-inline-padding) 6px 0;
  animation: typingFadeIn 0.25s ease;
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #202c33;
  border-radius: 0 8px 8px 8px;
  padding: 10px 14px;
  max-width: 180px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.13);
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #25d366;
  display: inline-block;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

.typing-bubble-label {
  color: #25d366;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

@keyframes typingBounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }

  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

@keyframes typingFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.messages {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  padding: 10px var(--messages-inline-padding) 4px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background-color: var(--chat-wallpaper-bg);
  background-image: var(--chat-wallpaper-pattern);
  background-repeat: var(--chat-wallpaper-repeat, repeat);
  background-size: var(--chat-wallpaper-size, 220px 220px);
  background-position: var(--chat-wallpaper-position, center);
}

.message-row {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: flex-end;
  gap: 3px;
  margin-top: 10px;
  flex: 0 0 auto;
  overflow: visible;
}

.message-row:first-child {
  margin-top: 0 !important;
}

.message-row.grouped {
  margin-top: 2px;
}

.message-row.group-start {
  margin-top: 10px;
}

.message-row.incoming {
  justify-content: flex-start;
}

.message-row.outgoing {
  justify-content: flex-end;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  overflow: hidden;
  color: #e9edef;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.message-row.outgoing .message-avatar {
  display: none;
}

.message-avatar-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.message-bubble {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  width: auto;
  min-width: 0;
  max-width: var(--message-max-width-desktop);
  max-inline-size: 100%;
  min-width: 53px;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: var(--message-font-size);
  line-height: var(--message-line-height);
  overflow-wrap: anywhere;
  word-break: normal;
}

.message-bubble.media-only {
  width: fit-content;
  min-width: 0;
  background: transparent !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  max-width: min(var(--message-media-max-width-desktop), 100%);
}

.message-row.outgoing .message-bubble.media-only {
  align-items: flex-end;
}

.message-bubble>* {
  min-width: 0;
  max-width: 100%;
}

.message-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: auto;
  max-width: min(var(--message-max-width-desktop), 100%);
  min-width: 0;
  flex: 0 1 auto;
}

.message-stack.media-stack {
  width: fit-content;
  max-width: min(var(--message-media-max-width-desktop), 100%);
}

.message-row.outgoing .message-stack {
  margin-left: auto;
  margin-right: 0;
  align-items: flex-end;
}

.message-row.incoming .message-stack {
  margin-right: auto;
}

.message-row.incoming .message-bubble {
  background: var(--bubble-in);
  color: var(--text);
  border-radius: 6px;
  border-top-left-radius: 2px;
}

.message-row.outgoing .message-bubble {
  background: linear-gradient(145deg, #0c7c74 0%, #0b6f78 55%, #0a5f79 100%);
  color: var(--text);
  border: 1px solid rgba(157, 236, 223, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.22);
  border-radius: 6px;
  border-top-right-radius: 2px;
}

.message-mini-head {
  align-self: flex-start;
  margin-bottom: 3px;
  font-size: 9px;
  line-height: 1.2;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.2px;
  display: block;
}

.message-row.outgoing .message-mini-head {
  align-self: flex-end;
  text-align: right;
}

.message-reply-ref {
  margin: 0 0 6px;
  padding: 5px 8px;
  border-left: 3px solid rgba(56, 189, 248, 0.8);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.35);
  display: grid;
  gap: 2px;
  min-width: 0;
}

.message-reply-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(191, 219, 254, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.message-reply-text {
  font-size: 12px;
  color: rgba(226, 232, 240, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-action-shell {
  position: absolute;
  top: 50%;
  right: -63px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  z-index: 9;
  pointer-events: auto;
}

.message-action-button {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(17, 24, 39, 0.88);
  border-radius: 999px;
  background: rgba(7, 9, 14, 0.9);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.message-action-button svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message-row:hover .message-action-button,
.message-bubble:hover .message-action-button,
.message-action-shell:hover .message-action-button,
.message-action-shell.open .message-action-button {
  opacity: 1;
  pointer-events: auto;
}

.message-action-button:hover {
  background: rgba(2, 6, 23, 0.98);
  transform: translateY(-1px);
}

.message-row.outgoing .message-action-shell {
  right: auto;
  left: -63px;
}

.message-action-button:focus-visible {
  outline: 1px solid rgba(45, 212, 191, 0.9);
  outline-offset: 1px;
}

.message-action-menu {
  margin-top: 4px;
  min-width: 180px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  background: rgba(8, 13, 23, 0.98);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: menuFadeIn 0.15s ease;
}

.message-action-shell.menu-open-up .message-action-menu {
  position: absolute;
  right: 0;
  bottom: 100%;
  margin-top: 0;
  margin-bottom: 4px;
  animation-name: menuFadeInUp;
}

@keyframes menuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes menuFadeInUp {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-action-menu button {
  border: none;
  background: transparent;
  color: #dbeafe;
  border-radius: var(--radius-md);
  text-align: left;
  padding: 8px 12px;
  font-size: 13px;
  transition: background var(--transition-fast);
}

.message-action-menu button:hover {
  background: rgba(30, 41, 59, 0.7);
}

.message-action-menu button.message-menu-danger {
  color: #fecaca;
}

.message-reaction-picker {
  margin-top: 6px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.96);
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.message-reaction-picker button {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: transparent;
  font-size: 18px;
  line-height: 1;
}

.message-reaction-picker button:hover {
  background: rgba(30, 41, 59, 0.65);
}

.message-action-trigger,
.message-action-menu,
.message-reaction-picker {
  display: none !important;
}

.message-reactions {
  margin-top: 3px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.message-reaction-chip {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  color: #e2e8f0;
  padding: 2px 7px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}

.message-reaction-chip.mine {
  border-color: rgba(45, 212, 191, 0.8);
  background: rgba(15, 118, 110, 0.25);
}

.message-reaction-count {
  font-size: 11px;
  font-weight: 700;
  color: rgba(226, 232, 240, 0.82);
}

.message-meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 0;
  margin-top: 1px;
  white-space: nowrap;
  vertical-align: bottom;
  position: relative;
  align-self: flex-end;
}

.message-date-divider {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 8px 0 10px;
  pointer-events: none;
}

.message-date-divider span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 12px;
  border-radius: 8px;
  background: rgba(32, 44, 51, 0.92);
  color: #cfd8df;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.message-time {
  display: inline;
  font-size: var(--message-meta-font-size);
  color: #8696a0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.message-edited {
  display: inline;
  font-size: 10px;
  color: #8696a0;
  white-space: nowrap;
}

.msg-ticks {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  margin-left: 1px;
  transform: translateY(0.2px);
  color: #aebac1;
}

.msg-ticks-icon {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.msg-ticks-icon-single {
  width: 11px;
  height: 9px;
}

.msg-ticks-icon-double {
  width: 14px;
  height: 9px;
}

.msg-ticks-sent {
  color: rgba(255, 255, 255, 0.5);
}

.msg-ticks-delivered {
  color: rgba(255, 255, 255, 0.7);
}

.msg-ticks-read {
  color: #53bdeb;
}

.msg-ticks-failed {
  display: inline;
  transform: none;
  color: #fb7185;
  letter-spacing: 0;
  font-size: 8.8px;
}

.msg-ticks.compact {
  margin-left: 2px;
}

.msg-ticks.compact .msg-ticks-icon-single {
  width: 10px;
  height: 8px;
}

.msg-ticks.compact .msg-ticks-icon-double {
  width: 12px;
  height: 8px;
}

.message-text {
  display: block;
  max-width: 100%;
  font-size: var(--message-font-size);
  line-height: var(--message-line-height);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.message-link {
  color: #8ad0ff;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}

.message-link:hover {
  color: #b5e2ff;
}

.wa-link-preview-list {
  margin-top: 6px;
  display: grid;
  gap: 6px;
  width: min(100%, 360px);
  max-width: 100%;
}

.wa-link-preview-shell {
  width: 100%;
  min-width: 0;
}

.wa-link-preview-card {
  width: 100%;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(2, 6, 23, 0.55);
  text-decoration: none;
  color: inherit;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  overflow: hidden;
}

.wa-link-preview-card:hover {
  border-color: rgba(56, 189, 248, 0.5);
}

.wa-link-preview-thumb {
  width: 86px;
  min-height: 86px;
  background: #0b1520;
  border-right: 1px solid rgba(148, 163, 184, 0.22);
}

.wa-link-preview-thumb img {
  width: 100%;
  height: 100%;
  min-height: 86px;
  display: block;
  object-fit: cover;
}

.wa-link-preview-body {
  min-width: 0;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}

.wa-link-preview-title {
  font-size: 12px;
  line-height: 1.25;
  color: #f8fafc;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wa-link-preview-desc {
  font-size: 11px;
  line-height: 1.25;
  color: rgba(226, 232, 240, 0.82);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wa-link-preview-domain {
  font-size: 10px;
  line-height: 1.2;
  color: rgba(148, 163, 184, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===================================================================
   COMPOSER
   =================================================================== */

.composer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  overflow: visible;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.quick-reply-select {
  width: 180px;
  font-size: 12px;
  padding: 6px 8px;
}

.reply-preview {
  border: 1px solid rgba(56, 189, 248, 0.4);
  background: rgba(15, 23, 42, 0.75);
  border-radius: var(--radius-md);
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reply-preview-body {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.reply-preview-body strong {
  font-size: 11px;
  color: #93c5fd;
}

.reply-preview-body span {
  font-size: 12px;
  color: #dbeafe;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview-close {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.6);
  color: #dbeafe;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

.composer-main {
  display: flex;
  align-items: center;
  gap: 6px;
}

.message-input-shell {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  border-radius: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.composer-input-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #8696a0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 0;
  z-index: 1;
}

.composer-input-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.composer-input-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e9edef;
}

.composer-input-attach {
  left: 8px;
}

.composer-input-emoji {
  left: 40px;
}

.composer-input-voice {
  right: 8px;
}

.composer-input-paste {
  display: none !important;
}

.composer-input-paste:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.composer-main textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  font-size: 14px;
  padding: 10px 44px 10px 78px;
  background: transparent;
  border: none;
  color: #e9edef;
  resize: none;
}

.composer-main textarea:focus {
  outline: none;
}

.voice-btn {
  color: var(--text-secondary);
}

.voice-btn.active {
  color: #34d399;
  background: rgba(16, 185, 129, 0.14) !important;
}

.composer.recording-mode .composer-main {
  display: none;
}

.recording-bar {
  min-height: 54px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  background: rgba(15, 23, 42, 0.96);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  box-shadow: var(--shadow-md);
  animation: recordingSlideIn 0.25s ease;
}

@keyframes recordingSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.recording-timer-wrap {
  min-width: 66px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 17px;
  font-weight: 700;
  color: #e2e8f0;
}

.recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
  animation: recordingPulse 1.2s ease-in-out infinite;
}

@keyframes recordingPulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.85);
  }
}

.recording-bar.paused .recording-dot {
  opacity: 0.35;
  box-shadow: none;
}

.recording-waveform {
  flex: 1;
  min-width: 120px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
}

.recording-wave {
  width: 3px;
  height: 8px;
  border-radius: var(--radius-full);
  background: #cbd5e1;
  opacity: 0.9;
  transform-origin: center;
  transition: height 80ms linear, opacity 80ms linear;
}

.recording-action {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: #111827;
  color: #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all var(--transition-fast);
}

.recording-action:hover {
  background: #1f2937;
  color: #f8fafc;
  transform: scale(1.08);
}

.recording-action.recording-send {
  color: #86efac;
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(6, 78, 59, 0.5);
}

.recording-action.recording-send:hover {
  color: #d1fae5;
  background: rgba(6, 95, 70, 0.68);
}

.recording-action.recording-danger {
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(127, 29, 29, 0.35);
}

.recording-action.recording-danger:hover {
  color: #fecaca;
  background: rgba(153, 27, 27, 0.5);
}

#fileInput {
  display: none;
}

.file-btn {
  cursor: pointer;
}

/* ===================================================================
   EMOJI PANEL
   =================================================================== */

.emoji-panel {
  position: absolute;
  left: 10px;
  bottom: calc(100% + 8px);
  z-index: 30;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  height: min(430px, 62vh);
  width: min(420px, calc(100vw - 20px));
  background: var(--bg-primary);
  box-shadow: var(--shadow-xl);
}

.emoji-popover {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.emoji-popover-body {
  flex: 1;
  min-height: 0;
}

.emoji-popover-view {
  height: 100%;
  min-height: 0;
}

.emoji-popover-media {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.gif-picker-head {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

.gif-picker-head input {
  width: 100%;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: var(--text);
  padding: 0 12px;
  font-size: 14px;
}

.gif-picker-status {
  padding: 18px 12px;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

.gif-picker-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.sticker-picker-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.gif-picker-item {
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--bg-secondary);
  overflow: hidden;
  padding: 0;
  min-height: 88px;
  max-height: 120px;
}

.gif-picker-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sticker-picker-item img {
  object-fit: contain;
  background: rgba(15, 23, 42, 0.28);
}

.emoji-popover-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 6px 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.emoji-popover-switch {
  min-height: 34px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
}

.emoji-popover-switch.active {
  color: var(--text);
  border-color: var(--accent);
  background: var(--bg-tertiary);
}

.emoji-popover-switch-icon {
  font-size: 14px;
  line-height: 1;
}

.emoji-popover-switch-label {
  line-height: 1;
}

emoji-picker {
  width: 100%;
  height: 100%;
  --emoji-size: calc(1.375rem * 0.85);
  --emoji-padding: 0.22rem;
  --category-emoji-size: calc(var(--emoji-size) * 0.9);
  --category-emoji-padding: 0.12rem;
  --num-columns: 14;
  --background: var(--bg-secondary);
  --border-color: var(--border);
  --input-border-color: var(--border-light);
  --input-font-color: var(--text);
  --input-placeholder-color: var(--text-muted);
  --category-font-color: var(--text-muted);
  --category-icon-color: var(--text-muted);
  --category-icon-active-color: var(--accent);
  --button-hover-background: var(--bg-hover);
}

/* ===================================================================
   ATTACHMENT INFO
   =================================================================== */

.attachment-info {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.attachment-info-media {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.attachment-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.attachment-preview-title {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
}

.attachment-preview-stage {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(2, 6, 23, 0.65);
  padding: 6px;
  min-height: 64px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.attachment-preview-image,
.attachment-preview-video {
  width: 100%;
  max-height: 300px;
  border-radius: 10px;
  object-fit: contain;
  background: #020617;
}

.attachment-preview-audio {
  width: 100%;
}

.attachment-preview-file {
  font-size: 13px;
  color: #dbeafe;
}

.attachment-preview-meta {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.attachment-remove {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  background: var(--danger-muted);
  color: #fca5a5;
  border: none;
  cursor: pointer;
}

.attachment-remove:hover {
  background: rgba(239, 68, 68, 0.2);
}

.quick-buttons-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.quick-buttons-bar[data-mode="slash"] {
  flex-wrap: wrap;
  overflow-x: hidden;
  max-height: 116px;
  overflow-y: auto;
}

.quick-button-chip {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.quick-button-chip:hover {
  background: var(--bg-tertiary);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.quick-button-empty {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ===================================================================
   MEDIA IN MESSAGES
   =================================================================== */

.message-file {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.15);
  width: min(100%, 360px);
  max-width: 100%;
  min-width: 0;
}

.message-file-name {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message-file-open {
  white-space: nowrap;
  color: #93c5fd;
  text-decoration: none;
}

.message-file-open:hover {
  text-decoration: underline;
}

.message-pdf-card {
  margin-top: 6px;
  width: min(100%, 360px);
  max-width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background:
    linear-gradient(162deg, rgba(9, 18, 30, 0.94) 0%, rgba(6, 14, 24, 0.95) 100%);
  box-shadow:
    0 14px 28px rgba(2, 6, 23, 0.35),
    0 1px 0 rgba(255, 255, 255, 0.04) inset;
  backdrop-filter: blur(5px);
  overflow: hidden;
}

.message-row.outgoing .message-pdf-card {
  border-color: rgba(94, 234, 212, 0.22);
  background:
    linear-gradient(162deg, rgba(7, 56, 52, 0.94) 0%, rgba(6, 41, 38, 0.95) 100%);
}

.message-pdf-preview {
  position: relative;
  height: 116px;
  background: linear-gradient(180deg, #0d4b73 0%, #0a3a5a 100%);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.message-row.outgoing .message-pdf-preview {
  background: linear-gradient(180deg, #0a5967 0%, #094750 100%);
}

.message-pdf-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 85% 24%, rgba(255, 255, 255, 0.18) 0%, transparent 42%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.05) 0%, rgba(2, 6, 23, 0.34) 100%);
  pointer-events: none;
}

.message-pdf-preview-frame {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
  background: #0b1520;
}

.message-pdf-preview-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: rgba(226, 232, 240, 0.94);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.message-pdf-head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 12px 9px;
  min-width: 0;
}

.message-pdf-icon {
  width: 36px;
  min-width: 36px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(180deg, #f43f5e 0%, #e11d48 55%, #be123c 100%);
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  position: relative;
  box-shadow:
    0 8px 14px rgba(225, 29, 72, 0.34),
    0 1px 0 rgba(255, 255, 255, 0.2) inset;
}

.message-pdf-icon::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 11px;
  height: 11px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(244, 63, 94, 0.48) 100%);
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}

.message-pdf-info {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.message-pdf-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-pdf-meta {
  font-size: 11px;
  color: rgba(203, 213, 225, 0.84);
}

.message-pdf-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.message-pdf-open {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(30, 41, 59, 0.55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #bfdbfe;
  text-decoration: none;
}

.message-pdf-open:hover {
  background: rgba(51, 65, 85, 0.72);
  border-color: rgba(148, 163, 184, 0.42);
  color: #dbeafe;
  text-decoration: none;
}

.message-pdf-open.pending {
  opacity: 0.6;
  pointer-events: none;
}

.message-pdf-open.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.message-pdf-download {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid rgba(16, 185, 129, 0.35);
  background: rgba(5, 150, 105, 0.16);
  color: #34d399;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.message-pdf-download:hover {
  background: rgba(5, 150, 105, 0.26);
  border-color: rgba(52, 211, 153, 0.55);
  color: #6ee7b7;
  text-decoration: none;
}

.message-row.outgoing .message-pdf-open {
  border-color: rgba(125, 211, 252, 0.32);
  background: rgba(12, 74, 92, 0.48);
}

.message-row.outgoing .message-pdf-open:hover {
  background: rgba(14, 116, 144, 0.52);
}

.message-row.outgoing .message-pdf-download {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.22);
  color: #a7f3d0;
}

.wa-audio-player {
  margin-top: 0;
  width: min(100%, clamp(232px, 70vw, 320px));
  min-width: 0;
  max-width: 100%;
  border-radius: 8px;
  padding: 5px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: none;
  overflow: hidden;
}

.wa-audio-leading {
  width: 42px;
  min-width: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wa-audio-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  color: #f8fafc;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-transform: uppercase;
}

.wa-audio-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wa-audio-toggle {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.wa-audio-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.wa-audio-speed {
  min-width: 40px;
  height: 24px;
  border-radius: var(--radius-full);
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
  display: none;
}

.wa-audio-speed:hover {
  background: rgba(255, 255, 255, 0.22);
}

.wa-audio-player.playing .wa-audio-speed {
  display: inline-flex;
}

.wa-audio-player.playing .wa-audio-avatar {
  display: none;
}

.wa-audio-content {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.wa-audio-track {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 20px;
}

.wa-audio-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
  background: #38bdf8;
  flex-shrink: 0;
}

.wa-audio-wave {
  min-height: 22px;
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1.5px;
  overflow: hidden;
  position: relative;
  --audio-progress: 0%;
  padding-bottom: 0;
  cursor: pointer;
}

.wa-audio-bar {
  width: 2px;
  border-radius: var(--radius-full);
  background: rgba(203, 213, 225, 0.34);
  opacity: 0.55;
  flex-shrink: 1;
  min-width: 1px;
  position: relative;
  z-index: 1;
  transition: background var(--transition-fast), opacity var(--transition-fast), box-shadow var(--transition-fast);
}

.wa-audio-bar.active {
  background: #38bdf8;
  opacity: 1;
}

.wa-audio-bar.current {
  background: #67e8f9;
  box-shadow: 0 0 7px rgba(56, 189, 248, 0.65);
}

.wa-audio-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  line-height: 1;
  color: rgba(226, 232, 240, 0.78);
  min-height: 12px;
}

.wa-audio-meta-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.wa-audio-duration {
  font-size: calc(11px * 0.85);
}

.wa-audio-clock {
  position: relative;
  top: 1px;
}

.wa-audio-source {
  display: none;
}

.wa-media-card {
  margin-top: 4px;
  margin-bottom: 0;
  margin-inline: 0;
  width: min(100%, clamp(184px, 66vw, 320px));
  max-width: 100%;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: #05080f;
}

.wa-media-image-card {
  display: inline-block;
  width: auto;
  max-width: min(100%, clamp(120px, 68vw, 360px));
  border: none;
  background: transparent;
  box-shadow: none;
}

.message-row.outgoing .wa-media-card {
  border-color: rgba(74, 222, 128, 0.45);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.14);
  margin-left: auto;
}

.message-row.outgoing .wa-media-image-card {
  border: none;
  box-shadow: none;
  margin-left: auto;
}

.message-row.outgoing .wa-sticker-card {
  margin-left: auto;
}

.wa-media-image,
.wa-media-video {
  width: 100%;
  max-height: 400px;
  display: block;
  background: #020617;
}

.wa-media-image {
  width: auto;
  height: auto;
  max-width: min(100%, clamp(120px, 68vw, 360px));
  max-height: min(64vh, 460px);
  object-fit: contain;
  background: transparent;
  border-radius: 10px;
  cursor: zoom-in;
}

.wa-media-video {
  object-fit: cover;
}

.wa-media-video {
  min-height: 150px;
}

.wa-media-gif {
  object-fit: contain;
  background: #020617;
}

.wa-media-time {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #f8fafc;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
  background: rgba(2, 6, 23, 0.55);
  border-radius: 10px;
  padding: 2px 6px;
  line-height: 1;
}

.wa-media-time .msg-ticks {
  color: rgba(226, 232, 240, 0.92);
}

.wa-media-time .msg-ticks-read {
  color: #67e8f9;
}

.wa-sticker-card {
  margin-top: 4px;
  margin-bottom: 0;
  margin-inline: 0;
  width: min(100%, clamp(104px, 34vw, 156px));
  max-width: 100%;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: transparent;
}

.wa-sticker-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  background: transparent;
  cursor: zoom-in;
}

.wa-sticker-time {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #f8fafc;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
  background: rgba(2, 6, 23, 0.58);
  border-radius: 9px;
  padding: 2px 5px;
  line-height: 1;
}

.message-image-wrap,
.message-video-wrap {
  margin-top: 6px;
}

.message-image,
.message-video {
  width: min(360px, 100%);
  max-height: 360px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: block;
  background: var(--bg-dark);
}

/* ===================================================================
   MANAGEMENT PANEL
   =================================================================== */

.management-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(20px) saturate(80%);
  -webkit-backdrop-filter: blur(20px) saturate(80%);
}

.management-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(980px, 92vw);
  max-height: min(86vh, 860px);
  height: auto;
  z-index: 100;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translate(-50%, -48%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.24s ease, opacity 0.24s ease;
  box-shadow: var(--shadow-xl);
}

.management-panel.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.management-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 2;
}

.management-head h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.management-tabs {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 6px;
  padding: 6px;
  margin: 10px 14px 0;
  min-height: 52px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  overflow: hidden;
}

.management-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  min-width: 0;
  height: 40px !important;
  min-height: 40px !important;
  border: none;
  border: 1px solid transparent;
  background: transparent;
  color: #90a2b1;
  border-radius: 8px;
  padding: 0 14px !important;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.1px;
  white-space: nowrap;
  text-align: center;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.management-tab-btn:hover {
  color: #dbe4ea;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.2);
}

.management-tab-btn.active,
.management-tab-btn[aria-selected="true"] {
  color: #ffffff;
  background: linear-gradient(180deg, #14c7a5 0%, #0aa886 100%);
  border-color: rgba(20, 199, 165, 0.7);
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(0, 168, 132, 0.28);
}

.management-tab-btn:focus-visible {
  outline: 2px solid rgba(20, 199, 165, 0.6);
  outline-offset: 1px;
}

.management-tab-content {
  display: flex;
  flex-direction: column;
}

.owner-only-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(245, 158, 11, 0.42);
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
  font-size: 10px;
  letter-spacing: 0.4px;
  font-weight: 700;
  text-transform: uppercase;
}

/* ===================================================================
   PANEL SECTIONS
   =================================================================== */

.panel-section {
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 0 0 14px 0;
}

.section-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.owner-only.hidden,
.manager-only.hidden {
  display: none !important;
}

.bot-only.hidden,
.crm-only.hidden {
  display: none !important;
}

.management-panel.bot-mode .crm-only {
  display: none !important;
}

.management-panel.bot-mode .bot-only {
  display: block;
}

.management-inline-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.management-user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.management-user-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.management-user-main {
  min-width: 0;
}

.management-user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.management-user-meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-word;
}

.management-user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.management-user-actions .btn-ghost:disabled,
.management-panel .btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===================================================================
   BOT WORKSPACE
   =================================================================== */

.bot-workspace {
  gap: 10px;
}

.bot-workspace-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.bot-workspace-tab {
  min-height: 36px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  padding: 0 10px;
}

.bot-workspace-tab:hover {
  color: var(--text);
  border-color: var(--accent);
}

.bot-workspace-tab.active {
  color: var(--text);
  border-color: rgba(37, 211, 102, 0.5);
  background: rgba(37, 211, 102, 0.14);
}

.bot-workspace-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bot-agents-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.bot-agent-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  padding: 10px 12px;
  display: grid;
  gap: 6px;
}

.bot-agent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bot-agent-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.bot-agent-status {
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-full);
  padding: 4px 8px;
  border: 1px solid var(--border-light);
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

.bot-agent-status.online {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.48);
  background: rgba(34, 197, 94, 0.18);
}

.bot-agent-status.offline {
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(148, 163, 184, 0.14);
}

.bot-agent-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* ===================================================================
   NOTES & QUICK REPLIES
   =================================================================== */

.note-list,
.quick-reply-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-item,
.quick-reply-item {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  transition: border-color var(--transition-fast);
}

.note-item:hover,
.quick-reply-item:hover {
  border-color: var(--border-light);
}

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

.note-text {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.quick-reply-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

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

.quick-reply-text {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===================================================================
   TOGGLE ROW
   =================================================================== */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-row input {
  width: auto;
  flex-shrink: 0;
}

/* ===================================================================
   INFO TEXT
   =================================================================== */

.info-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

/* ===================================================================
   ATTENDANT PRESENCE
   =================================================================== */

.presence-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.presence-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border-light);
}

.presence-chip-online {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.42);
  color: #86efac;
}

.presence-chip-offline {
  background: rgba(148, 163, 184, 0.16);
  border-color: rgba(148, 163, 184, 0.35);
  color: #cbd5e1;
}

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

.presence-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.presence-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  padding: 10px 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.presence-item:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

.presence-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.presence-content {
  min-width: 0;
  flex: 1;
}

.presence-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.presence-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.presence-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
}

.presence-item.presence-online .presence-badge {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.17);
}

.presence-item.presence-offline .presence-badge {
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(148, 163, 184, 0.14);
}

/* ===================================================================
   RESPONSIVE — TABLET
   =================================================================== */

@media (max-width: 1200px) {
  :root {
    --sidebar-width: 300px;
  }

  .messages {
    padding-inline: clamp(6px, 1.5vw, 14px);
  }

  .topbar-center {
    max-width: 200px;
  }
}

/* ===================================================================
   RESPONSIVE — MOBILE
   =================================================================== */

@media (max-width: 900px) {
  .login-view {
    align-items: stretch;
    padding: 12px;
  }

  .login-card {
    max-width: 100%;
    margin: auto 0;
    padding: 24px 18px;
    border-radius: 14px;
  }

  .login-brand {
    margin-bottom: 20px;
  }

  .login-logo {
    width: 52px;
    height: 52px;
    margin-bottom: 12px;
  }

  .login-brand h1 {
    font-size: 24px;
    margin-bottom: 4px;
  }

  .login-subtitle {
    font-size: 13px;
  }

  .login-form input {
    padding: 12px 14px;
    font-size: 15px;
  }

  .seed-help {
    margin-top: 16px;
    padding-top: 14px;
    gap: 4px;
  }

  .seed-item {
    font-size: 10px;
    padding: 3px 8px;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    height: 100dvh;
  }

  .side-rail {
    display: none;
  }

  .app-topbar {
    display: flex;
    padding: env(safe-area-inset-top) 12px 0;
    height: calc(var(--topbar-height) + env(safe-area-inset-top));
  }

  .topbar-center {
    display: none;
  }

  .topbar-title {
    font-size: 14px;
  }

  .user-badge {
    display: none;
  }

  .workspace {
    display: block;
    position: relative;
    flex: 1;
    min-height: 0;
    height: calc(100dvh - var(--topbar-height) - env(safe-area-inset-top));
    overflow: hidden;
  }

  .chat-list-panel,
  .conversation-panel {
    position: absolute;
    inset: 0;
    min-height: 0;
  }

  .chat-list-panel {
    border-right: none;
    border-bottom: none;
  }

  .app-shell.is-mobile.mobile-screen-list .chat-list-panel {
    display: flex;
  }

  .app-shell.is-mobile.mobile-screen-list .conversation-panel {
    display: none;
  }

  .app-shell.is-mobile.mobile-screen-chat .chat-list-panel {
    display: none;
  }

  .app-shell.is-mobile.mobile-screen-chat .conversation-panel {
    display: flex;
  }

  .app-shell.is-mobile.mobile-screen-management .chat-list-panel {
    display: none;
  }

  .app-shell.is-mobile.mobile-screen-management .conversation-panel {
    display: flex;
  }

  .mobile-back-btn {
    display: inline-flex;
    width: 34px;
    height: 34px;
  }

  .conversation-header {
    height: 56px;
    padding: 0 10px;
  }

  .conversation-contact {
    gap: 8px;
  }

  .contact-info h3 {
    font-size: 14px;
  }

  .contact-subtitle {
    font-size: 11px;
  }

  .quick-filter-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .chat-list-title {
    font-size: 22px;
  }

  .chat-sort-control {
    font-size: 11px;
    min-height: 28px;
  }

  .chat-simple-filter-btn {
    width: 28px;
    height: 28px;
  }

  .chat-promo-card {
    display: none;
  }

  .chat-item {
    padding: 8px 10px;
    gap: 10px;
    min-height: 58px;
  }

  .chat-avatar {
    width: 38px;
    height: 38px;
    font-size: 13px;
  }

  .messages {
    padding: 10px 6px 4px;
  }

  .message-row {
    padding-inline: 0;
  }

  .message-row.incoming {
    padding-right: 0;
  }

  .message-row.outgoing {
    padding-left: 0;
  }

  .message-bubble {
    width: auto;
    max-width: var(--message-max-width-mobile);
  }

  .message-stack {
    max-width: var(--message-max-width-mobile);
  }

  .message-bubble.media-only,
  .message-stack.media-stack {
    max-width: var(--message-media-max-width-mobile);
  }

  .wa-link-preview-list {
    width: 100%;
  }

  .wa-link-preview-card {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .wa-link-preview-thumb {
    width: 72px;
    min-height: 72px;
  }

  .wa-link-preview-thumb img {
    min-height: 72px;
  }

  .composer {
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }

  .composer-main {
    align-items: center;
    gap: 6px;
  }

  .message-input-shell {
    min-width: 0;
  }

  .recording-bar {
    gap: 6px;
    padding: 8px;
  }

  .recording-waveform {
    min-width: 84px;
  }

  .composer-input-icon {
    width: 28px;
    height: 28px;
  }

  .composer-input-attach {
    left: 7px;
  }

  .composer-input-emoji {
    left: 35px;
  }

  .composer-main textarea {
    padding-left: 70px;
    padding-right: 42px;
  }

  .attachment-preview-image,
  .attachment-preview-video {
    max-height: 220px;
  }

  .emoji-panel {
    left: 8px;
    right: 8px;
    bottom: calc(100% + 6px);
    width: auto;
    height: min(52vh, 380px);
  }

  .gif-picker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sticker-picker-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  emoji-picker {
    --num-columns: 10;
  }

  .management-backdrop {
    inset: 0;
  }

  .management-panel {
    width: min(96vw, 640px);
    max-height: min(88vh, 760px);
    border-left: 1px solid var(--border);
    border-radius: 16px;
  }

  .management-head {
    padding-top: 14px;
  }

  .management-tabs {
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .management-tabs::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }

  .management-tab-btn {
    flex: 0 0 auto;
    min-width: 116px;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 12px !important;
    font-size: 11px;
  }

  .panel-section {
    padding: 14px;
  }

  .management-inline-grid {
    grid-template-columns: 1fr;
  }

  .management-user-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .management-user-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ===================================================================
   MODAL
   =================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(11, 20, 26, 0.85);
  /* Dark overlay */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.delete-message-modal {
  width: min(560px, 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  box-shadow: var(--shadow-xl);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.delete-message-modal h3 {
  font-size: 34px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.4px;
  color: #e9edef;
  margin: 0;
}

.delete-message-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.delete-message-btn {
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 15px;
  font-weight: 600;
  transition: filter var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.delete-message-btn:hover {
  filter: brightness(1.05);
}

.delete-message-cancel {
  background: transparent;
  color: #25d366;
}

.delete-message-me {
  background: #25d366;
  color: #0b141a;
}

.delete-message-all {
  background: #dc2626;
  color: #ffffff;
}

.edit-message-modal {
  width: min(560px, 100%);
  border-radius: 18px;
  border: 1px solid #2a3942;
  background: #1f2b33;
  box-shadow: var(--shadow-xl);
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.edit-message-modal h3 {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.2px;
  color: #e9edef;
  margin: 0;
}

.edit-message-input {
  width: 100%;
  min-height: 102px;
  max-height: 50vh;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid #2a3942;
  background: #111b21;
  color: #e9edef;
  font-size: 14px;
  line-height: 1.35;
  padding: 10px 12px;
}

.edit-message-input:focus {
  border-color: #25d366;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.2);
}

.edit-message-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.edit-message-btn {
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 15px;
  font-weight: 600;
  transition: filter var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.edit-message-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.edit-message-btn:hover:not(:disabled) {
  filter: brightness(1.05);
}

.edit-message-cancel {
  background: transparent;
  color: #25d366;
}

.edit-message-save {
  background: #25d366;
  color: #0b141a;
}

.image-viewer-modal {
  width: min(1120px, 100%);
  max-height: min(94vh, 940px);
  border-radius: 18px;
  border: 1px solid #2a3942;
  background: #111b21;
  box-shadow: var(--shadow-xl);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.image-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.image-viewer-head h3 {
  margin: 0;
  color: #e9edef;
  font-size: 18px;
  font-weight: 700;
}

.image-viewer-stage {
  flex: 1;
  min-height: 220px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(2, 6, 23, 0.66);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: auto;
}

.image-viewer-media-shell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: min(70vh, 760px);
}

.image-viewer-media-content {
  position: relative;
  transform-origin: center center;
  max-width: 100%;
}

.image-viewer-image {
  display: block;
  max-width: min(88vw, 960px);
  max-height: min(68vh, 720px);
  width: auto;
  height: auto;
  border-radius: 12px;
  user-select: none;
  -webkit-user-drag: none;
}

.image-viewer-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  pointer-events: none;
  touch-action: none;
}

.image-viewer-canvas.editable {
  pointer-events: auto;
  cursor: crosshair;
}

.image-viewer-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.image-viewer-tool-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.image-tool-btn {
  border: 1px solid #2a3942;
  background: #1f2b33;
  color: #d5dde2;
  border-radius: 10px;
  min-height: 34px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), filter var(--transition-fast);
}

.image-tool-btn svg {
  flex-shrink: 0;
}

.image-tool-btn:hover {
  filter: brightness(1.06);
  border-color: #4b5563;
}

.image-tool-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: none;
}

.image-tool-btn.active {
  background: rgba(37, 211, 102, 0.18);
  border-color: rgba(37, 211, 102, 0.4);
  color: #dff9e8;
}

.image-tool-btn-primary {
  background: #25d366;
  border-color: #25d366;
  color: #03281a;
}

.image-draw-tools {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 12px;
  background: rgba(31, 43, 51, 0.76);
  padding: 8px;
}

.image-draw-color,
.image-draw-width {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid #2a3942;
  border-radius: 10px;
  background: #1f2b33;
  color: #d5dde2;
  font-size: 12px;
  padding: 6px 10px;
}

.image-draw-color input[type="color"] {
  width: 22px;
  height: 22px;
  border: none;
  padding: 0;
  background: transparent;
}

.image-draw-width input[type="range"] {
  width: 88px;
}

.image-viewer-sliders {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.image-slider {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.42);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.image-slider span {
  color: #c6d2db;
  font-size: 11px;
  font-weight: 600;
}

.image-slider input[type="range"] {
  width: 100%;
}

[data-theme="light"] .image-viewer-modal {
  background: #fffaf1;
  border-color: #ddccb0;
}

[data-theme="light"] .image-viewer-head h3 {
  color: #3a3329;
}

[data-theme="light"] .image-viewer-stage {
  background: rgba(249, 240, 225, 0.9);
  border-color: #d6c7ae;
}

[data-theme="light"] .image-tool-btn,
[data-theme="light"] .image-draw-color,
[data-theme="light"] .image-draw-width {
  background: #f6eddc;
  border-color: #ddccb0;
  color: #4a4134;
}

[data-theme="light"] .image-tool-btn.active {
  background: rgba(11, 143, 106, 0.14);
  border-color: rgba(11, 143, 106, 0.36);
  color: #0a6f54;
}

[data-theme="light"] .image-tool-btn-primary {
  color: #ffffff;
  background: #0b8f6a;
  border-color: #0b8f6a;
}

[data-theme="light"] .image-draw-tools {
  border-color: #ddccb0;
  background: #f8f1e2;
}

[data-theme="light"] .image-slider {
  border-color: #ddccb0;
  background: #f5eddc;
}

[data-theme="light"] .image-slider span {
  color: #675b48;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.2s ease;
  border: 1px solid var(--border);
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.quick-msg-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.quick-msg-list-wrapper h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quick-msg-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-msg-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  transition: background var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  position: relative;
}

.quick-msg-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
}

.quick-msg-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.quick-msg-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.quick-msg-title {
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
}

.quick-msg-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-msg-tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
}

.quick-msg-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  white-space: pre-wrap;
}

.quick-msg-text-muted {
  color: var(--text-muted);
  font-style: italic;
}

.btn-send-msg,
.btn-delete-msg {
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-send-msg {
  color: var(--accent);
  border-color: rgba(59, 130, 246, 0.35);
}

.btn-send-msg:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.14);
  color: var(--accent-hover);
}

.btn-send-msg:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.quick-msg-audio-hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.client-profile-modal-card {
  max-width: 560px;
}

.client-profile-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.client-profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.client-profile-note {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.client-profile-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.user-edit-modal-card {
  max-width: 620px;
}

.user-edit-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-edit-hero {
  border: 1px solid rgba(37, 211, 102, 0.35);
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.16), rgba(6, 95, 70, 0.1));
  border-radius: 12px;
  padding: 12px;
}

.user-edit-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(37, 211, 102, 0.45);
  background: rgba(15, 23, 42, 0.55);
  color: #9af0bd;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.45px;
  text-transform: uppercase;
  padding: 3px 8px;
}

.user-edit-hero p {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.user-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.user-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

[data-theme="light"] .user-edit-hero {
  border-color: rgba(11, 143, 106, 0.35);
  background: linear-gradient(135deg, rgba(11, 143, 106, 0.12), rgba(188, 247, 210, 0.35));
}

[data-theme="light"] .user-edit-badge {
  background: rgba(255, 255, 255, 0.85);
  color: #0b8f6a;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .delete-message-modal {
    width: min(92vw, 420px);
    padding: 16px 16px 14px;
    border-radius: 16px;
    gap: 14px;
  }

  .delete-message-modal h3 {
    font-size: 25px;
    line-height: 1.2;
  }

  .delete-message-btn {
    font-size: 14px;
    padding: 8px 15px;
  }

  .edit-message-modal {
    width: min(92vw, 420px);
    padding: 16px 16px 14px;
    border-radius: 16px;
    gap: 12px;
  }

  .edit-message-modal h3 {
    font-size: 23px;
    line-height: 1.2;
  }

  .edit-message-input {
    min-height: 94px;
    font-size: 14px;
    padding: 9px 10px;
  }

  .edit-message-btn {
    font-size: 14px;
    padding: 8px 14px;
  }

  .image-viewer-modal {
    width: min(96vw, 96vw);
    max-height: 96vh;
    border-radius: 14px;
    padding: 10px;
    gap: 10px;
  }

  .image-viewer-stage {
    min-height: 180px;
    padding: 8px;
  }

  .image-viewer-image {
    max-width: 92vw;
    max-height: 60vh;
  }

  .image-viewer-tool-row {
    gap: 6px;
  }

  .image-tool-btn {
    min-height: 32px;
    font-size: 11px;
    padding: 6px 9px;
  }

  .image-viewer-sliders {
    grid-template-columns: 1fr;
  }

  .image-draw-width input[type="range"] {
    width: 70px;
  }

  .client-profile-grid {
    grid-template-columns: 1fr;
  }

  .user-edit-grid {
    grid-template-columns: 1fr;
  }

  .user-edit-actions {
    justify-content: stretch;
    flex-wrap: wrap;
  }

  .user-edit-actions .btn-ghost,
  .user-edit-actions .btn-primary {
    flex: 1;
    min-width: 130px;
  }
}

/* ===================================================================
   INTERNAL TEAM CHAT
   =================================================================== */

.internal-chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--danger);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(239, 68, 68, 0.5);
  animation: badgePulse 2s ease-in-out infinite;
}

.side-rail-btn {
  position: relative;
}

@keyframes badgePulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

.internal-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.internal-chat-container {
  display: flex;
  width: min(1100px, 94vw);
  height: min(720px, 88vh);
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Sidebar */
.internal-chat-sidebar {
  width: 340px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
}

.internal-chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

.internal-chat-sidebar-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.internal-chat-search-wrap {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
}

.internal-chat-search-wrap input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.internal-chat-search-wrap input:focus {
  border-color: var(--accent);
}

.internal-chat-search-wrap input::placeholder {
  color: var(--text-muted);
}

.internal-conversation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.internal-conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition-fast);
}

.internal-conv-item:hover {
  background: var(--bg-hover);
}

.internal-conv-item.active {
  background: var(--bg-active);
  border-left: 3px solid var(--accent);
}

.internal-conv-avatar {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.internal-conv-avatar.group {
  border-radius: var(--radius-lg);
}

.internal-conv-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.internal-conv-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.internal-conv-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.internal-conv-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.internal-conv-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.internal-conv-preview {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.internal-conv-unread {
  min-width: 20px;
  height: 20px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.internal-conv-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Main Area */
.internal-chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  min-width: 0;
}

.internal-chat-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}

.internal-chat-main-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.internal-chat-main-info h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

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

.internal-chat-main-actions {
  display: flex;
  gap: 6px;
}

/* Messages */
.internal-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-color: var(--chat-wallpaper-bg);
  background-image: var(--chat-wallpaper-pattern);
  background-repeat: var(--chat-wallpaper-repeat, repeat);
  background-size: var(--chat-wallpaper-size, 220px 220px);
  background-position: var(--chat-wallpaper-position, center);
}

.internal-messages-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.internal-msg {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}

.internal-msg-me {
  align-self: flex-end;
  align-items: flex-end;
}

.internal-msg-other {
  align-self: flex-start;
  align-items: flex-start;
}

.internal-msg-author {
  display: flex;
  gap: 6px;
  align-items: baseline;
  margin-bottom: 2px;
  padding-left: 8px;
}

.internal-msg-author-name {
  font-size: 12px;
  font-weight: 600;
}

.internal-msg-author-role {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.internal-msg-bubble {
  position: relative;
  padding: 8px 12px 4px;
  border-radius: var(--radius-lg);
  min-width: 60px;
}

.internal-msg-me .internal-msg-bubble {
  background: var(--bubble-out);
  border-bottom-right-radius: var(--radius-xs);
}

.internal-msg-other .internal-msg-bubble {
  background: var(--bubble-in);
  border-bottom-left-radius: var(--radius-xs);
}

.internal-msg-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.internal-msg-time {
  display: block;
  text-align: right;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  padding-bottom: 2px;
}

.internal-msg-date-sep {
  display: flex;
  justify-content: center;
  padding: 10px 0;
}

.internal-msg-date-sep span {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 4px 14px;
  border-radius: var(--radius-full);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

/* Composer */
.internal-chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.internal-chat-composer textarea {
  flex: 1;
  height: 38px;
  max-height: 120px;
  padding: 8px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color var(--transition-fast);
  line-height: 1.4;
}

.internal-chat-composer textarea:focus {
  border-color: var(--accent);
}

.internal-chat-composer textarea::placeholder {
  color: var(--text-muted);
}

.internal-chat-composer .btn-send {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.internal-chat-composer .btn-send:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.internal-chat-composer .btn-send:active {
  transform: scale(0.95);
}

/* Team Group Modal */
.team-group-modal-card {
  width: min(480px, 92vw);
  max-height: 80vh;
}

.team-group-modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 16px;
}

.team-group-members-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.team-member-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  transition: border-color var(--transition-fast);
}

.team-member-card:hover {
  border-color: var(--border);
}

.team-member-avatar {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.team-member-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.team-member-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.team-member-email {
  font-size: 11.5px;
  color: var(--text-muted);
}

.team-member-toggle {
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.team-member-toggle.included {
  background: rgba(0, 168, 132, 0.1);
  border-color: rgba(0, 168, 132, 0.35);
  color: var(--accent);
}

.team-member-toggle.included:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}

.team-member-toggle.excluded {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  color: var(--danger);
}

.team-member-toggle.excluded:hover {
  background: rgba(0, 168, 132, 0.08);
  border-color: rgba(0, 168, 132, 0.35);
  color: var(--accent);
}

/* Responsive */
@media (max-width: 700px) {
  .internal-chat-container {
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  .internal-chat-sidebar {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .internal-msg {
    max-width: 90%;
  }
}

/* Light theme overrides */
[data-theme="light"] .internal-chat-overlay {
  background: rgba(255, 255, 255, 0.5);
}

[data-theme="light"] .internal-chat-container {
  border-color: #e6d8c1;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .internal-chat-sidebar {
  background: #fffaf1;
  border-right-color: #e6d8c1;
}

[data-theme="light"] .internal-chat-sidebar-header {
  background: #f9f3e7;
  border-bottom-color: #e6d8c1;
}

[data-theme="light"] .internal-conv-item:hover {
  background: #f7efe1;
}

[data-theme="light"] .internal-conv-item.active {
  background: #f2e7d4;
  border-left-color: var(--accent);
}

[data-theme="light"] .internal-chat-main {
  background: var(--chat-wallpaper-bg);
}

[data-theme="light"] .internal-chat-main-header {
  background: #f9f3e7;
  border-bottom-color: #e6d8c1;
}

[data-theme="light"] .internal-msg-other .internal-msg-bubble {
  background: var(--bubble-in);
  border: 1px solid #e5d7c0;
}

[data-theme="light"] .internal-msg-me .internal-msg-bubble {
  background: var(--bubble-out);
  border: 1px solid #d2dbe8;
}

[data-theme="light"] .internal-chat-composer {
  background: #f7efdf;
  border-top-color: #e6d8c1;
}

[data-theme="light"] .internal-msg-date-sep span {
  background: #f4ead8;
  color: #625745;
}

[data-theme="light"] .team-member-card {
  background: #ffffff;
  border-color: #e2e8f0;
}
