/* ============================================================
   CACTUS RCS INBOX - STYLES
   ============================================================ */

/* Base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: #f9fafb;
  color: #111827;
  line-height: 1.5;
}

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

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s, opacity 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

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

.btn-primary {
  background-color: #10b981;
  color: white;
}

.btn-primary:hover {
  background-color: #059669;
}

.btn-secondary {
  background-color: #e5e7eb;
  color: #111827;
}

.btn-secondary:hover {
  background-color: #d1d5db;
}

.btn-danger {
  background-color: #f44336;
  color: white;
}

.btn-danger:hover {
  background-color: #e53935;
}

.btn-icon {
  padding: 8px 12px;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 16px;
}

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

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

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #10b981 0%, #065f46 100%);
}

.login-container {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 360px;
}

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

.login-header h1 {
  font-size: 32px;
  margin-bottom: 4px;
}

.login-header p {
  color: #6b7280;
  font-size: 14px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #4b5563;
}

.login-form input {
  width: 100%;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 16px;
}

.login-form input:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.login-form .btn {
  width: 100%;
  padding: 12px;
  font-size: 16px;
}

.error-message {
  background-color: #ffebee;
  color: #c62828;
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}

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

.app-container {
  display: flex;
  flex-direction: row;
  height: 100vh;
}

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

.app-sidebar {
  width: 240px;
  background: #111827;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  height: 100vh;
}

.sidebar-logo {
  padding: 20px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  border-bottom: 1px solid #1f2937;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: #10b981;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-logo-subtitle {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 400;
}

.sidebar-landing-link {
  text-decoration: none;
  border-bottom: 1px solid #1f2937;
}

.sidebar-external-icon {
  font-size: 12px;
  color: #6b7280;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.sidebar-section-title {
  padding: 12px 16px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 14px;
  color: #d1d5db;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.sidebar-item:hover {
  background: #1f2937;
  color: #fff;
}

.sidebar-item.active {
  background: #065f46;
  color: #6ee7b7;
}

.sidebar-item-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-item-name {
  flex: 1;
}

.sidebar-badge-live {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: #065f46;
  color: #6ee7b7;
  font-weight: 600;
}

.sidebar-badge-soon {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: #1f2937;
  color: #6b7280;
  font-weight: 500;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #1f2937;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

.sidebar-footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-footer .version-badge {
  font-size: 11px;
  color: #6b7280;
  background: #1f2937;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  align-self: flex-start;
}

.sidebar-footer .dark-mode-switch {
  font-size: 13px;
}

.sidebar-footer .dark-mode-switch .switch-icon {
  color: #9ca3af;
}

.sidebar-footer .sidebar-logout-btn {
  background: transparent;
  border: 1px solid #374151;
  color: #9ca3af;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s, color 0.2s;
}

.sidebar-footer .sidebar-logout-btn:hover {
  background: #1f2937;
  color: #f87171;
}

/* Main content area (right of sidebar) */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Placeholder modules (hidden by default) */
.module-placeholder {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-left h1 {
  font-size: 24px;
}

.header-subtitle {
  color: #6b7280;
  font-size: 14px;
}

.version-badge {
  font-size: 11px;
  color: #6b7280;
  background-color: #e5e7eb;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

/* Header Navigation */
.header-nav {
  display: flex;
  gap: 4px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: #6b7280;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s, color 0.2s;
}

.nav-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.nav-btn.active {
  background: #ecfdf5;
  color: #065f46;
}

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

/* ============================================================
   DARK MODE TOGGLE
   ============================================================ */

.dark-mode-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch-icon {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}

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

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #d1d5db;
  transition: 0.3s;
  border-radius: 22px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #10b981;
}

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

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

.inbox-container {
  display: grid;
  grid-template-columns: 320px 1fr 280px;
  grid-template-rows: 1fr;
  flex: 1;
  overflow: hidden;
  width: 100%;
  min-height: 0;
}

/* ============================================================
   CONVERSATION LIST
   ============================================================ */

.conversation-list {
  background: white;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  min-height: 0;
  align-self: stretch;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.list-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.list-header-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Search Box */
.search-box {
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.search-box input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
}

.search-box input:focus {
  outline: none;
  border-color: #10b981;
}

.conversations {
  flex: 1;
  overflow-y: auto;
}

.conversation-item {
  padding: 12px 16px 12px 24px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background-color 0.15s;
  position: relative;
}

.conversation-item:hover {
  background-color: #f9fafb;
}

.conversation-item.active {
  background-color: #ecfdf5;
  border-left: 3px solid #10b981;
  padding-left: 21px;
}

/* Unread Indicator */
.unread-dot {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: #2196f3;
  border-radius: 50%;
}

.conversation-item.active .unread-dot {
  left: 5px;
}

.conversation-phone {
  font-weight: 600;
  margin-bottom: 2px;
  font-size: 14px;
}

.conversation-name-display {
  font-weight: 600;
  font-size: 15px;
  color: #374151;
  margin-bottom: 2px;
}

.conversation-item.has-name .conversation-phone {
  font-weight: 400;
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.conversation-preview {
  font-size: 13px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-time {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

.loading, .empty-state {
  padding: 40px 20px;
  text-align: center;
  color: #9ca3af;
}

/* ============================================================
   CONVERSATION DETAIL
   ============================================================ */

.conversation-detail {
  display: flex;
  flex-direction: column;
  background: #fafafa;
  overflow: hidden;
  min-height: 0;
  max-height: 100%;
  align-self: stretch;
}

#conversation-view {
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.detail-header {
  padding: 16px 20px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-header-info {
  flex: 1;
}

.detail-header h3 {
  font-size: 18px;
  margin-bottom: 2px;
}

.detail-header-name {
  font-size: 14px;
  color: #6b7280;
}

.detail-header-name:empty {
  display: none;
}

.detail-header-actions {
  display: flex;
  gap: 8px;
}

.archived-badge {
  display: inline-block;
  font-size: 11px;
  color: #6b7280;
  background-color: #e5e7eb;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
}

.campaign-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #00695c;
  background-color: rgba(0, 150, 136, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.3px;
}

/* Campaign badge in conversation list */
.conversation-item .campaign-badge {
  margin-left: 6px;
  vertical-align: middle;
}

/* Campaign badge in conversation detail header */
.detail-header-info .campaign-badge {
  margin-top: 4px;
}

/* Campaign badge on individual messages */
.message-campaign {
  font-size: 10px;
  font-weight: 600;
  color: #00695c;
  background-color: rgba(0, 150, 136, 0.15);
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 4px;
}

.message.outbound .message-campaign {
  background: rgba(255, 255, 255, 0.2);
  color: #e0f2f1;
}

/* Archive toggle in conversation list */
.archive-toggle {
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
}

.archive-toggle .toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #6b7280;
  cursor: pointer;
}

.archive-toggle input[type="checkbox"] {
  cursor: pointer;
}

/* Archived conversation indicator in list */
.conversation-item.archived {
  opacity: 0.7;
}

.conversation-item.archived::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: #9ca3af;
}

/* Messages */
.messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 12px;
  position: relative;
}

.message.inbound {
  align-self: flex-start;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px 12px 12px 4px;
}

.message.outbound {
  align-self: flex-end;
  background: #10b981;
  color: white;
  border-radius: 12px 12px 4px 12px;
}

.message-content {
  word-wrap: break-word;
  line-height: 1.4;
}

.message-meta {
  font-size: 11px;
  margin-top: 6px;
  opacity: 0.7;
  display: flex;
  gap: 8px;
  align-items: center;
}

.message.outbound .message-meta {
  color: rgba(255, 255, 255, 0.8);
}

.message-template {
  font-size: 10px;
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  margin-top: 4px;
  display: inline-block;
}

.message.outbound .message-template {
  background: rgba(255, 255, 255, 0.2);
}

/* Status Badges */
.status-badge {
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
}

.status-delivered {
  background: rgba(16, 185, 129, 0.2);
  color: #065f46;
}

.status-sent, .status-pending {
  background: rgba(255, 152, 0, 0.2);
  color: #e65100;
}

.status-read {
  background: rgba(33, 150, 243, 0.2);
  color: #1565c0;
}

.status-failed {
  background: rgba(244, 67, 54, 0.2);
  color: #c62828;
}

.message.outbound .status-badge {
  background: rgba(255, 255, 255, 0.2);
}

.message.outbound .status-delivered {
  color: white;
}

.message.outbound .status-pending, .message.outbound .status-sent {
  color: #fff3e0;
}

.message.outbound .status-failed {
  color: #ffcdd2;
}

/* ============================================================
   REPLY AREA
   ============================================================ */

.reply-area {
  padding: 16px 20px;
  background: white;
  border-top: 1px solid #e5e7eb;
}

.reply-input-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.textarea-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.textarea-wrapper textarea,
.reply-input-row > textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
}

.textarea-wrapper textarea:focus,
.reply-input-row > textarea:focus {
  outline: none;
  border-color: #10b981;
}

.textarea-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.keyboard-hint {
  font-size: 12px;
  color: #9ca3af;
}

.char-counter {
  font-size: 12px;
  color: #9ca3af;
}

.char-counter.warning {
  color: #ff9800;
}

.char-counter.danger {
  color: #f44336;
}

.template-row {
  display: flex;
  gap: 12px;
}

.template-row select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  background: white;
}

/* ============================================================
   QUICK TEMPLATE PANEL (INBOX RIGHT SIDE)
   ============================================================ */

.template-panel {
  background: white;
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  min-height: 0;
  align-self: stretch;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.panel-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.template-list {
  flex: 1;
  overflow-y: auto;
}

.template-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background-color 0.15s;
}

.template-item:hover {
  background-color: #f9fafb;
}

.template-item.active {
  background-color: #ecfdf5;
}

.template-item-name {
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
}

.template-item-desc {
  font-size: 12px;
  color: #6b7280;
}

/* ============================================================
   TEMPLATE CATEGORIES
   ============================================================ */

.template-category {
  border-bottom: 1px solid #e5e7eb;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #f9fafb;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s;
}

.category-header:hover {
  background: #ebebeb;
}

.category-arrow {
  font-size: 12px;
  width: 12px;
  color: #6b7280;
  transition: transform 0.15s;
}

.template-category.collapsed .category-arrow {
  transform: rotate(-90deg);
}

.category-name {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #4b5563;
  flex: 1;
}

.category-count {
  font-size: 11px;
  color: #9ca3af;
  background: #e5e7eb;
  padding: 2px 8px;
  border-radius: 10px;
}

.category-items {
  display: block;
}

.template-category.collapsed .category-items {
  display: none;
}

.template-preview-area {
  border-top: 1px solid #e5e7eb;
  padding: 16px;
  background: #fafafa;
}

.template-preview-area h4 {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 12px;
  font-weight: 500;
}

.preview-bubble {
  background: #10b981;
  color: white;
  padding: 12px 16px;
  border-radius: 12px 12px 4px 12px;
  font-size: 14px;
  line-height: 1.4;
}

/* ============================================================
   TEMPLATE MANAGER VIEW
   ============================================================ */

.templates-container {
  display: grid;
  grid-template-columns: 200px 1fr 400px;
  grid-template-rows: 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.templates-list-panel {
  background: white;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  min-height: 0;
  align-self: stretch;
}

/* Template Editor */
.template-editor {
  padding: 0;
  overflow: hidden;
  background: #fafafa;
  min-height: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
}

.editor-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-height: 0;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.editor-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.editor-mode-toggle {
  display: flex;
  gap: 2px;
  background: #f3f4f6;
  padding: 3px;
  border-radius: 8px;
}

.mode-btn {
  padding: 7px 18px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: #6b7280;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-btn:hover {
  color: #374151;
}

.mode-btn.active {
  background: white;
  color: #059669;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Visual Composer full-screen view */
.visual-composer-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #f9fafb;
}

.visual-composer-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.visual-composer-back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.visual-composer-back:hover {
  background: #f9fafb;
  border-color: #10b981;
  color: #059669;
}

.visual-composer-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  background: #f3f4f6;
  padding: 4px 10px;
  border-radius: 4px;
}

.editor-form {
  max-width: 600px;
}

/* JSON editor should be wider for full payloads */
#json-editor {
  max-width: none;
}

