/* =====================================================
   WhatsApp Web Theme System
   Dark & Light Mode Support with Modern Design
   - الخط والألوان موحدة مع admin-dashboard
   ===================================================== */

/* توحيد الخط مع لوحة الإدارة */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

html,
body {
  height: 100%;
  font-family: 'Cairo', sans-serif;
}
:root {
  /* Light Theme Colors */
  --wa-light-bg-primary: #FFFFFF;
  --wa-light-bg-secondary: #F0F0F0;
  --wa-light-bg-tertiary: #E5E5EA;
  --wa-light-text-primary: #000000;
  --wa-light-text-secondary: #54656F;
  --wa-light-text-muted: #8A8A8E;
  --wa-light-border: #E5E5EA;
  --wa-light-bubble-incoming: #E5E5EA;
  --wa-light-bubble-outgoing: #DCF8C6;
  --wa-light-header-bg: #F8F8F8;
  --wa-light-sidebar-bg: #FFFFFF;
  --wa-light-composer-bg: #FFFFFF;

  /* Dark Theme Colors */
  --wa-dark-bg-primary: #0A0E11;
  --wa-dark-bg-secondary: #111B21;
  --wa-dark-bg-tertiary: #1F2937;
  --wa-dark-text-primary: #E9EDEF;
  --wa-dark-text-secondary: #AEBAC1;
  --wa-dark-text-muted: #8A8A8E;
  --wa-dark-border: #2A3942;
  --wa-dark-bubble-incoming: #202C33;
  --wa-dark-bubble-outgoing: #005C4B;
  --wa-dark-header-bg: #111B21;
  --wa-dark-sidebar-bg: #111B21;
  --wa-dark-composer-bg: #111B21;

  /* Accent Colors */
  --wa-accent-green: #00A884;
  --wa-accent-blue: #0077CC;
  --wa-accent-red: #FF6B6B;
  --wa-accent-yellow: #FFB300;

  /* Current Theme (default: dark) - ألوان متطابقة مع لوحة الإدارة */
  --wa-bg-primary: #0E0E10;
  --wa-bg-secondary: #1e2a3a;
  --wa-bg-tertiary: #162236;
  --wa-text-primary: #E0E0E0;
  --wa-text-secondary: #B0B0B0;
  --wa-text-muted: #808080;
  --wa-border: rgba(0, 119, 204, 0.18);
  --wa-bubble-incoming: #1e2a3a;
  --wa-bubble-outgoing: #0a3a6e;
  --wa-header-bg: #0a1628;
  --wa-sidebar-bg: #0a1628;
  --wa-composer-bg: #0a1628;
}

/* Dark Theme Overrides - التأكد من تطبيق ألوان الدارك بشكل صحيح */
[data-wa-theme="dark"] {
  --wa-bg-primary: #0E0E10;
  --wa-bg-secondary: #1e2a3a;
  --wa-bg-tertiary: #162236;
  --wa-text-primary: #E0E0E0;
  --wa-text-secondary: #B0B0B0;
  --wa-text-muted: #808080;
  --wa-bubble-incoming: #1e2a3a;
  --wa-bubble-outgoing: #0a3a6e;
}

/* Light Theme */
[data-wa-theme="light"] {
  --wa-bg-primary: var(--wa-light-bg-primary);
  --wa-bg-secondary: var(--wa-light-bg-secondary);
  --wa-bg-tertiary: var(--wa-light-bg-tertiary);
  --wa-text-primary: var(--wa-light-text-primary);
  --wa-text-secondary: var(--wa-light-text-secondary);
  --wa-text-muted: var(--wa-light-text-muted);
  --wa-border: var(--wa-light-border);
  --wa-bubble-incoming: var(--wa-light-bubble-incoming);
  --wa-bubble-outgoing: var(--wa-light-bubble-outgoing);
  --wa-header-bg: var(--wa-light-header-bg);
  --wa-sidebar-bg: var(--wa-light-sidebar-bg);
  --wa-composer-bg: var(--wa-light-composer-bg);
}