.editor-form .form-group {
  margin-bottom: 20px;
}

/* Template Settings (name, auto-reply, keywords) */
.template-settings {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

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

.template-settings .form-group:last-child {
  margin-bottom: 0;
}

.template-settings label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 6px;
}

.template-settings input,
.template-settings select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.template-settings input:focus,
.template-settings select:focus {
  outline: none;
  border-color: #4CAF50;
}

/* Collapsible Form Sections (unused but kept for compatibility) */
.form-section {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}

.form-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #fafafa;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: background-color 0.2s;
}

.form-section-header:hover {
  background: #f0f0f0;
}

.form-section.open .form-section-header {
  border-bottom-color: #e5e7eb;
}

.section-title {
  font-weight: 600;
  font-size: 14px;
  color: #374151;
}

.section-toggle {
  font-size: 12px;
  color: #6b7280;
  transition: transform 0.2s;
}

.form-section:not(.open) .section-toggle {
  transform: rotate(-90deg);
}

.form-section-content {
  padding: 16px;
  display: none;
}

.form-section.open .form-section-content {
  display: block;
}

/* Form row for side-by-side fields */
.form-row {
  display: flex;
  gap: 16px;
}

.form-group-half {
  flex: 1;
}

.editor-form label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #374151;
  font-size: 14px;
}

.label-hint {
  font-weight: normal;
  color: #9ca3af;
  font-size: 12px;
}

.editor-form input,
.editor-form textarea:not(.json-textarea),
.editor-form select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.editor-form input:focus,
.editor-form textarea:not(.json-textarea):focus,
.editor-form select:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.editor-form textarea:not(.json-textarea) {
  resize: vertical;
  min-height: 80px;
}

/* Character Limit Hint */
.char-limit-hint {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
}

.char-limit-hint.warning {
  color: #ff9800;
}

.char-limit-hint.over {
  color: #f44336;
}

/* Suggested Replies */
.suggested-replies-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.reply-item {
  display: flex;
  gap: 8px;
  align-items: center;
}

.reply-item input {
  flex: 1;
}

.reply-item .reply-postback {
  font-family: 'Monaco', 'Menlo', monospace;
  font-size: 13px;
}

.btn-remove-reply {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 20px;
  cursor: pointer;
  padding: 0 8px;
  line-height: 1;
}

.btn-remove-reply:hover {
  color: #f44336;
}

/* ============================================================
   JSON EDITOR - Enhanced with syntax highlighting
   ============================================================ */

.json-editor-container {
  display: flex;
  flex-direction: column;
  border: 1px solid #374151;
  border-radius: 8px;
  overflow: hidden;
  background: #111827;
  max-width: 100%;
}

/* Toolbar */
.json-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #1f2937;
  border-bottom: 1px solid #4b5563;
}

.json-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.json-toolbar-label {
  font-size: 12px;
  color: #9ca3af;
  font-weight: 500;
}

.json-toolbar-right {
  display: flex;
  gap: 4px;
}

.json-toolbar-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: #4b5563;
  border: none;
  border-radius: 4px;
  color: #d1d5db;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.json-toolbar-btn:hover {
  background: #505050;
  color: #fff;
}

.json-toolbar-btn:active {
  background: #606060;
}

.toolbar-icon {
  font-size: 11px;
}

/* Editor wrapper with line numbers */
.json-editor-wrapper {
  display: flex;
  flex: 1;
  min-height: 500px;
  max-height: 700px;
  overflow: hidden;
}

.json-line-numbers {
  flex-shrink: 0;
  width: 48px;
  padding: 12px 8px;
  background: #1f2937;
  border-right: 1px solid #4b5563;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #9ca3af;
  text-align: right;
  user-select: none;
  overflow: hidden;
}

.json-line-numbers span {
  display: block;
}

/* Input wrapper with overlay for highlighting */
.json-input-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #111827;
}

.json-highlight {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 12px;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  pointer-events: none;
  overflow: auto;
  z-index: 1;
  color: #BABED8; /* Base color for any unmatched text */
}

.json-textarea {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 450px;
  margin: 0;
  padding: 12px;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.5;
  background: transparent;
  color: transparent;
  border: none;
  resize: none;
  outline: none;
  caret-color: #fff;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
  z-index: 2;
}

.json-textarea::placeholder {
  color: #6b7280;
}

.json-textarea::selection {
  background: rgba(100, 150, 255, 0.3);
}

/* Syntax highlighting colors - Postman style */
/* Using simple HTML elements: mark=keys, i=strings, u=numbers, em=booleans, s=null, var=brackets, kbd=punctuation */
.json-highlight mark {
  color: #9cdcfe; /* Light blue for keys - Postman style */
  background: none;
}

.json-highlight i {
  color: #ce9178; /* Orange/salmon for strings - Postman style */
  font-style: normal;
}

.json-highlight u {
  color: #b5cea8; /* Light green for numbers - Postman style */
  text-decoration: none;
}

.json-highlight em {
  color: #56b6c2; /* Teal for booleans - Postman style */
  font-style: normal;
}

.json-highlight s {
  color: #f87171; /* Red for null */
  text-decoration: none;
}

.json-highlight var {
  color: #abb2bf; /* Light gray for brackets - Postman style */
  font-style: normal;
}

.json-highlight kbd {
  color: #abb2bf; /* Light gray for punctuation - Postman style */
  font-family: inherit;
}

/* Status bar */
.json-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #1f2937;
  border-top: 1px solid #4b5563;
  min-height: 32px;
}

.json-error {
  color: #f48771;
  font-size: 12px;
  flex: 1;
}

.json-error:empty {
  display: none;
}

.json-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #9ca3af;
}

.status-separator {
  color: #4b5563;
}

.validity-valid {
  color: #89d185;
}

.validity-invalid {
  color: #f48771;
}

/* Copy success feedback */
.json-toolbar-btn.copied {
  background: #065f46;
  color: white;
}

/*
 * JSON Editor is always dark (like VS Code) regardless of app theme.
 * All colors are explicitly set for consistency.
 */
.json-editor-container {
  background: #111827;
  border-color: #374151;
}

.json-editor-container .json-toolbar {
  background: #1f2937;
  border-bottom-color: #4b5563;
}

.json-editor-container .json-toolbar-label {
  color: #d1d5dbccc;
}

.json-editor-container .json-toolbar-btn {
  background: #4b5563;
  color: #d1d5dbccc;
  border: none;
}

.json-editor-container .json-toolbar-btn:hover {
  background: #505050;
  color: #ffffff;
}

.json-editor-container .json-line-numbers {
  background: #111827;
  border-right-color: #374151;
  color: #9ca3af;
}

.json-editor-container .json-highlight {
  color: #BABED8; /* Ensure base text color is always light */
}

.json-editor-container .json-status-bar {
  background: #111827;
  border-top-color: #374151;
}

.json-editor-container .json-status {
  color: #9ca3af;
}

.json-editor-container .status-separator {
  color: #4b5563;
}

.json-editor-container .validity-valid {
  color: #89d185;
}

.json-editor-container .validity-invalid {
  color: #f48771;
}

.json-editor-container .json-error {
  color: #f48771;
}

.editor-actions {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
  background: #fafafa;
  flex-shrink: 0;
}

/* Template Preview Panel */
.template-preview-panel {
  background: #f0f2f5;
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  align-self: stretch;
}

.preview-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: white;
  flex-shrink: 0;
}

.preview-panel-header h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.preview-panel-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Phone Mockup Frame - Simplified iPhone-style design */
.phone-mockup {
  background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
  border-radius: 32px;
  padding: 8px;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  width: 280px;
  flex-shrink: 0;
  margin-bottom: 16px;
}

.phone-notch {
  width: 80px;
  height: 20px;
  background: #111827;
  border-radius: 0 0 14px 14px;
  margin: 0 auto;
  position: relative;
  z-index: 10;
  margin-bottom: -10px;
}

.phone-screen {
  background: #f9fafb;
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 420px;
}

.phone-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 16px;
  font-size: 11px;
  font-weight: 600;
  background: #f9fafb;
  flex-shrink: 0;
}

.status-time {
  color: #111827;
}

.status-icons {
  display: flex;
  gap: 3px;
  font-size: 9px;
}

.signal-icon {
  letter-spacing: -2px;
}

.phone-header {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  background: #10b981;
  color: white;
  gap: 6px;
  flex-shrink: 0;
}