/* Light Theme - إصلاح ألوان النصوص والفقاعات */
[data-wa-theme="light"] .wa-bubble.inbound {
  background: #E5E5EA !important;
  color: #000000 !important;
}

[data-wa-theme="light"] .wa-bubble.outbound {
  background: #DCF8C6 !important;
  color: #000000 !important;
}

[data-wa-theme="light"] .wa-bubble-text {
  color: #000000 !important;
}

[data-wa-theme="light"] .wa-bubble-meta {
  color: rgba(0, 0, 0, 0.55) !important;
}

[data-wa-theme="light"] .wa-bubble.outbound .wa-bubble-meta {
  color: rgba(0, 0, 0, 0.55) !important;
}

[data-wa-theme="light"] .wa-interactive-header,
[data-wa-theme="light"] .wa-interactive-footer,
[data-wa-theme="light"] .wa-interactive-template-name,
[data-wa-theme="light"] .wa-interactive-reply,
[data-wa-theme="light"] .wa-reaction-label,
[data-wa-theme="light"] .wa-unsupported {
  color: #000000 !important;
}

[data-wa-theme="light"] .wa-interactive-buttons {
  border-top-color: rgba(0, 0, 0, 0.1) !important;
}

[data-wa-theme="light"] .wa-conversation-top strong {
  color: #000000;
}

[data-wa-theme="light"] .wa-conversation-bottom span {
  color: #54656F;
}

[data-wa-theme="light"] .wa-inbox-sidebar-head h2 {
  color: #000000;
}

[data-wa-theme="light"] .wa-chat-title strong {
  color: #000000;
}

[data-wa-theme="light"] .wa-search input {
  background: #F0F0F0;
  color: #000000;
  border-color: #E5E5EA;
}

[data-wa-theme="light"] .wa-composer-form textarea {
  background: #F0F0F0;
  color: #000000;
  border-color: #E5E5EA;
}

[data-wa-theme="light"] .wa-composer-form textarea::placeholder {
  color: #8A8A8E;
}

[data-wa-theme="light"] .wa-attachment-meta strong {
  color: #000000;
}

[data-wa-theme="light"] .wa-empty-chat,
[data-wa-theme="light"] .wa-empty-list {
  color: #54656F;
}

[data-wa-theme="light"] .wa-chat-state {
  color: #54656F;
  background: rgba(0, 119, 204, 0.06);
}

[data-wa-theme="light"] .wa-typing {
  color: #0077CC;
}

/* ─── WhatsApp Inbox Shell ─── */
.wa-inbox-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--wa-bg-primary);
  border: none;
  border-radius: 0;
  box-shadow: none;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* ─── Sidebar ─── */
.wa-inbox-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  min-height: 0;
  background: var(--wa-sidebar-bg);
  border-left: 1px solid var(--wa-border);
  transition: background-color 0.3s ease, border-color 0.3s ease;
  overflow: hidden;
}

.wa-inbox-sidebar-head {
  min-height: 60px;
  height: 60px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--wa-header-bg);
  border-bottom: 1px solid var(--wa-border);
  transition: background-color 0.3s ease, border-color 0.3s ease;
  flex-shrink: 0;
}

.wa-inbox-sidebar-head h2 {
  font-size: 18px;
  color: var(--wa-text-primary);
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.wa-inbox-sidebar-head p {
  font-size: 11px;
  color: var(--wa-text-muted);
  margin: 2px 0 0;
}

.wa-sidebar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.wa-icon-action {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--wa-text-secondary);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
  font-size: 18px;
  cursor: pointer;
  border: none;
  padding: 0;
}

.wa-icon-action:hover {
  color: var(--wa-accent-blue);
  background: rgba(0, 119, 204, 0.10);
}