.phone-back-btn {
  font-size: 18px;
  font-weight: 300;
  cursor: pointer;
  width: 20px;
}

.phone-contact {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.phone-contact-avatar {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
}

.phone-contact-info {
  display: flex;
  flex-direction: column;
}

.phone-contact-name {
  font-weight: 600;
  font-size: 13px;
}

.phone-contact-status {
  font-size: 10px;
  opacity: 0.9;
}

.phone-more-btn {
  font-size: 16px;
  cursor: pointer;
  padding: 2px;
}

.phone-messages {
  flex: 1;
  padding: 8px;
  background: #e5e7eb;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.phone-input-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: white;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.phone-input-placeholder {
  color: #9ca3af;
  font-size: 12px;
}

.phone-send-btn {
  color: #10b981;
  font-size: 14px;
  cursor: pointer;
}

.phone-home-indicator {
  width: 100px;
  height: 3px;
  background: #6b7280;
  border-radius: 2px;
  margin: 6px auto 2px;
  flex-shrink: 0;
}

/* Adjust preview content inside phone */
.phone-messages .preview-bubble {
  background: white;
  border-radius: 18px;
  border-bottom-right-radius: 4px;
  padding: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  margin-left: auto;
  max-width: 95%;
}

.phone-messages .preview-replies {
  justify-content: flex-end;
}

/* Legacy device mockup (hidden but kept for compatibility) */
.preview-device {
  display: none;
}

.preview-device-header {
  background: #10b981;
  color: white;
  padding: 12px 16px;
}

.preview-device-title {
  font-weight: 600;
  display: block;
}

.preview-device-subtitle {
  font-size: 12px;
  opacity: 0.9;
}

.preview-device-body {
  padding: 16px;
  background: #f0f0f0;
  min-height: 120px;
}

/* Preview Reply Chips */
.preview-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.preview-chip {
  background: #ecfdf5;
  color: #065f46;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  border: 1px solid #c8e6c9;
}

/* Preview Meta */
.preview-meta {
  background: white;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.preview-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
}

.preview-meta-label {
  color: #9ca3af;
}

/* SMS Fallback Preview */
.preview-sms-section {
  background: white;
  border-radius: 8px;
  padding: 12px 16px;
}

.preview-sms-section h4 {
  font-size: 12px;
  color: #9ca3af;
  margin: 0 0 8px 0;
  font-weight: 500;
}

.preview-sms {
  background: #f9fafb;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #6b7280;
}

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

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-content.modal-sm {
  max-width: 340px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-header .btn-icon {
  border: none;
  font-size: 24px;
  padding: 4px 8px;
  color: #6b7280;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

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

.modal-body label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #4b5563;
}

.modal-body input,
.modal-body textarea,
.modal-body select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.modal-body textarea {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  display: block;
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  background: #fafafa;
}

/* Phone Input Group */
.phone-input-group {
  display: flex;
  gap: 8px;
}

.phone-input-group select {
  width: 110px;
  flex-shrink: 0;
}

.phone-input-group input {
  flex: 1;
}

/* ============================================================
   INTEGRATIONS VIEW
   ============================================================ */

.integrations-container {
  display: grid;
  grid-template-columns: 200px 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Left Panel: Integration List */
.integrations-list-panel {
  background: white;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}

.integrations-list {
  flex: 1;
  overflow-y: auto;
}

.integration-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
}

.integration-item:hover {
  background: #f9fafb;
}

.integration-item.active {
  background: #ecfdf5;
  border-left: 3px solid #10b981;
  padding-left: 13px;
}

.integration-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.integration-icon {
  font-size: 20px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9fafb;
  border-radius: 8px;
}

.integration-icon-img img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.integration-info {
  flex: 1;
}

.integration-name {
  font-weight: 500;
  font-size: 14px;
}

.integration-status {
  font-size: 11px;
  margin-top: 2px;
  color: #065f46;
}

.integration-status.muted {
  color: #9ca3af;
}

/* Center Panel: Configuration */
.integration-config-panel {
  display: flex;
  flex-direction: column;
  background: #fafafa;
  overflow: hidden;
  min-height: 0;
}

.integration-config-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.config-panel-header {
  padding: 16px 24px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
}

.config-panel-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.config-panel-title h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.active {
  background: #ecfdf5;
  color: #065f46;
}

/* MOCKUP Badge - obvious indicator */
.mockup-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: #ff9800;
  color: white;
  animation: mockup-pulse 2s ease-in-out infinite;
}

@keyframes mockup-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.config-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.config-section {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.config-section h3 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
}

.config-description {
  margin: 0 0 12px 0;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
}

.config-description code {
  background: #f9fafb;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 12px;
}

/* Copyable Field */
.copyable-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px 12px;
}

.copyable-field code {
  flex: 1;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 13px;
  color: #374151;
  word-break: break-all;
}

.copyable-field code.masked {
  letter-spacing: 2px;
  color: #9ca3af;
}

/* Code Block */
.code-block {
  position: relative;
  background: #111827;
  border-radius: 6px;
  overflow: hidden;
}

.code-block pre {
  margin: 0;
  padding: 16px;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 13px;
  color: #d4d4d4;
  line-height: 1.6;
  overflow-x: auto;
}

.code-block .code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  color: #d1d5db;
}

.code-block .code-copy-btn:hover {
  background: rgba(255,255,255,0.2);
}

/* Template Chips */
.template-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px 12px;
}

.template-chip-name {
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 13px;
}

/* Right Panel: Logs */
.integration-logs-panel {
  background: white;
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}

.logs-filters {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
}

.logs-filters select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
  background: white;
}

.logs-list {
  flex: 1;
  overflow-y: auto;
}

.log-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
}

.log-item:hover {
  background: #f9f9f9;
}

.log-status-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
}

.log-status-icon.success { color: #10b981; }
.log-status-icon.failed { color: #f44336; }
.log-status-icon.invalid { color: #ff9800; }

.log-summary {
  flex: 1;
  min-width: 0;
}

.log-phone {
  font-size: 13px;
  font-weight: 500;
}

.log-template {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-time {
  font-size: 11px;
  color: #9ca3af;
}

/* ============================================================
   DARK MODE
   ============================================================ */

body.dark {
  background: #111827;
  color: #e5e7eb;
}

body.dark .app-header {
  background: #1f2937;
  border-color: #374151;
}

body.dark .main-content {
  background: #111827;
}

body.dark .header-subtitle {
  color: #9ca3af;
}

body.dark .version-badge {
  background-color: #374151;
  color: #9ca3af;
}

body.dark .switch-icon {
  color: #9ca3af;
}

/* Dark Mode Navigation */
body.dark .nav-btn {
  color: #9ca3af;
}

body.dark .nav-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

body.dark .nav-btn.active {
  background: #065f46;
  color: #6ee7b7;
}

/* Dark Mode Buttons */
body.dark .btn-secondary {
  background: #374151;
  color: #e5e7eb;
}

body.dark .btn-secondary:hover {
  background: #4b5563;
}

body.dark .btn-icon {
  border-color: #4b5563;
  color: #9ca3af;
}

body.dark .btn-icon:hover {
  background: #374151;
  color: #e5e7eb;
}

body.dark .btn-danger {
  background: #c62828;
}

body.dark .btn-danger:hover {
  background: #b71c1c;
}

/* Dark Mode Conversation List */
body.dark .conversation-list {
  background: #1f2937;
  border-color: #374151;
}

body.dark .list-header {
  border-color: #374151;
}

body.dark .search-box {
  border-color: #374151;
}

body.dark .search-box input {
  background: #111827;
  border-color: #374151;
  color: #e5e7eb;
}

body.dark .conversation-item {
  border-color: #374151;
}

body.dark .conversation-item:hover {
  background: #374151;
}

body.dark .conversation-item.active {
  background: #065f46;
  border-left-color: #10b981;
}

body.dark .conversation-phone {
  color: #e5e7eb;
}

body.dark .conversation-name-display {
  color: #e5e7eb;
}

body.dark .conversation-item.has-name .conversation-phone {
  color: #9ca3af;
}

body.dark .conversation-preview {
  color: #9ca3af;
}

body.dark .conversation-time {
  color: #6b7280;
}

/* Dark Mode Conversation Detail */
body.dark .conversation-detail {
  background: #111827;
}

body.dark .detail-header {
  background: #1f2937;
  border-color: #374151;
}

body.dark .detail-header h3 {
  color: #e5e7eb;
}

body.dark .detail-header-name {
  color: #9ca3af;
}

body.dark .archived-badge {
  background-color: #374151;
  color: #9ca3af;
}

body.dark .campaign-badge {
  background-color: rgba(0, 150, 136, 0.25);
  color: #4db6ac;
}

body.dark .message-campaign {
  background-color: rgba(0, 150, 136, 0.25);
  color: #4db6ac;
}

body.dark .archive-toggle {
  border-color: #374151;
}

body.dark .archive-toggle .toggle-label {
  color: #9ca3af;
}

body.dark .conversation-item.archived::before {
  background-color: #4b5563;
}

body.dark .message.inbound {
  background: #374151;
  border-color: #374151;
  color: #e5e7eb;
}

/* Dark Mode Reply Area */
body.dark .reply-area {
  background: #1f2937;
  border-color: #374151;
}

body.dark .reply-area textarea {
  background: #111827;
  border-color: #374151;
  color: #e5e7eb;
}

body.dark .reply-area select {
  background: #111827;
  border-color: #374151;
  color: #e5e7eb;
}

body.dark .keyboard-hint {
  color: #6b7280;
}

body.dark .char-counter {
  color: #6b7280;
}

/* Dark Mode Status Badges */
body.dark .status-delivered {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

body.dark .status-pending, body.dark .status-sent {
  background: rgba(255, 152, 0, 0.15);
  color: #ffb74d;
}

body.dark .status-failed {
  background: rgba(244, 67, 54, 0.15);
  color: #ef9a9a;
}

/* Dark Mode Template Panel */
body.dark .template-panel {
  background: #1f2937;
  border-color: #374151;
}

body.dark .panel-header {
  border-color: #374151;
}

body.dark .template-item {
  border-color: #374151;
}

body.dark .template-item:hover {
  background: #374151;
}

body.dark .template-item.active {
  background: #065f46;
}

body.dark .template-item-name {
  color: #e5e7eb;
}

body.dark .template-item-desc {
  color: #9ca3af;
}

/* Dark Mode Template Categories */
body.dark .template-category {
  border-color: #374151;
}

body.dark .category-header {
  background: #1f2937;
}

body.dark .category-header:hover {
  background: #4b5563;
}

body.dark .category-name {
  color: #d1d5db;
}

body.dark .category-count {
  background: #4b5563;
  color: #9ca3af;
}

body.dark .category-arrow {
  color: #9ca3af;
}

body.dark .template-preview-area {
  background: #111827;
  border-color: #374151;
}

body.dark .template-preview-area h4 {
  color: #9ca3af;
}

/* Dark Mode Templates View */
body.dark .templates-list-panel {
  background: #1f2937;
  border-color: #374151;
}

body.dark .template-editor {
  background: #111827;
}

body.dark .editor-header h3 {
  color: #e5e7eb;
}

body.dark .editor-mode-toggle {
  background: #374151;
}

body.dark .mode-btn {
  color: #9ca3af;
}

body.dark .mode-btn.active {
  background: #4b5563;
  color: #e5e7eb;
}

body.dark .visual-composer-topbar {
  background: #1f2937;
  border-color: #374151;
}

body.dark .visual-composer-back {
  background: #1f2937;
  border-color: #4b5563;
  color: #e5e7eb;
}

body.dark .visual-composer-back:hover {
  border-color: #10b981;
  color: #6ee7b7;
}

body.dark .visual-composer-badge {
  background: #374151;
  color: #9ca3af;
}

body.dark .editor-form label {
  color: #d1d5db;
}

body.dark .label-hint {
  color: #6b7280;
}

body.dark .editor-form input,
body.dark .editor-form textarea:not(.json-textarea),
body.dark .editor-form select {
  background: #1f2937;
  border-color: #374151;
  color: #e5e7eb;
}

body.dark .editor-form input:focus,
body.dark .editor-form textarea:not(.json-textarea):focus,
body.dark .editor-form select:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

body.dark .char-limit-hint {
  color: #6b7280;
}

body.dark .btn-remove-reply {
  color: #6b7280;
}

body.dark .btn-remove-reply:hover {
  color: #ef9a9a;
}

body.dark .editor-actions {
  border-color: #374151;
  background: #111827;
}

/* Dark Mode Preview Panel */
body.dark .template-preview-panel {
  background: #111827;
  border-color: #374151;
}

body.dark .preview-panel-header {
  background: #1f2937;
  border-color: #374151;
}

body.dark .preview-panel-header h3 {
  color: #e5e7eb;
}

body.dark .preview-device {
  background: #1f2937;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark .preview-device-body {
  background: #111827;
}

body.dark .preview-chip {
  background: #065f46;
  color: #6ee7b7;
  border-color: #065f46;
}

body.dark .preview-meta {
  background: #1f2937;
}

body.dark .preview-meta-row {
  color: #e5e7eb;
}

body.dark .preview-meta-label {
  color: #9ca3af;
}

body.dark .preview-sms-section {
  background: #1f2937;
}

body.dark .preview-sms-section h4 {
  color: #9ca3af;
}

body.dark .preview-sms {
  background: #374151;
  color: #9ca3af;
}

/* Dark Mode Form Sections */
/* Dark mode template settings */
body.dark .template-settings {
  background: #1f2937;
  border-color: #4b5563;
}

body.dark .template-settings label {
  color: #e5e7eb;
}

body.dark .template-settings input,
body.dark .template-settings select {
  background: #111827;
  border-color: #4b5563;
  color: #e5e7eb;
}

body.dark .template-settings input:focus,
body.dark .template-settings select:focus {
  border-color: #4CAF50;
}

body.dark .form-section {
  background: #1f2937;
  border-color: #4b5563;
}

body.dark .form-section-header {
  background: #374151;
}

body.dark .form-section-header:hover {
  background: #374151;
}

body.dark .form-section.open .form-section-header {
  border-bottom-color: #4b5563;
}

body.dark .section-title {
  color: #e5e7eb;
}

body.dark .section-toggle {
  color: #9ca3af;
}

/* Dark Mode Phone Mockup */
body.dark .phone-mockup {
  background: #0c1220;
  box-shadow:
    0 0 0 2px #222,
    0 20px 40px rgba(0, 0, 0, 0.5),
    inset 0 0 0 2px #111827;
}

body.dark .phone-notch {
  background: #0c1220;
}

body.dark .phone-screen {
  background: #111827;
}

body.dark .phone-status-bar {
  background: #111827;
}

body.dark .status-time {
  color: #e5e7eb;
}

body.dark .phone-messages {
  background: #1f2937;
}

body.dark .phone-input-bar {
  background: #111827;
  border-top-color: #374151;
}

body.dark .phone-input-placeholder {
  color: #6b7280;
}

body.dark .phone-home-indicator {
  background: #4b5563;
}

body.dark .phone-messages .preview-bubble {
  background: #374151;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Dark Mode Modal */
body.dark .modal-backdrop {
  background: rgba(0, 0, 0, 0.7);
}

body.dark .modal-content {
  background: #1f2937;
}

body.dark .modal-header {
  border-color: #374151;
}

body.dark .modal-header h3 {
  color: #e5e7eb;
}

body.dark .modal-header .btn-icon {
  color: #9ca3af;
}

body.dark .modal-body label {
  color: #d1d5db;
}

body.dark .modal-body input,
body.dark .modal-body textarea,
body.dark .modal-body select {
  background: #111827;
  border-color: #374151;
  color: #e5e7eb;
}

body.dark .form-hint {
  color: #9ca3af;
}

body.dark .modal-footer {
  border-color: #374151;
  background: #111827;
}

body.dark .loading, body.dark .empty-state {
  color: #6b7280;
}

/* Dark Mode Integrations */
body.dark .integrations-list-panel {
  background: #1f2937;
  border-color: #374151;
}

body.dark .integration-item {
  border-color: #374151;
}

body.dark .integration-item:hover {
  background: #374151;
}

body.dark .integration-item.active {
  background: #065f46;
}

body.dark .integration-icon {
  background: #374151;
}

body.dark .integration-name {
  color: #e5e7eb;
}

body.dark .integration-status {
  color: #6ee7b7;
}

body.dark .integration-status.muted {
  color: #6b7280;
}

body.dark .integration-config-panel {
  background: #111827;
}

body.dark .integration-config-content .config-content {
  background: #111827;
}

body.dark .config-panel-header {
  background: #1f2937;
  border-color: #374151;
}

body.dark .config-panel-title h2 {
  color: #e5e7eb;
}

body.dark .status-badge.active {
  background: #065f46;
  color: #6ee7b7;
}

body.dark .config-section {
  background: #1f2937;
  border-color: #374151;
}

body.dark .config-section h3 {
  color: #e5e7eb;
}

body.dark .config-description {
  color: #aaa;
}

body.dark .config-description code {
  background: #374151;
  color: #e5e7eb;
}

body.dark .copyable-field {
  background: #111827;
  border-color: #374151;
}

body.dark .copyable-field code {
  color: #e5e7eb;
}

body.dark .template-chip {
  background: #374151;
  border-color: #4b5563;
}

body.dark .template-chip-name {
  color: #e5e7eb;
}

body.dark .integration-logs-panel {
  background: #1f2937;
  border-color: #374151;
}

body.dark .logs-filters {
  border-color: #374151;
}

body.dark .logs-filters select {
  background: #111827;
  border-color: #374151;
  color: #e5e7eb;
}

body.dark .log-item {
  border-color: #374151;
}

body.dark .log-item:hover {
  background: #374151;
}

body.dark .log-phone {
  color: #e5e7eb;
}

body.dark .log-template {
  color: #9ca3af;
}

body.dark .log-time {
  color: #6b7280;
}

/* ============================================================
   DARK MODE - PLACEHOLDER MODULES
   ============================================================ */

/* Outer gradient containers → dark background */
body.dark .module-placeholder > div {
  background: #111827 !important;
}

/* White cards → dark cards */
body.dark .module-placeholder .bg-white {
  background-color: #1f2937 !important;
  border-color: #374151 !important;
}

/* Gray-50 backgrounds → dark */
body.dark .module-placeholder .bg-gray-50 {
  background-color: #374151 !important;
}

/* Colored light backgrounds (green-50, yellow-50, red-50, blue-50, etc.) → dark tinted */
body.dark .module-placeholder .bg-green-50 {
  background-color: #1a2e1a !important;
}

body.dark .module-placeholder .bg-yellow-50 {
  background-color: #2e2a1a !important;
}

body.dark .module-placeholder .bg-red-50 {
  background-color: #2e1a1a !important;
}

body.dark .module-placeholder .bg-blue-50 {
  background-color: #1a1a2e !important;
}

body.dark .module-placeholder .bg-amber-50 {
  background-color: #2e2a1a !important;
}

/* Gray-100 backgrounds */
body.dark .module-placeholder .bg-gray-100 {
  background-color: #374151 !important;
}

/* Text color overrides: dark text → light text */
body.dark .module-placeholder .text-gray-900 {
  color: #e5e7eb !important;
}

body.dark .module-placeholder .text-gray-800 {
  color: #d1d5db !important;
}

body.dark .module-placeholder .text-gray-700 {
  color: #bbb !important;
}

body.dark .module-placeholder .text-gray-600 {
  color: #9ca3af !important;
}

body.dark .module-placeholder .text-gray-500 {
  color: #9ca3af !important;
}

body.dark .module-placeholder .text-gray-400 {
  color: #777 !important;
}

/* Border overrides */
body.dark .module-placeholder .border-gray-200 {
  border-color: #4b5563 !important;
}

body.dark .module-placeholder .border-gray-100 {
  border-color: #374151 !important;
}

body.dark .module-placeholder .border-gray-300 {
  border-color: #4b5563 !important;
}

/* Colored borders in dark mode */
body.dark .module-placeholder .border-green-200 {
  border-color: #2d5a2d !important;
}

body.dark .module-placeholder .border-green-300 {
  border-color: #2d5a2d !important;
}

body.dark .module-placeholder .border-yellow-200 {
  border-color: #5a5a2d !important;
}

body.dark .module-placeholder .border-red-200 {
  border-color: #5a2d2d !important;
}

body.dark .module-placeholder .border-blue-200 {
  border-color: #2d2d5a !important;
}

body.dark .module-placeholder .border-cyan-300 {
  border-color: #2d4a5a !important;
}

body.dark .module-placeholder .border-orange-300 {
  border-color: #5a3d2d !important;
}

body.dark .module-placeholder .border-purple-300 {
  border-color: #3d2d5a !important;
}

body.dark .module-placeholder .border-indigo-300 {
  border-color: #2d2d5a !important;
}

body.dark .module-placeholder .border-amber-300 {
  border-color: #5a4a2d !important;
}

body.dark .module-placeholder .border-emerald-300 {
  border-color: #2d5a3d !important;
}

body.dark .module-placeholder .border-teal-300 {
  border-color: #2d5a4a !important;
}

body.dark .module-placeholder .border-red-300 {
  border-color: #5a2d2d !important;
}

body.dark .module-placeholder .border-rose-300 {
  border-color: #5a2d3d !important;
}

/* Card shadow override */
body.dark .module-placeholder .shadow-xl {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
}

body.dark .module-placeholder .shadow-sm {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

/* Rounded pill badges (the "COMING SOON" labels) */
body.dark .module-placeholder .bg-green-200 {
  background-color: #2d5a2d !important;
}

body.dark .module-placeholder .text-green-900 {
  color: #6ee7b7 !important;
}

body.dark .module-placeholder .bg-cyan-200 {
  background-color: #2d4a5a !important;
}

body.dark .module-placeholder .text-cyan-900 {
  color: #80deea !important;
}

body.dark .module-placeholder .bg-orange-200 {
  background-color: #5a3d2d !important;
}

body.dark .module-placeholder .text-orange-900 {
  color: #ffb74d !important;
}

body.dark .module-placeholder .bg-purple-200 {
  background-color: #3d2d5a !important;
}

body.dark .module-placeholder .text-purple-900 {
  color: #ce93d8 !important;
}

body.dark .module-placeholder .bg-indigo-200 {
  background-color: #2d2d5a !important;
}

body.dark .module-placeholder .text-indigo-900 {
  color: #9fa8da !important;
}

body.dark .module-placeholder .bg-amber-200 {
  background-color: #5a4a2d !important;
}

body.dark .module-placeholder .text-amber-900 {
  color: #ffd54f !important;
}

body.dark .module-placeholder .bg-emerald-200 {
  background-color: #2d5a3d !important;
}

body.dark .module-placeholder .text-emerald-900 {
  color: #6ee7b7 !important;
}

body.dark .module-placeholder .bg-teal-200 {
  background-color: #2d5a4a !important;
}

body.dark .module-placeholder .text-teal-900 {
  color: #80cbc4 !important;
}

body.dark .module-placeholder .bg-red-200 {
  background-color: #5a2d2d !important;
}

body.dark .module-placeholder .text-red-900 {
  color: #ef9a9a !important;
}

body.dark .module-placeholder .bg-rose-200 {
  background-color: #5a2d3d !important;
}

body.dark .module-placeholder .text-rose-900 {
  color: #f48fb1 !important;
}

/* Status pill colors in cards */
body.dark .module-placeholder .bg-green-100 {
  background-color: #1a3a1a !important;
}

body.dark .module-placeholder .bg-blue-100 {
  background-color: #1a1a3a !important;
}

body.dark .module-placeholder .bg-gray-200 {
  background-color: #4b5563 !important;
}

/* Input fields in placeholders */
body.dark .module-placeholder input {
  background-color: #111827 !important;
  border-color: #4b5563 !important;
  color: #e5e7eb !important;
}

/* Font color helpers */
body.dark .module-placeholder .font-semibold {
  color: inherit;
}

/* Colored badge backgrounds that sit on cards */
body.dark .module-placeholder .bg-green-600,
body.dark .module-placeholder .bg-cyan-600,
body.dark .module-placeholder .bg-orange-600,
body.dark .module-placeholder .bg-purple-600,
body.dark .module-placeholder .bg-indigo-600,
body.dark .module-placeholder .bg-amber-600,
body.dark .module-placeholder .bg-emerald-600,
body.dark .module-placeholder .bg-teal-600,
body.dark .module-placeholder .bg-red-600,
body.dark .module-placeholder .bg-rose-600 {
  /* Keep their original colors - they look fine on dark bg */
}

/* "Under development" info box */
body.dark .module-placeholder .text-gray-500 svg {
  color: inherit !important;
}

/* Colored heading text in pill badges */
body.dark .module-placeholder .text-green-800 {
  color: #6ee7b7 !important;
}

body.dark .module-placeholder .text-cyan-800 {
  color: #80deea !important;
}

body.dark .module-placeholder .text-orange-800 {
  color: #ffb74d !important;
}

body.dark .module-placeholder .text-purple-800 {
  color: #ce93d8 !important;
}

body.dark .module-placeholder .text-indigo-800 {
  color: #9fa8da !important;
}

body.dark .module-placeholder .text-amber-800 {
  color: #ffd54f !important;
}

body.dark .module-placeholder .text-emerald-800 {
  color: #6ee7b7 !important;
}

body.dark .module-placeholder .text-teal-800 {
  color: #80cbc4 !important;
}

body.dark .module-placeholder .text-red-800 {
  color: #ef9a9a !important;
}

body.dark .module-placeholder .text-rose-800 {
  color: #f48fb1 !important;
}

/* Card internal colored text */
body.dark .module-placeholder .text-green-600 {
  color: #6ee7b7 !important;
}

body.dark .module-placeholder .text-green-700 {
  color: #66bb6a !important;
}

body.dark .module-placeholder .text-yellow-600 {
  color: #ffd54f !important;
}

body.dark .module-placeholder .text-yellow-700 {
  color: #ffca28 !important;
}

body.dark .module-placeholder .text-red-600 {
  color: #ef9a9a !important;
}

body.dark .module-placeholder .text-red-700 {
  color: #ef5350 !important;
}

body.dark .module-placeholder .text-blue-700 {
  color: #90caf9 !important;
}

body.dark .module-placeholder .text-teal-600 {
  color: #80cbc4 !important;
}

body.dark .module-placeholder .text-orange-600 {
  color: #ffb74d !important;
}

body.dark .module-placeholder .text-purple-900 {
  color: #ce93d8 !important;
}

body.dark .module-placeholder .text-amber-800 {
  color: #ffd54f !important;
}

/* Mono/code sections */
body.dark .module-placeholder .font-mono {
  color: #e5e7eb;
}

body.dark .module-placeholder .bg-purple-100 {
  background-color: #2d1a3a !important;
}

body.dark .module-placeholder .text-purple-900 {
  color: #ce93d8 !important;
}

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

@media (max-width: 1024px) {
  .app-sidebar {
    width: 56px;
    overflow: hidden;
  }

  .sidebar-logo-title,
  .sidebar-logo-subtitle,
  .sidebar-landing-link,
  .sidebar-section-title,
  .sidebar-item-name,
  .sidebar-badge-live,
  .sidebar-badge-soon,
  .sidebar-external-icon,
  .sidebar-footer-top,
  .sidebar-footer-bottom {
    display: none;
  }

  .sidebar-logo {
    justify-content: center;
    padding: 12px 0;
  }

  .sidebar-item {
    justify-content: center;
    padding: 12px 0;
  }

  .sidebar-item-icon {
    width: auto;
  }

  .sidebar-footer {
    align-items: center;
    padding: 12px 4px;
  }

  .inbox-container {
    grid-template-columns: 280px 1fr;
  }

  .template-panel {
    display: none;
  }

  .templates-container {
    grid-template-columns: 200px 1fr;
  }

  .template-preview-panel {
    display: none;
  }

  .integrations-container {
    grid-template-columns: 200px 1fr;
  }

  .integration-logs-panel {
    display: none;
  }
}

@media (max-width: 768px) {
  .app-sidebar {
    display: none;
  }

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

  .conversation-list {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    z-index: 10;
  }

  .conversation-detail {
    display: none;
  }

  .conversation-detail.active {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 20;
  }

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

  .templates-list-panel {
    display: none;
  }

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

  .integrations-list-panel {
    display: none;
  }

  .modal-content {
    margin: 16px;
    max-width: calc(100% - 32px);
  }
}

/* ============================================================
   RCS RICH MESSAGE RENDERING
   ============================================================ */

/* RCS Card Container */
.rcs-card {
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
  max-width: 300px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #e5e7eb;
}

.rcs-card-compact {
  max-width: 260px;
}

/* RCS Card Media (Image) */
.rcs-card-media {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #f9fafb;
}

.rcs-media-short {
  height: 112px;
}

.rcs-media-medium {
  height: 168px;
}

.rcs-media-tall {
  height: 264px;
}

.rcs-media-error {
  background-color: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rcs-media-error::after {
  content: 'Image unavailable';
  color: #9ca3af;
  font-size: 12px;
}

/* RCS Card Content */
.rcs-card-content {
  padding: 12px 16px;
}

.rcs-card-title {
  font-weight: 600;
  font-size: 16px;
  color: #111827;
  margin-bottom: 4px;
  line-height: 1.3;
}

.rcs-card-text {
  font-size: 14px;
  color: #6b7280666;
  line-height: 1.4;
}

/* Vertical card with image on the right (like mobile RCS) */
.rcs-card-vertical-image-right {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  max-width: 320px;
}

.rcs-card-vertical-image-right .rcs-card-content {
  grid-column: 1;
  grid-row: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.rcs-card-vertical-image-right .rcs-card-media {
  grid-column: 2;
  grid-row: 1;
  width: 100px;
  height: 100px;
  min-height: 100px;
  border-radius: 0 16px 0 0;
}

.rcs-card-vertical-image-right .rcs-options-dropdown {
  grid-column: 1 / -1;
  grid-row: 2;
}

/* Horizontal card layout (image on side) */
.rcs-card-horizontal {
  display: flex;
  flex-direction: row;
  max-width: 360px;
}

.rcs-card-horizontal .rcs-card-media {
  width: 120px;
  min-width: 120px;
  height: auto;
  min-height: 100px;
}

.rcs-card-horizontal .rcs-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* When image is on the right */
.rcs-card-image-right {
  flex-direction: row;
}

.rcs-card-image-right .rcs-card-content {
  order: 1;
}

.rcs-card-image-right .rcs-card-media {
  order: 2;
}

.rcs-card-image-right .rcs-options-dropdown {
  order: 3;
  width: 100%;
}

/* For horizontal cards, options dropdown needs to span full width */
.rcs-card-horizontal .rcs-options-dropdown {
  flex-basis: 100%;
}

/* RCS Options Dropdown (like mobile) */
.rcs-options-dropdown {
  border-top: 1px solid #e5e7eb;
}

.rcs-options-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  transition: background 0.2s ease;
}

.rcs-options-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
}

.rcs-options-label {
  color: inherit;
}

.rcs-options-chevron {
  font-size: 10px;
  transition: transform 0.2s ease;
  color: #9ca3af;
}

.rcs-options-dropdown.open .rcs-options-chevron {
  transform: rotate(180deg);
}

.rcs-options-content {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 0 16px 12px;
}

.rcs-options-dropdown.open .rcs-options-content {
  display: flex;
}

/* RCS Action Buttons (inside dropdown) */
.rcs-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  padding-top: 0;
}

.rcs-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #c8e6c9;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.rcs-action:hover:not(:disabled) {
  background: #c8e6c9;
  border-color: #a5d6a7;
}

.rcs-action:disabled {
  cursor: default;
  opacity: 0.8;
}

.rcs-action-icon {
  font-size: 16px;
}

/* Action type icons */
.rcs-action-dial .rcs-action-icon::before {
  content: '\260E';
}

.rcs-action-location .rcs-action-icon::before {
  content: '\1F4CD';
}

.rcs-action-share-location .rcs-action-icon::before {
  content: '\1F4CD';
}

.rcs-action-url .rcs-action-icon::before {
  content: '\1F517';
}

.rcs-action-calendar .rcs-action-icon::before {
  content: '\1F4C5';
}

/* ============================================================
   RCS IMAGE/VIDEO/FILE MESSAGES
   ============================================================ */

/* Shared media message styles */
.rcs-media-message {
  max-width: 300px;
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #e5e7eb;
}

.rcs-media-message.rcs-compact {
  max-width: 240px;
}

.rcs-media-content {
  width: 100%;
  display: block;
  max-height: 300px;
  object-fit: cover;
}

.rcs-media-caption {
  padding: 10px 14px;
  font-size: 14px;
  color: #374151;
  background: #fff;
}

/* Image message */
.rcs-image-message img {
  border-radius: 16px 16px 0 0;
}

.rcs-image-message img:only-child {
  border-radius: 16px;
}

/* Video message */
.rcs-video-message .rcs-video-wrapper {
  position: relative;
  min-height: 180px;
  background: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
}

.rcs-video-wrapper.rcs-has-thumbnail {
  background-color: #374151;
}

.rcs-play-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 4px;
}

.rcs-video-wrapper video {
  width: 100%;
  max-height: 300px;
}

/* File message */
.rcs-file-message {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid #e5e7eb;
  max-width: 280px;
}

.rcs-file-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #ecfdf5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
}

.rcs-file-icon::before {
  content: '\1F4C4';
}

.rcs-file-icon[data-type="pdf"]::before {
  content: '\1F4D5';
}

.rcs-file-icon[data-type="doc"]::before {
  content: '\1F4DD';
}

.rcs-file-icon[data-type="spreadsheet"]::before {
  content: '\1F4CA';
}

.rcs-file-icon[data-type="presentation"]::before {
  content: '\1F4CA';
}

.rcs-file-icon[data-type="archive"]::before {
  content: '\1F4E6';
}

.rcs-file-icon[data-type="audio"]::before {
  content: '\1F3B5';
}

.rcs-file-icon[data-type="video"]::before {
  content: '\1F3AC';
}

.rcs-file-icon[data-type="image"]::before {
  content: '\1F5BC';
}

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

.rcs-file-name {
  font-weight: 500;
  font-size: 14px;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rcs-file-caption {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

/* Text with suggestions */
.rcs-text-with-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 300px;
}

.rcs-text-with-suggestions .rcs-actions {
  padding: 0;
}

/* RCS in message bubbles - additional types */
.message.outbound .rcs-media-message {
  margin-left: auto;
}

.message.outbound .rcs-file-message {
  margin-left: auto;
}

.message.outbound .rcs-text-with-suggestions {
  margin-left: auto;
}

/* RCS Carousel */
.rcs-carousel {
  max-width: 100%;
}

.rcs-carousel-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 4px;
  -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar but keep functionality */
.rcs-carousel-track::-webkit-scrollbar {
  height: 6px;
}

.rcs-carousel-track::-webkit-scrollbar-track {
  background: transparent;
}

.rcs-carousel-track::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}

.rcs-carousel .rcs-card {
  scroll-snap-align: start;
  flex-shrink: 0;
  width: 280px;
}

.rcs-carousel-compact .rcs-card {
  width: 240px;
}

/* Carousel indicators (dots) */
.rcs-carousel-indicators {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 12px 0 4px;
}

.rcs-carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
  transition: background 0.2s ease;
}

.rcs-carousel-dot.active {
  background: #10b981;
}

/* RCS Text Bubble (fallback) */
.rcs-text-bubble {
  background: #10b981;
  color: white;
  padding: 12px 16px;
  border-radius: 12px 12px 4px 12px;
  font-size: 14px;
  line-height: 1.4;
  max-width: 300px;
}

/* RCS in message bubbles */
.message.outbound .rcs-card {
  margin-left: auto;
}

.message.outbound .rcs-carousel {
  margin-left: auto;
}

.message.outbound .rcs-text-bubble {
  margin-left: auto;
}

/* RCS in preview panel */
.preview-device-body .rcs-card {
  max-width: 100%;
}

.preview-device-body .rcs-carousel {
  max-width: 100%;
}

.preview-device-body .rcs-carousel .rcs-card {
  width: 220px;
}

/* Quick template preview panel */
.template-preview-area .rcs-card {
  max-width: 100%;
}

.template-preview-area .rcs-carousel .rcs-card {
  width: 200px;
}

/* ============================================================
   RCS DARK MODE SUPPORT
   ============================================================ */

[data-theme="dark"] .rcs-card {
  background: #374151;
  border-color: #4b5563;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .rcs-card-media {
  background-color: #374151;
}

[data-theme="dark"] .rcs-media-error {
  background-color: #4b5563;
}

[data-theme="dark"] .rcs-card-title {
  color: #ffffff;
}

[data-theme="dark"] .rcs-card-text {
  color: #b0b0b0;
}

[data-theme="dark"] .rcs-options-dropdown {
  border-top-color: #4b5563;
}

[data-theme="dark"] .rcs-options-toggle {
  color: #b0b0b0;
}

[data-theme="dark"] .rcs-options-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .rcs-options-chevron {
  color: #9ca3af;
}

[data-theme="dark"] .rcs-action {
  background: #065f46;
  color: #6ee7b7;
  border-color: #065f46;
}

[data-theme="dark"] .rcs-action:hover:not(:disabled) {
  background: #065f46;
  border-color: #4d7d50;
}

[data-theme="dark"] .rcs-carousel-track::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .rcs-carousel-dot {
  background: #505050;
}

[data-theme="dark"] .rcs-carousel-dot.active {
  background: #6ee7b7;
}

[data-theme="dark"] .rcs-text-bubble {
  background: #065f46;
}

/* Dark mode - Media messages */
[data-theme="dark"] .rcs-media-message {
  background: #374151;
  border-color: #4b5563;
}

[data-theme="dark"] .rcs-media-caption {
  background: #374151;
  color: #e5e7eb;
}

[data-theme="dark"] .rcs-video-wrapper {
  background: #111827;
}

/* Dark mode - File messages */
[data-theme="dark"] .rcs-file-message {
  background: #374151;
  border-color: #4b5563;
}

[data-theme="dark"] .rcs-file-icon {
  background: #065f46;
}

[data-theme="dark"] .rcs-file-name {
  color: #ffffff;
}

[data-theme="dark"] .rcs-file-caption {
  color: #b0b0b0;
}

/* ============================================================
   RCS IN PHONE MOCKUP PREVIEW
   Scaled-down styles for realistic phone preview display
   ============================================================ */

/* RCS Cards in phone mockup - add margins for realistic appearance */
.phone-messages .rcs-card {
  max-width: calc(100% - 16px);
  margin: 0 auto;
  font-size: 12px;
}

.phone-messages .rcs-card-title {
  font-size: 12px;
  margin-bottom: 2px;
}

.phone-messages .rcs-card-text {
  font-size: 10px;
  line-height: 1.3;
}

/* Scaled media heights for phone preview */
.phone-messages .rcs-media-short {
  height: 60px;
}

.phone-messages .rcs-media-medium {
  height: 80px;
}

.phone-messages .rcs-media-tall {
  height: 110px;
}

/* Card with image on right - smaller image for phone */
.phone-messages .rcs-card-vertical-image-right {
  max-width: calc(100% - 16px);
  margin: 0 auto;
}

.phone-messages .rcs-card-vertical-image-right .rcs-card-media {
  width: 60px;
  height: 60px;
  min-height: 60px;
}

.phone-messages .rcs-card-vertical-image-right .rcs-card-content {
  padding: 8px 10px;
}

/* Options dropdown in phone - smaller */
.phone-messages .rcs-options-toggle {
  padding: 6px 10px;
  font-size: 10px;
}

.phone-messages .rcs-options-content {
  padding: 0 10px 6px;
  gap: 4px;
}

.phone-messages .rcs-action {
  padding: 5px 8px;
  font-size: 9px;
  border-radius: 12px;
}

/* Carousel in phone mockup */
.phone-messages .rcs-carousel {
  max-width: 100%;
  margin: 0;
}

.phone-messages .rcs-carousel-track {
  gap: 6px;
  padding: 2px;
}

.phone-messages .rcs-carousel .rcs-card {
  width: 180px;
  max-width: 180px;
  flex-shrink: 0;
}

.phone-messages .rcs-carousel .rcs-card-content {
  padding: 5px 6px;
}

.phone-messages .rcs-carousel .rcs-card-title {
  font-size: 11px;
  margin-bottom: 2px;
  line-height: 1.2;
}

.phone-messages .rcs-carousel .rcs-card-text {
  font-size: 9px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.phone-messages .rcs-carousel .rcs-media-short {
  height: 50px;
}

.phone-messages .rcs-carousel .rcs-media-medium {
  height: 65px;
}

.phone-messages .rcs-carousel .rcs-media-tall {
  height: 85px;
}

/* Carousel card options in phone */
.phone-messages .rcs-carousel .rcs-options-toggle {
  padding: 5px 6px;
  font-size: 9px;
}

.phone-messages .rcs-carousel .rcs-options-content {
  padding: 0 6px 5px;
  gap: 3px;
}

.phone-messages .rcs-carousel .rcs-action {
  padding: 3px 6px;
  font-size: 8px;
  border-radius: 8px;
}

/* Carousel indicators in phone */
.phone-messages .rcs-carousel-indicators {
  padding: 6px 0 2px;
  gap: 3px;
}

.phone-messages .rcs-carousel-dot {
  width: 5px;
  height: 5px;
}

/* Text bubble in phone */
.phone-messages .rcs-text-bubble {
  max-width: calc(100% - 24px);
  margin: 0 auto;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px 10px 4px 10px;
}

/* ===== Inbound Action Messages (Button clicks, replies, etc.) ===== */
.inbound-action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f0f4f8;
  border-radius: 12px;
  border-left: 3px solid #4A90A4;
}

.inbound-action .action-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.inbound-action .action-text {
  font-weight: 500;
  color: #374151;
}

.inbound-action .action-detail {
  font-size: 12px;
  color: #6b7280;
  margin-left: auto;
}

/* Inbound location message */
.inbound-location {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: #f0f4f8;
  border-radius: 12px;
  border-left: 3px solid #4A90A4;
}

.inbound-location .location-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.inbound-location .location-coords {
  font-size: 12px;
  color: #6b7280;
  font-family: monospace;
}

/* Inbound media messages (image, file) */
.inbound-media {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f0f4f8;
  border-radius: 12px;
  border-left: 3px solid #4A90A4;
}

.inbound-media .media-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.inbound-media .media-info {
  display: flex;
  flex-direction: column;
}

.inbound-media .media-type {
  font-weight: 500;
  color: #374151;
}

.inbound-media .media-caption {
  font-size: 12px;
  color: #6b7280;
}

/* Dark mode for inbound action messages */
[data-theme="dark"] .inbound-action,
[data-theme="dark"] .inbound-location,
[data-theme="dark"] .inbound-media {
  background: #2a3441;
  border-left-color: #5ba3b5;
}

[data-theme="dark"] .inbound-action .action-text,
[data-theme="dark"] .inbound-location .location-header,
[data-theme="dark"] .inbound-media .media-type {
  color: #ffffff;
}

[data-theme="dark"] .inbound-action .action-detail,
[data-theme="dark"] .inbound-location .location-coords,
[data-theme="dark"] .inbound-media .media-caption {
  color: #a0a0a0;
}

/* ============================================================
   AGENT MODULE & BADGES
   ============================================================ */

/* Agent badge (purple theme) */
.agent-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #6d28d9;
  background: rgba(109, 40, 217, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.3px;
}

.agent-active-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #059669;
  background: #ecfdf5;
  padding: 2px 8px;
  border-radius: 10px;
}

.agent-active-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  animation: agent-pulse 2s infinite;
}

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