/* ─── Search ─── */
.wa-search {
  padding: 10px 12px;
  background: var(--wa-bg-secondary);
  border-bottom: 1px solid var(--wa-border);
  transition: background-color 0.3s ease, border-color 0.3s ease;
  flex-shrink: 0;
}

.wa-search input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--wa-border);
  border-radius: 20px;
  background: var(--wa-bg-tertiary);
  color: var(--wa-text-primary);
  padding: 0 16px;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}

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

.wa-search input:focus {
  border-color: var(--wa-accent-blue);
  box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.12);
}

/* ─── Conversations List ─── */
.wa-conversations {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  transition: background-color 0.3s ease;
  min-height: 0;
}

.wa-conversation {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: inherit;
  text-align: right;
  border-bottom: 1px solid var(--wa-border);
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
  position: relative;
  background: var(--wa-bg-primary);
  cursor: pointer;
  border: none;
}

.wa-conversation:hover {
  background: var(--wa-bg-secondary);
}

.wa-conversation.active {
  background: var(--wa-bg-secondary);
}

.wa-conversation.active::before {
  content: '';
  position: absolute;
  inset-block: 8px;
  right: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--wa-accent-blue);
}

.wa-conversation-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  color: white;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.wa-conversation-body {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wa-conversation-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.wa-conversation-top strong {
  color: var(--wa-text-primary);
  font-size: 13px;
  direction: ltr;
  unicode-bidi: plaintext;
  font-weight: 600;
}

.wa-conversation-top time {
  color: var(--wa-text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.wa-conversation-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.wa-conversation-bottom span {
  color: var(--wa-text-secondary);
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.wa-unread {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 50%;
  background: var(--wa-accent-blue);
  color: white;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

/* ─── Chat Window ─── */
.wa-chat-window {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: var(--wa-bg-primary);
  position: relative;
  transition: background-color 0.3s ease;
  overflow: hidden;
}

.wa-chat-window::before {
  content: '';
  position: absolute;
  inset: 60px 0 70px;
  opacity: 0.03;
  pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, var(--wa-text-primary) 1px, transparent 0);
  background-size: 24px 24px;
}

/* ─── Chat Header ─── */
.wa-chat-header {
  min-height: 60px;
  height: 60px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--wa-header-bg);
  border-bottom: 1px solid var(--wa-border);
  position: relative;
  z-index: 1;
  transition: background-color 0.3s ease, border-color 0.3s ease;
  flex-shrink: 0;
}

.wa-chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  color: white;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.wa-chat-title {
  flex: 1;
  min-width: 0;
}

.wa-chat-title strong {
  display: block;
  color: var(--wa-text-primary);
  direction: ltr;
  unicode-bidi: plaintext;
  font-weight: 600;
  font-size: 14px;
}

.wa-chat-title span {
  font-size: 11px;
  color: var(--wa-text-muted);
  margin-top: 2px;
  display: block;
}

.wa-chat-placeholder-title {
  color: var(--wa-text-secondary);
  font-weight: 700;
  font-size: 14px;
}

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

/* ─── Messages Container ─── */
.wa-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px clamp(12px, 3vw, 32px);
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--wa-bg-primary);
  transition: background-color 0.3s ease;
  min-height: 0;
}

/* ─── Message Bubbles ─── */
.wa-bubble {
  width: fit-content;
  max-width: min(85%, 620px);
  padding: 10px 14px;
  border-radius: 14px;
  color: var(--wa-text-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
  position: relative;
  overflow: visible;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wa-bubble.inbound {
  align-self: flex-start;
  background: var(--wa-bubble-incoming);
  border-top-left-radius: 4px;
  color: var(--wa-text-primary);
}

.wa-bubble.outbound {
  align-self: flex-end;
  background: var(--wa-bubble-outgoing);
  border-top-right-radius: 4px;
  color: #E9EDEF;
}

.wa-bubble-text {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
  color: inherit;
  width: 100%;
}

.wa-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.8;
}

.wa-bubble.inbound .wa-bubble-meta {
  color: var(--wa-text-muted);
}

.wa-bubble.outbound .wa-bubble-meta {
  color: rgba(255, 255, 255, .72);
}

.wa-delivery {
  letter-spacing: -2px;
  font-weight: 800;
}

.wa-delivery.read {
  color: var(--wa-accent-blue);
}

/* ─── Media Preview ─── */
.wa-media-preview {
  display: block;
  margin: -2px -4px 7px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.1);
  cursor: zoom-in;
}

.wa-image-preview img {
  width: 100%;
  max-width: 360px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.wa-video-preview video {
  width: min(460px, 62vw);
  max-height: 360px;
  display: block;
  border-radius: 10px;
  background: #000;
}

.wa-audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  padding: 9px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
}

.wa-audio-wave {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 0 0 auto;
}

.wa-audio-wave i {
  width: 3px;
  border-radius: 3px;
  background: #fff;
  display: block;
}

.wa-audio-wave i:nth-child(1) { height: 12px; }
.wa-audio-wave i:nth-child(2) { height: 20px; }
.wa-audio-wave i:nth-child(3) { height: 15px; }
.wa-audio-wave i:nth-child(4) { height: 24px; }

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

.wa-audio-body strong {
  display: block;
  margin-bottom: 4px;
  color: var(--wa-text-primary);
  font-size: 12px;
}

.wa-audio-body audio {
  width: 100%;
}

.wa-document-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 250px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--wa-text-primary);
  border: 1px solid var(--wa-border);
}