.agent-paused-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 10px;
}

.message-agent {
  font-size: 10px;
  font-weight: 600;
  color: #6d28d9;
  background: rgba(109, 40, 217, 0.15);
  padding: 2px 6px;
  border-radius: 3px;
}

.message.outbound .message-agent {
  background: rgba(255, 255, 255, 0.2);
  color: #f3e8ff;
}

.conversation-badges {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.agent-resume-btn {
  background: #7c3aed;
  color: white;
}
.agent-resume-btn:hover {
  background: #6d28d9;
}

.agent-pause-btn {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}
.agent-pause-btn:hover {
  background: #fde68a;
}

/* "You took over" divider */
.agent-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 10px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.agent-divider::before,
.agent-divider::after {
  content: '';
  flex: 1;
  border-top: 1px dashed #e5e7eb;
}

/* Agent Module Layout — 3-panel grid like integrations */
.agent-container {
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  height: 100%;
  overflow: hidden;
}

.agent-left-panel {
  background: white;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.agent-panel-header {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.agent-panel-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 12px;
}

.agent-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.agent-toggle-label {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.agent-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #10b981;
  font-weight: 500;
  margin-top: 4px;
}

.agent-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  animation: agent-pulse 2s infinite;
}

.agent-stats {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agent-stat-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
}

.agent-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  font-weight: 600;
  margin-bottom: 4px;
}

.agent-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
}

.agent-stat-sub {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
}

/* Center panel */
.agent-center-panel {
  background: #fafafa;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-center-header {
  padding: 16px 20px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.agent-center-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.agent-knowledge-area {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.agent-knowledge-hint {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
  margin-bottom: 14px;
}

.agent-knowledge-textarea {
  flex: 1;
  width: 100%;
  padding: 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.7;
  resize: none;
  color: #374151;
  background: white;
}

.agent-knowledge-textarea:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.agent-knowledge-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.agent-char-count {
  font-size: 11px;
  color: #9ca3af;
}

.agent-save-status {
  font-size: 11px;
  color: #10b981;
  font-weight: 500;
}

/* Right panel */
.agent-right-panel {
  background: white;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.agent-right-header {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.agent-right-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.agent-settings-section {
  padding: 16px;
  border-bottom: 1px solid #f3f4f6;
}

.agent-settings-section h3 {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.agent-system-prompt-textarea {
  width: 100%;
  min-height: 140px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  color: #374151;
}

.agent-system-prompt-textarea:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.agent-coming-soon-setting {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

.agent-coming-soon-setting::after {
  content: 'Coming Soon';
  position: absolute;
  top: 8px;
  right: 16px;
  font-size: 10px;
  font-weight: 600;
  color: #9ca3af;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 4px;
}

.agent-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

.agent-setting-label {
  font-size: 13px;
  color: #374151;
}

.agent-setting-value {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  background: #f3f4f6;
  padding: 4px 12px;
  border-radius: 4px;
}

.agent-test-section {
  padding: 16px;
}

.agent-test-section h3 {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.agent-test-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.agent-test-input-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
}

.agent-test-input-row input:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.agent-test-btn {
  background: #7c3aed;
  color: white;
}
.agent-test-btn:hover {
  background: #6d28d9;
}

.agent-test-response-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #7c3aed;
  margin-bottom: 6px;
}

.agent-test-response {
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  color: #4c1d95;
  line-height: 1.5;
}

/* ===== Agent Dark Mode ===== */
body.dark .agent-badge {
  background-color: rgba(109, 40, 217, 0.25);
  color: #a78bfa;
}

body.dark .message-agent {
  background-color: rgba(109, 40, 217, 0.25);
  color: #a78bfa;
}

body.dark .message.outbound .message-agent {
  background: rgba(255, 255, 255, 0.15);
  color: #e9d5ff;
}

body.dark .agent-active-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

body.dark .agent-paused-badge {
  background: rgba(146, 64, 14, 0.2);
  color: #fbbf24;
}

body.dark .agent-left-panel,
body.dark .agent-right-panel {
  background: #1a1a2e;
  border-color: #2d2d44;
}

body.dark .agent-center-panel {
  background: #16162a;
  border-color: #2d2d44;
}

body.dark .agent-panel-header,
body.dark .agent-center-header,
body.dark .agent-right-header {
  background: #1a1a2e;
  border-color: #2d2d44;
}

body.dark .agent-panel-header h2,
body.dark .agent-center-header h2,
body.dark .agent-right-header h2,
body.dark .agent-toggle-label,
body.dark .agent-stat-value,
body.dark .agent-settings-section h3,
body.dark .agent-test-section h3 {
  color: #e2e8f0;
}

body.dark .agent-stat-card {
  background: #16162a;
  border-color: #2d2d44;
}

body.dark .agent-stat-label,
body.dark .agent-stat-sub,
body.dark .agent-knowledge-hint,
body.dark .agent-char-count {
  color: #9ca3af;
}

body.dark .agent-knowledge-textarea,
body.dark .agent-system-prompt-textarea {
  background: #1a1a2e;
  border-color: #2d2d44;
  color: #e2e8f0;
}

body.dark .agent-knowledge-textarea:focus,
body.dark .agent-system-prompt-textarea:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

body.dark .agent-settings-section {
  border-color: #2d2d44;
}

body.dark .agent-setting-label {
  color: #e2e8f0;
}

body.dark .agent-setting-value {
  background: #16162a;
  color: #9ca3af;
}

body.dark .agent-test-input-row input {
  background: #1a1a2e;
  border-color: #2d2d44;
  color: #e2e8f0;
}

body.dark .agent-test-response {
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.2);
  color: #c4b5fd;
}

body.dark .agent-test-response-label {
  color: #a78bfa;
}

body.dark .agent-divider {
  color: #6b7280;
}

body.dark .agent-divider::before,
body.dark .agent-divider::after {
  border-color: #2d2d44;
}

body.dark .agent-coming-soon-setting::after {
  background: #2d2d44;
  color: #6b7280;
}

/* ============================================================
   PREFLIGHT MODULE
   ============================================================ */

.preflight-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.preflight-tabs {
  display: flex;
  gap: 0;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}

.preflight-tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preflight-tab:hover {
  color: #111827;
}

.preflight-tab.active {
  color: #10b981;
  border-bottom-color: #10b981;
}

.preflight-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  max-width: 720px;
}

.preflight-tab-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

/* Textarea */
.preflight-textarea {
  width: 100%;
  height: 220px;
  padding: 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  line-height: 1.5;
  box-sizing: border-box;
}

.preflight-textarea:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Sample message chips */
.preflight-samples {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.preflight-samples-label {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
  margin-right: 2px;
}

.preflight-sample-chip {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.preflight-sample-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.preflight-chip-fail {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}

.preflight-chip-warn {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #b45309;
}

.preflight-chip-pass {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #059669;
}

.dark .preflight-samples-label {
  color: #9ca3af;
}

.dark .preflight-chip-fail {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.dark .preflight-chip-warn {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.dark .preflight-chip-pass {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.preflight-textarea-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.preflight-char-count {
  font-size: 12px;
  color: #9ca3af;
}

/* Score ring */
.preflight-score-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 0;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 16px;
}

.preflight-score-gauge {
  text-align: center;
  flex-shrink: 0;
}

.preflight-score-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px solid #e5e7eb;
  margin: 0 auto 6px;
}

.preflight-score-number {
  font-size: 28px;
  font-weight: 700;
}

.preflight-score-label {
  font-size: 11px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preflight-ring-pass {
  border-color: #10b981;
  color: #059669;
}

.preflight-ring-warn {
  border-color: #f59e0b;
  color: #d97706;
}

.preflight-ring-fail {
  border-color: #ef4444;
  color: #dc2626;
}

/* Verdict */
.preflight-verdict {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preflight-verdict-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  width: fit-content;
}

.preflight-badge-pass { background: #d1fae5; color: #065f46; }
.preflight-badge-warn { background: #fef3c7; color: #92400e; }
.preflight-badge-fail { background: #fee2e2; color: #991b1b; }

.preflight-verdict-text {
  font-size: 13px;
  color: #6b7280;
}

/* Category cards */
.preflight-categories {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preflight-category-card {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid;
}

.preflight-cat-pass {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.preflight-cat-warn {
  background: #fffbeb;
  border-color: #fde68a;
}

.preflight-cat-fail {
  background: #fef2f2;
  border-color: #fecaca;
}

.preflight-cat-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preflight-cat-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
}

.preflight-cat-pass .preflight-cat-icon { color: #16a34a; }
.preflight-cat-warn .preflight-cat-icon { color: #d97706; }
.preflight-cat-fail .preflight-cat-icon { color: #dc2626; }

.preflight-cat-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  flex: 1;
}

.preflight-cat-status {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.preflight-cat-pass .preflight-cat-status { color: #16a34a; }
.preflight-cat-warn .preflight-cat-status { color: #d97706; }
.preflight-cat-fail .preflight-cat-status { color: #dc2626; }

.preflight-cat-matches {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

.preflight-match-tag {
  padding: 2px 8px;
  background: rgba(0,0,0,0.05);
  border-radius: 4px;
  font-size: 12px;
  color: #374151;
}

.preflight-cat-recommendation {
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(59, 130, 246, 0.06);
  border-left: 3px solid #3b82f6;
  border-radius: 0 6px 6px 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: #1e40af;
}

.preflight-rec-icon {
  margin-right: 4px;
}

.dark .preflight-cat-recommendation {
  background: rgba(96, 165, 250, 0.1);
  color: #93c5fd;
}

/* Number checker - summary bar */
.preflight-summary-bar {
  display: flex;
  gap: 4px;
  padding: 14px 0;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 12px;
  margin-top: 16px;
}

.preflight-summary-stat {
  flex: 1;
  text-align: center;
  padding: 8px;
  background: #f9fafb;
  border-radius: 8px;
}

.preflight-summary-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: #111827;
}

.preflight-summary-label {
  display: block;
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}

/* Number results table */
.preflight-numbers-table-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

.preflight-numbers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.preflight-numbers-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 2px solid #e5e7eb;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  font-weight: 600;
}

.preflight-numbers-table td {
  padding: 10px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}

.preflight-numbers-table tr:hover td {
  background: #f9fafb;
}

.preflight-row-invalid td {
  color: #ef4444;
}

/* RCS badges */
.preflight-rcs-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.preflight-rcs-yes { background: #d1fae5; color: #065f46; }
.preflight-rcs-no { background: #fee2e2; color: #991b1b; }
.preflight-rcs-unknown { background: #f3f4f6; color: #6b7280; }

/* Loading state */
.preflight-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px;
  justify-content: center;
  color: #6b7280;
  font-size: 14px;
}

.preflight-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e5e7eb;
  border-top-color: #10b981;
  border-radius: 50%;
  animation: preflight-spin 0.6s linear infinite;
}

@keyframes preflight-spin {
  to { transform: rotate(360deg); }
}

/* ---- Preflight Dark Mode ---- */
body.dark .preflight-tabs {
  background: #1a1a2e;
  border-bottom-color: #2d2d44;
}

body.dark .preflight-tab {
  color: #9ca3af;
}

body.dark .preflight-tab:hover {
  color: #e5e7eb;
}

body.dark .preflight-tab.active {
  color: #10b981;
}

body.dark .preflight-textarea {
  background: #1a1a2e;
  border-color: #2d2d44;
  color: #e5e7eb;
}

body.dark .preflight-textarea:focus {
  border-color: #10b981;
}

body.dark .preflight-score-row { border-color: #2d2d44; }
body.dark .preflight-score-ring { border-color: #2d2d44; }
body.dark .preflight-verdict-text { color: #9ca3af; }

body.dark .preflight-cat-pass { background: #052e16; border-color: #166534; }
body.dark .preflight-cat-warn { background: #422006; border-color: #92400e; }
body.dark .preflight-cat-fail { background: #450a0a; border-color: #991b1b; }
body.dark .preflight-cat-label { color: #e5e7eb; }
body.dark .preflight-match-tag { background: rgba(255,255,255,0.08); color: #d1d5db; }

body.dark .preflight-summary-stat { background: #1a1a2e; }
body.dark .preflight-summary-value { color: #e5e7eb; }
body.dark .preflight-summary-bar { border-color: #2d2d44; }

body.dark .preflight-numbers-table th { border-color: #2d2d44; color: #9ca3af; }
body.dark .preflight-numbers-table td { border-color: #2d2d44; color: #d1d5db; }
body.dark .preflight-numbers-table tr:hover td { background: #1a1a2e; }

/* ---- Deep Lookup ---- */
.deep-lookup-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.deep-lookup-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  box-sizing: border-box;
}

.deep-lookup-input:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.deep-lookup-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.deep-lookup-card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f3f4f6;
}

.deep-lookup-field {
  display: flex;
  align-items: center;
  padding: 5px 0;
}

.deep-lookup-label {
  width: 140px;
  flex-shrink: 0;
  font-size: 13px;
  color: #6b7280;
}

.deep-lookup-value {
  flex: 1;
  font-size: 14px;
  color: #111827;
  font-weight: 500;
}

.deep-lookup-null {
  color: #d1d5db;
  font-weight: 400;
}

/* ---- Deep Lookup Dark Mode ---- */
body.dark .deep-lookup-input {
  background: #1a1a2e;
  border-color: #2d2d44;
  color: #e5e7eb;
}

body.dark .deep-lookup-input:focus {
  border-color: #10b981;
}

body.dark .deep-lookup-card {
  background: #16162a;
  border-color: #2d2d44;
}

body.dark .deep-lookup-card-title {
  color: #9ca3af;
  border-bottom-color: #2d2d44;
}

body.dark .deep-lookup-label {
  color: #9ca3af;
}

body.dark .deep-lookup-value {
  color: #e5e7eb;
}

body.dark .deep-lookup-null {
  color: #4b5563;
}

/* ============================================================
   HEALTH STATUS VIEW
   ============================================================ */

/* Health status container */
.health-status-container {
  display: flex;
  flex-direction: column;
  padding: 24px;
  gap: 24px;
  overflow-y: auto;
  background: #f9fafb;
}

.health-status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.health-status-header h2 {
  font-size: 24px;
  font-weight: 600;
  color: #111827;
}

/* Health status summary card */
.health-status-summary {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
}

.health-summary-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.health-summary-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  background: #f3f4f6;
}

.health-summary-text {
  flex: 1;
}

.health-summary-status {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.health-summary-status.health-status-healthy {
  color: #10b981;
}

.health-summary-status.health-status-degraded {
  color: #f59e0b;
}

.health-summary-status.health-status-unhealthy {
  color: #ef4444;
}

.health-summary-time {
  font-size: 13px;
  color: #6b7280;
}

/* Health services grid */
.health-services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.health-service-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
  transition: box-shadow 0.2s;
}

.health-service-card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.health-service-card.status-ok {
  border-left: 4px solid #10b981;
}

.health-service-card.status-warning {
  border-left: 4px solid #f59e0b;
}

.health-service-card.status-error {
  border-left: 4px solid #ef4444;
}

.health-service-card.status-config {
  border-left: 4px solid #9ca3af;
}

.health-service-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.health-service-icon {
  font-size: 24px;
}

.health-service-name {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}

.health-critical-badge {
  font-size: 10px;
  font-weight: 600;
  background: #fee2e2;
  color: #dc2626;
  padding: 2px 6px;
  border-radius: 4px;
}

.health-service-status {
  font-size: 18px;
  font-weight: bold;
}

.status-ok .health-service-status {
  color: #10b981;
}

.status-warning .health-service-status {
  color: #f59e0b;
}

.status-error .health-service-status {
  color: #ef4444;
}

.status-config .health-service-status {
  color: #9ca3af;
}

.health-service-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.health-service-detail {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.health-detail-label {
  color: #6b7280;
  font-weight: 500;
}

.health-detail-value {
  color: #111827;
  font-weight: 500;
}

.health-error-detail .health-detail-value {
  color: #ef4444;
  word-break: break-word;
}

/* Version badge health status colors */
.version-badge {
  transition: background-color 0.3s, border 0.3s;
}

.version-badge.health-healthy {
  background: #10b981 !important;
  color: white !important;
  border: 1px solid #059669;
}

.version-badge.health-degraded {
  background: #f59e0b !important;
  color: white !important;
  border: 1px solid #d97706;
}

.version-badge.health-unhealthy {
  background: #ef4444 !important;
  color: white !important;
  border: 1px solid #dc2626;
}

/* Dark mode health status */
body.dark .health-status-container {
  background: #111827;
}

body.dark .health-status-header h2 {
  color: #f9fafb;
}

body.dark .health-status-summary {
  background: #1f2937;
  border-color: #374151;
}

body.dark .health-summary-icon {
  background: #374151;
}

body.dark .health-summary-time {
  color: #9ca3af;
}

body.dark .health-service-card {
  background: #1f2937;
  border-color: #374151;
}

body.dark .health-service-name {
  color: #f9fafb;
}

body.dark .health-detail-label {
  color: #9ca3af;
}

body.dark .health-detail-value {
  color: #f9fafb;
}

/* Test Suite Status Section */
.test-suite-section {
  margin-top: 8px;
}

.test-suite-heading {
  font-size: 16px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 12px;
}

.test-suite-card .health-service-card.status-unavailable {
  border-left: 4px solid #9ca3af;
}

.test-suite-link {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}

.test-suite-link:hover {
  text-decoration: underline;
}

body.dark .test-suite-heading {
  color: #e5e7eb;
}

body.dark .test-suite-link {
  color: #60a5fa;
}