.wa-doc-icon {
  font-size: 22px;
}

.wa-doc-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
}

.wa-doc-download {
  color: var(--wa-accent-green);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

/* ─── Typing Indicator ─── */
.wa-typing {
  padding: 6px 16px;
  color: var(--wa-accent-blue);
  font-size: 12px;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

/* ─── Composer (Message Input) ─── */
.wa-composer {
  position: relative;
  z-index: 1;
  background: var(--wa-composer-bg);
  border-top: 1px solid var(--wa-border);
  padding: 12px 16px 14px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
  flex-shrink: 0;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.wa-composer-form {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.wa-composer-form textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  border: 1px solid var(--wa-border);
  outline: none;
  border-radius: 20px;
  background: var(--wa-bg-secondary);
  color: var(--wa-text-primary);
  padding: 10px 16px;
  font-family: inherit;
  line-height: 1.5;
  font-size: 14px;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03), 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wa-composer-form textarea:focus {
  border-color: var(--wa-accent-blue);
  box-shadow: inset 0 0 0 1px var(--wa-accent-blue);
}

.wa-composer-form textarea::placeholder {
  color: var(--wa-text-muted);
}

.wa-composer-btn {
  min-width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--wa-text-secondary);
  background: transparent;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
  font-size: 18px;
  cursor: pointer;
  border: none;
  padding: 0;
  flex-shrink: 0;
}

.wa-composer-btn:hover {
  background: rgba(0, 119, 204, 0.10);
  color: var(--wa-accent-blue);
  transform: scale(1.05);
}

.wa-composer-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.wa-composer-btn.recording {
  background: rgba(244, 67, 54, 0.16);
  color: #ff8a80;
  animation: waRecording 1s infinite;
}

@keyframes waRecording {
  50% {
    box-shadow: 0 0 0 6px rgba(244, 67, 54, 0.12);
  }
}

.wa-send-btn {
  min-width: 40px;
  height: 40px;
  border-radius: 20px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease, box-shadow .2s ease;
  cursor: pointer;
  border: none;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(30, 60, 114, 0.30);
}

.wa-send-btn:hover {
  background: linear-gradient(135deg, #2a5298, #1e3c72);
  box-shadow: 0 4px 12px rgba(30, 60, 114, 0.45);
  transform: translateY(-1px);
}

.wa-send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.wa-send-btn span {
  display: none;
}

@media (min-width: 768px) {
  .wa-send-btn span {
    display: inline;
  }
}

/* ─── Attachment Previews ─── */
.wa-composer-previews {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding: 0 50px 10px 50px;
  max-height: 120px;
  overflow-y: auto;
}

.wa-attachment-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  max-width: 320px;
  padding: 10px;
  border-radius: 12px;
  background: var(--wa-bg-secondary);
  border: 1px solid var(--wa-border);
  flex-shrink: 0;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.wa-attachment-preview:hover {
  border-color: rgba(0, 119, 204, 0.3);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.wa-attachment-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--wa-bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.wa-attachment-thumb img,
.wa-attachment-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wa-attachment-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

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

.wa-attachment-preview > button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #ff8a80;
  background: rgba(255, 255, 255, 0.06);
  font-size: 16px;
  cursor: pointer;
  border: none;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wa-attachment-preview > button:hover {
  background: rgba(255, 136, 128, 0.20);
  transform: scale(1.1);
}

.wa-file-preview-icon {
  font-size: 24px;
}

/* ─── Emoji Panel ─── */
.wa-emoji-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 50px;
  display: grid;
  grid-template-columns: repeat(6, 36px);
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
  background: var(--wa-bg-secondary);
  border: 1px solid var(--wa-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 119, 204, 0.1);
  z-index: 30;
  max-width: min(320px, calc(100vw - 32px));
  animation: emojiPanelIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes emojiPanelIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.wa-emoji-panel button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  border: none;
  background: transparent;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wa-emoji-panel button:hover {
  background: rgba(0, 119, 204, 0.12);
  transform: scale(1.15);
}

/* ─── Lightbox ─── */
.wa-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(5, 10, 14, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  backdrop-filter: blur(8px);
}

.wa-lightbox img {
  max-width: min(980px, 94vw);
  max-height: 88vh;
  border-radius: 14px;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.55);
}

.wa-lightbox-close {
  position: fixed;
  top: 18px;
  left: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  border: none;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}

.wa-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ─── Skeleton Loading ─── */
.wa-skeleton {
  height: 60px;
  margin: 10px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  animation: waPulse 1.4s infinite;
}

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

/* ─── Empty States ─── */
.wa-empty-chat,
.wa-empty-list {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--wa-text-muted);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

/* ─── Chat State ─── */
.wa-chat-state {
  padding: 10px 16px;
  color: var(--wa-text-secondary);
  font-size: 12px;
  text-align: center;
  background: rgba(0, 119, 204, 0.08);
  border: 1px solid rgba(0, 119, 204, 0.20);
  border-radius: 6px;
  margin: 8px 16px 0;
  flex-shrink: 0;
}

.wa-chat-state.error {
  color: var(--wa-accent-red);
  background: rgba(255, 107, 107, 0.08);
  border-color: rgba(255, 107, 107, 0.2);
}

.wa-billing-warning {
  background: rgba(255, 179, 0, 0.1);
  border: 1px solid rgba(255, 179, 0, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: waFadeIn 0.3s ease;
}

.wa-billing-warning-content {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--wa-accent-yellow);
  font-size: 13px;
  font-weight: 600;
}

.wa-billing-warning-icon {
  font-size: 18px;
}

.wa-billing-btn {
  background: var(--wa-accent-yellow);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.wa-billing-btn:hover {
  opacity: 0.9;
}

@keyframes waFadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive ─── */
@media (max-width: 980px) {

  .wa-inbox-shell {
    grid-template-columns: 1fr;
    height: 100%;
    overflow: hidden;
  }

  .wa-inbox-sidebar {
    max-height: 240px;
    min-height: 0;
    overflow-y: auto;
    border-left: none;
    border-bottom: 1px solid var(--wa-border);
    flex-shrink: 0;
  }

  .wa-chat-window {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  .wa-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px clamp(8px, 2vw, 20px);
  }

  .wa-composer {
    flex-shrink: 0;
    max-height: 160px;
  }

  .wa-bubble {
    max-width: 88%;
  }
}

@media (max-width: 640px) {
  .wa-inbox-sidebar {
    max-height: 200px;
  }

  .wa-inbox-sidebar-head {
    min-height: 52px;
    height: 52px;
    padding: 10px 12px;
  }

  .wa-inbox-sidebar-head h2 {
    font-size: 16px;
  }

  .wa-search {
    padding: 8px 10px;
  }

  .wa-search input {
    height: 32px;
    font-size: 12px;
  }

  .wa-conversation {
    padding: 8px 10px;
  }

  .wa-conversation-avatar {
    width: 40px;
    height: 40px;
    font-size: 13px;
  }

  .wa-chat-header {
    min-height: 52px;
    height: 52px;
    padding: 10px 12px;
  }

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

  .wa-chat-title strong {
    font-size: 13px;
  }

  .wa-chat-title span {
    font-size: 10px;
  }

  .wa-messages {
    padding: 8px clamp(6px, 2vw, 12px);
  }

  .wa-composer-previews {
    padding: 0 40px 8px 40px;
    max-height: 100px;
  }

  .wa-attachment-preview {
    min-width: 100%;
  }

  .wa-emoji-panel {
    right: 10px;
    left: 10px;
    max-width: calc(100vw - 20px);
    grid-template-columns: repeat(auto-fill, 36px);
  }

  .wa-audio-player {
    min-width: 200px;
  }

  .wa-bubble {
    max-width: 95%;
  }

  .wa-composer-form textarea {
    min-height: 36px;
    max-height: 100px;
    padding: 8px 12px;
    font-size: 13px;
  }

  .wa-composer-btn {
    min-width: 36px;
    height: 36px;
  }

  .wa-send-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
  }
}

/* ─── Scrollbar Styling ─── */
.wa-conversations::-webkit-scrollbar,
.wa-messages::-webkit-scrollbar {
  width: 6px;
}

.wa-conversations::-webkit-scrollbar-track,
.wa-messages::-webkit-scrollbar-track {
  background: transparent;
}

.wa-conversations::-webkit-scrollbar-thumb,
.wa-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 119, 204, 0.30);
  border-radius: 3px;
}

.wa-conversations::-webkit-scrollbar-thumb:hover,
.wa-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 119, 204, 0.50);
}

/* ─── Composer Scrollbar ─── */
.wa-composer::-webkit-scrollbar {
  width: 4px;
}

.wa-composer::-webkit-scrollbar-track {
  background: transparent;
}

.wa-composer::-webkit-scrollbar-thumb {
  background: rgba(0, 119, 204, 0.20);
  border-radius: 2px;
}

.wa-composer::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 119, 204, 0.40);
}

/* ─── Session Closed & Template Button Styles ─── */
.wa-session-closed-notice {
  padding: 20px;
  background: var(--wa-bg-secondary);
  border-top: 1px solid var(--wa-border);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 10;
}

.wa-session-closed-notice p {
  margin: 0;
  font-size: 13px;
  color: var(--wa-text-secondary);
  max-width: 400px;
  line-height: 1.6;
}

.wa-send-template-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--wa-accent-blue);
  color: white;
  border: none;
  border-radius: 24px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 119, 204, 0.25);
}

.wa-send-template-btn:hover {
  background: #0066b3;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 119, 204, 0.35);
}

.wa-send-template-btn svg, 
.wa-send-template-btn .wa-composer-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

/* Light Theme Overrides for Session Notice */
[data-wa-theme="light"] .wa-session-closed-notice {
  background: #f8f9fa;
  border-top-color: #e9ecef;
}

[data-wa-theme="light"] .wa-session-closed-notice p {
  color: #495057;
}
