/* public/mini_crm.css - WhatsApp Mini-CRM Styles (WA_MINI_CRM_01) */

/* Let the workspace flex item shrink; the board owns horizontal scrolling. */
#app-workspace main:has(> #tab-crm),
#tab-crm,
.crm-wrapper,
#crmMainContent {
  min-width: 0;
}

.crm-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Header & Controls */
.crm-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.75rem;
  padding: 0.875rem 1.25rem;
}

.crm-controls-left,
.crm-controls-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.crm-input-search {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.5rem;
  color: #f1f5f9;
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  outline: none;
  min-width: 180px;
}

.crm-input-search:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.crm-select {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.5rem;
  color: #f1f5f9;
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  outline: none;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.crm-select:focus {
  border-color: #f4d922;
  box-shadow: 0 0 0 2px rgba(244, 217, 34, 0.22);
}

.crm-select:disabled,
.crm-input-search:disabled,
.crm-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Admin Cabinet Discovery Bar */
.crm-cabinet-bar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: linear-gradient(135deg, rgba(24, 21, 28, 0.92) 0%, rgba(18, 16, 22, 0.94) 100%);
  border: 1px solid rgba(244, 217, 34, 0.28);
  border-radius: 0.75rem;
  padding: 0.875rem 1.15rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
  max-width: 100%;
}

.crm-cabinet-bar-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.crm-cabinet-title-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.crm-cabinet-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #f4d922;
}

.crm-cabinet-scope-badge {
  font-size: 0.78rem;
  padding: 0.18rem 0.6rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(225, 222, 231, 0.16);
  color: #cbd5e1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-cabinet-scope-badge.is-active {
  background: rgba(244, 217, 34, 0.14);
  border-color: rgba(244, 217, 34, 0.45);
  color: #fde047;
  font-weight: 600;
}

.crm-cabinet-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
}

.crm-cabinet-search {
  flex: 1 1 220px;
  min-width: 180px;
  background: #141218;
  border-color: rgba(225, 222, 231, 0.18);
  color: #f3f1f6;
}

.crm-cabinet-select {
  flex: 2 1 320px;
  min-width: 220px;
  width: 100%;
  background: #141218;
  border-color: rgba(225, 222, 231, 0.18);
  color: #f3f1f6;
}

.crm-cabinet-refresh-btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
}

.crm-empty-cabinet {
  background: rgba(24, 21, 28, 0.85);
  border: 1px dashed rgba(244, 217, 34, 0.35);
  border-radius: 0.75rem;
  padding: 2rem 1.25rem;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.crm-empty-cabinet-title {
  font-size: 1rem;
  font-weight: 700;
  color: #f4d922;
  margin-bottom: 0.4rem;
}

.crm-empty-cabinet-desc {
  font-size: 0.875rem;
  color: #d1ced7;
  max-width: 42rem;
  margin: 0 auto;
  line-height: 1.45;
}

.crm-cabinet-empty-banner {
  background: rgba(244, 217, 34, 0.08);
  border: 1px solid rgba(244, 217, 34, 0.28);
  border-radius: 0.6rem;
  padding: 0.65rem 1rem;
  color: #f4e69a;
  font-size: 0.84rem;
  margin-bottom: 0.75rem;
}

.crm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  padding: 0.45rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.crm-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.crm-btn-primary {
  background: #d97706;
  border-color: #b45309;
  color: #ffffff;
}

.crm-btn-primary:hover {
  background: #b45309;
}

.crm-btn-active {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  color: #fbbf24;
}

/* KPI Summary Cards */
.crm-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.crm-kpi-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
}

.crm-kpi-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.crm-kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f8fafc;
  margin-top: 0.25rem;
}

/* Kanban View */
.crm-board-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
}

.crm-board-scroll-hint {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.75rem;
  background: rgba(24, 21, 28, 0.85);
  border: 1px solid rgba(244, 217, 34, 0.25);
  border-radius: 0.5rem;
  font-size: 0.78rem;
  color: #f4d922;
}

.crm-board-scroll-hint.is-visible {
  display: flex;
}

.crm-board-scroll-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.crm-board-scroll-btn {
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  border-color: rgba(244, 217, 34, 0.35);
  color: #f4d922;
}

.crm-kanban-board {
  display: flex;
  gap: 0.625rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  min-height: 480px;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--gr-scrollbar-thumb, rgba(244, 217, 34, 0.42)) var(--gr-scrollbar-track, #0e0d12);
}

.crm-kanban-board::-webkit-scrollbar {
  height: 9px;
}

.crm-kanban-board::-webkit-scrollbar-track {
  background: var(--gr-scrollbar-track, #0e0d12);
  border-radius: 9999px;
}

.crm-kanban-board::-webkit-scrollbar-thumb {
  background: var(--gr-scrollbar-thumb, rgba(244, 217, 34, 0.42));
  border-radius: 9999px;
  border: 2px solid var(--gr-scrollbar-border, rgba(14, 13, 18, 0.85));
}

.crm-kanban-board::-webkit-scrollbar-thumb:hover {
  background: var(--gr-scrollbar-thumb-hover, rgba(244, 217, 34, 0.68));
}

.crm-kanban-column {
  flex: 1 1 180px;
  width: auto;
  min-width: 180px;
  max-width: none;
  background: rgba(20, 18, 24, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  box-sizing: border-box;
}

.crm-kanban-board--multi .crm-kanban-column {
  flex: 0 0 232px;
  width: 232px;
  min-width: 220px;
  max-width: 260px;
}

.crm-column-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.crm-column-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  overflow: hidden;
}

.crm-stage-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.crm-column-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #f1f5f9;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-badge-count {
  background: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  flex-shrink: 0;
}

.crm-column-cards {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
}

.crm-lead-card {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.5rem;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.crm-lead-card:hover {
  border-color: rgba(245, 158, 11, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.crm-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.crm-card-header > div:first-child {
  min-width: 0;
  overflow: hidden;
}

.crm-card-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #f8fafc;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-card-phone {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.15rem;
  font-family: monospace;
  word-break: break-all;
  overflow-wrap: anywhere;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crm-card-preview {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-top: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.crm-card-footer {
  margin-top: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #64748b;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding-top: 0.4rem;
  min-width: 0;
  overflow: hidden;
}

.crm-channel-pill {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.68rem;
  flex-shrink: 0;
}

/* List / Table View */
.crm-table-container {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.75rem;
  box-sizing: border-box;
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.crm-table th {
  padding: 0.75rem 1rem;
  background: rgba(30, 41, 59, 0.5);
  color: #94a3b8;
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.crm-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
}

.crm-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Lead Detail Drawer / Modal */
.crm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.crm-modal-card {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1rem;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.crm-modal-header {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.crm-modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.crm-lead-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  background: rgba(30, 41, 59, 0.5);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.crm-timeline-item {
  display: flex;
  gap: 0.75rem;
  padding-left: 0.5rem;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  margin-left: 0.5rem;
  padding-bottom: 1rem;
}

.crm-timeline-item:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

.crm-timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  margin-left: -0.65rem;
  margin-top: 0.35rem;
  flex-shrink: 0;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .crm-header-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
  }
  .crm-controls-left,
  .crm-controls-right {
    width: 100%;
  }
  .crm-input-search,
  .crm-cabinet-search,
  .crm-cabinet-select,
  .crm-select {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }
  .crm-board-scroll-hint.is-visible {
    display: none;
  }
  .crm-kanban-board,
  .crm-kanban-board--multi {
    flex-direction: column;
    overflow-x: visible;
  }
  .crm-kanban-column,
  .crm-kanban-board--multi .crm-kanban-column {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: none;
    box-sizing: border-box;
  }
  .crm-stage-settings-row {
    flex-direction: column;
    align-items: stretch;
  }
  .crm-stage-settings-left,
  .crm-stage-settings-right {
    flex-wrap: wrap;
    width: 100%;
  }
  .crm-modal-card {
    max-width: 100%;
    max-height: 95vh;
  }
}


/* Funnel Settings & Pagination Styles */
.crm-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.75rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

.crm-pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.crm-btn-danger {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.crm-btn-danger:hover {
  background: rgba(239, 68, 68, 0.35);
  border-color: #ef4444;
}

.crm-stage-settings-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.crm-stage-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: rgba(30, 41, 59, 0.6);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.crm-stage-settings-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.crm-stage-settings-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.crm-color-input {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

/* Funnel rows reflow without clipping actions. Other CRM dialogs remain unchanged. */
#crmFunnelModalContainer .crm-modal-backdrop { z-index: 2147483000; inset-block-start: 4.75rem; }
#crmFunnelModalContainer .crm-modal-card { max-width: 960px; min-width: 0; max-height: calc(100dvh - 6.75rem); }
#crmFunnelModalContainer .crm-modal-header > div { min-width: 0; }
#crmFunnelModalContainer .crm-modal-header > button { flex-shrink: 0; }
#crmFunnelModalContainer .crm-modal-body { min-width: 0; }
#crmFunnelModalContainer .crm-stage-settings-row { display: grid; grid-template-columns: minmax(0, 1fr); }
#crmFunnelModalContainer .crm-stage-settings-left { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(0, 200px) auto; min-width: 0; }
#crmFunnelModalContainer input, #crmFunnelModalContainer select { box-sizing: border-box; max-width: 100%; }
#crmFunnelModalContainer .crm-input-search { min-width: 0 !important; width: 100%; }
#crmFunnelModalContainer .crm-stage-settings-right { min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
#crmFunnelModalContainer .crm-btn { max-width: 100%; }
#crmFunnelModalContainer .crm-color-input { flex-shrink: 0; }
@media (max-width: 600px) {
 #crmFunnelModalContainer .crm-stage-settings-left { grid-template-columns: 28px minmax(0, 1fr); }
 #crmFunnelModalContainer .crm-stage-settings-left > select { grid-column: 1 / -1; width: 100%; }
 #crmFunnelModalContainer .crm-stage-settings-left > span { grid-column: 1 / -1; }
 #crmFunnelModalContainer .crm-stage-settings-right { justify-content: flex-start; }
}

/* ==========================================================================
   GenResurs Charcoal & Gold Theme for Funnel Settings Modal (WA_CRM_FUNNEL_THEME_01)
   Scoped strictly to #crmFunnelModalContainer
   ========================================================================== */

#crmFunnelModalContainer .crm-modal-backdrop {
  background: rgba(10, 8, 14, 0.85) !important;
  backdrop-filter: blur(8px) !important;
}

#crmFunnelModalContainer .crm-modal-card {
  background: linear-gradient(180deg, #18151c 0%, #100e14 100%) !important;
  border: 1px solid rgba(244, 217, 34, 0.25) !important;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.85), 0 0 24px rgba(244, 217, 34, 0.08) !important;
  color: #e7e5ea !important;
}

#crmFunnelModalContainer .crm-modal-header {
  border-bottom: 1px solid rgba(225, 222, 231, 0.1) !important;
  background: rgba(22, 19, 26, 0.6) !important;
}

#crmFunnelModalContainer .crm-modal-header h3 {
  color: #f4d922 !important;
  text-shadow: 0 0 12px rgba(244, 217, 34, 0.2);
}

#crmFunnelModalContainer .crm-modal-header p {
  color: #99969e !important;
}

#crmFunnelModalContainer .crm-modal-header > button {
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(225, 222, 231, 0.15) !important;
  color: #e7e5ea !important;
  border-radius: 0.375rem !important;
  transition: all 0.15s ease !important;
}

#crmFunnelModalContainer .crm-modal-header > button:hover {
  background: rgba(244, 217, 34, 0.15) !important;
  border-color: rgba(244, 217, 34, 0.4) !important;
  color: #f4d922 !important;
}

#crmFunnelModalContainer .crm-modal-body {
  color-scheme: dark !important;
  scrollbar-width: thin !important;
  scrollbar-color: var(--gr-scrollbar-thumb, rgba(244, 217, 34, 0.34)) var(--gr-scrollbar-track, #0e0d12);
}

#crmFunnelModalContainer .crm-modal-body::-webkit-scrollbar {
  width: 8px !important;
  height: 8px !important;
}

#crmFunnelModalContainer .crm-modal-body::-webkit-scrollbar-track {
  background: #0c0a10 !important;
  border-radius: 4px !important;
}

#crmFunnelModalContainer .crm-modal-body::-webkit-scrollbar-thumb {
  background: rgba(172, 163, 176, 0.3) !important;
  border-radius: 4px !important;
  border: 1px solid rgba(244, 217, 34, 0.15) !important;
}

#crmFunnelModalContainer .crm-modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(244, 217, 34, 0.55) !important;
}

#crmFunnelModalContainer .crm-stage-settings-row {
  background: rgba(26, 22, 31, 0.75) !important;
  border: 1px solid rgba(225, 222, 231, 0.08) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
  transition: border-color 0.15s ease, background 0.15s ease !important;
}

#crmFunnelModalContainer .crm-stage-settings-row:hover {
  border-color: rgba(244, 217, 34, 0.2) !important;
  background: rgba(30, 25, 36, 0.85) !important;
}

#crmFunnelModalContainer .crm-stage-settings-left span {
  color: #99969e !important;
}

#crmFunnelModalContainer input.crm-input-search,
#crmFunnelModalContainer select.crm-select {
  background: #141218 !important;
  border: 1px solid rgba(225, 222, 231, 0.16) !important;
  color: #e7e5ea !important;
  border-radius: 0.375rem !important;
}

#crmFunnelModalContainer input.crm-input-search:focus,
#crmFunnelModalContainer select.crm-select:focus {
  border-color: #f4d922 !important;
  box-shadow: 0 0 0 2px rgba(244, 217, 34, 0.25) !important;
  outline: none !important;
}

#crmFunnelModalContainer select.crm-select option {
  background: #18151c !important;
  color: #e7e5ea !important;
}

#crmFunnelModalContainer .crm-color-input {
  border: 1px solid rgba(225, 222, 231, 0.2) !important;
  border-radius: 4px !important;
}

/* Primary Gold Action Buttons (Save & Create) */
#crmFunnelModalContainer .crm-btn-primary {
  background: linear-gradient(#ffee48 0%, #ffd009 100%) !important;
  color: #2a240b !important;
  border: 1px solid #fae767 !important;
  font-weight: 700 !important;
  box-shadow: 0 3px 12px rgba(235, 186, 15, 0.3) !important;
  transition: filter 0.12s, transform 0.12s, box-shadow 0.12s !important;
}

#crmFunnelModalContainer .crm-btn-primary:hover {
  filter: brightness(1.06) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 5px 16px rgba(235, 186, 15, 0.45) !important;
}

#crmFunnelModalContainer .crm-btn-primary:active {
  filter: brightness(0.95) !important;
  transform: translateY(0) !important;
}

/* Neutral Secondary Buttons (▲, ▼) */
#crmFunnelModalContainer .crm-btn:not(.crm-btn-primary):not(.crm-btn-danger) {
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(225, 222, 231, 0.14) !important;
  color: #d1ced7 !important;
  border-radius: 0.375rem !important;
  transition: all 0.12s ease !important;
}

#crmFunnelModalContainer .crm-btn:not(.crm-btn-primary):not(.crm-btn-danger):hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(244, 217, 34, 0.3) !important;
  color: #f4d922 !important;
}

/* Destructive Action Button (Delete) */
#crmFunnelModalContainer .crm-btn-danger {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.25) 0%, rgba(153, 27, 27, 0.35) 100%) !important;
  border: 1px solid rgba(239, 68, 68, 0.5) !important;
  color: #fca5a5 !important;
  border-radius: 0.375rem !important;
  transition: all 0.12s ease !important;
}

#crmFunnelModalContainer .crm-btn-danger:hover {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.45) 0%, rgba(153, 27, 27, 0.55) 100%) !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
}

/* Create New Stage Form Container */
#crmFunnelModalContainer .crm-modal-body > div:last-child {
  background: rgba(22, 18, 27, 0.6) !important;
  border: 1px dashed rgba(244, 217, 34, 0.25) !important;
  border-radius: 0.5rem !important;
}

#crmFunnelModalContainer .crm-modal-body > div:last-child h4 {
  color: #f4d922 !important;
  font-weight: 600 !important;
}


/* ==========================================================================
   WhatsApp Messenger Adjacent Chat CRM Side Panel (WA_CHAT_CRM_PANEL_01)
   Charcoal & Gold Theme, Desktop 3rd Column + Mobile Same-Page Drawer
   ========================================================================== */

.wa-chat-crm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 6px;
  border: 1px solid rgba(245, 203, 92, 0.45);
  background: linear-gradient(180deg, rgba(64, 48, 14, 0.86) 0%, rgba(30, 22, 8, 0.94) 100%);
  color: #f5cb5c;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.35;
  transition: filter 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.wa-chat-crm-btn:hover:not(:disabled) {
  filter: brightness(1.15);
  border-color: #ffe066;
}

.wa-chat-crm-btn.wa-chat-crm-btn-active {
  background: linear-gradient(180deg, #ffe066 0%, #eab308 100%);
  color: #1c1505;
  border-color: #fef08a;
  box-shadow: 0 0 10px rgba(245, 203, 92, 0.35);
}

.wa-chat-crm-btn:disabled,
.wa-chat-crm-btn[aria-disabled="true"] {
  opacity: 0.42;
  cursor: not-allowed;
  border-color: rgba(148, 163, 184, 0.25);
  background: rgba(30, 41, 59, 0.45);
  color: #94a3b8;
  box-shadow: none;
}

.wa-header-crm-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid rgba(245, 203, 92, 0.45);
  background: rgba(245, 203, 92, 0.1);
  color: #f5cb5c;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.wa-header-crm-btn:hover:not(:disabled) {
  background: rgba(245, 203, 92, 0.22);
  border-color: #ffe066;
}

.wa-header-crm-btn.wa-header-crm-btn-active {
  background: linear-gradient(180deg, #ffe066 0%, #eab308 100%);
  color: #1c1505;
  border-color: #fef08a;
}

.wa-header-crm-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.wa-messenger-split {
  min-width: 0;
  max-width: 100%;
}

.wa-messenger-split > .wa-left-pane,
.wa-messenger-split > .wa-right-pane {
  min-width: 0;
}

.wa-messenger-split.wa-has-crm-panel .wa-input-pill,
.wa-messenger-split.wa-has-crm-panel .wa-input-pill > textarea {
  min-width: 0;
}

.wa-crm-back-btn {
  display: none;
}

.wa-crm-side-panel {
  display: flex;
  flex-direction: column;
  width: clamp(276px, 31cqi, 320px);
  min-width: 0;
  max-width: 340px;
  flex: 0 0 auto;
  height: 100%;
  background-color: #101218;
  background-image: linear-gradient(180deg, rgba(16, 18, 24, 0.98) 0%, rgba(10, 12, 16, 0.99) 100%);
  border-left: 1px solid rgba(245, 198, 68, 0.28);
  color: #f1f5f9;
  z-index: 25;
  box-sizing: border-box;
  overflow: hidden;
  user-select: text;
}

/* Container-aware 3-column adjacent layout when actual messenger width permits */
@container wa-messenger (min-width: 880px) and (max-width: 1119px) {
  :is(#wa-messenger-root, #demo-wa-messenger-root) .wa-messenger-split.wa-has-crm-panel > .wa-left-pane {
    width: clamp(232px, 26cqi, 256px);
    min-width: 0;
    max-width: 260px;
    flex: 0 0 auto;
  }
  :is(#wa-messenger-root, #demo-wa-messenger-root) .wa-messenger-split.wa-has-crm-panel > .wa-left-pane .wa-top-header-left {
    padding: 8px 8px 8px 42px;
    gap: 5px 6px;
  }
  :is(#wa-messenger-root, #demo-wa-messenger-root) .wa-messenger-split.wa-has-crm-panel > .wa-left-pane #wa-btn-manager-inbox {
    padding: 3px 7px;
    font-size: 11px;
  }
  :is(#wa-messenger-root, #demo-wa-messenger-root) .wa-messenger-split.wa-has-crm-panel .wa-right-pane .wa-input-footer {
    padding-right: 14px;
  }
  .wa-crm-side-panel {
    width: clamp(276px, 31cqi, 300px);
    max-width: 300px;
    flex: 0 0 auto;
  }
}

@container wa-messenger (min-width: 1120px) {
  :is(#wa-messenger-root, #demo-wa-messenger-root) .wa-messenger-split.wa-has-crm-panel > .wa-left-pane {
    width: clamp(268px, 25cqi, 310px);
    min-width: 0;
    max-width: 320px;
    flex: 0 0 auto;
  }
  :is(#wa-messenger-root, #demo-wa-messenger-root) .wa-messenger-split.wa-has-crm-panel .wa-right-pane .wa-input-footer {
    padding-right: 14px;
  }
  .wa-crm-side-panel {
    width: clamp(300px, 28cqi, 340px);
    max-width: 340px;
    flex: 0 0 auto;
  }
  #app-workspace.wa-crm-expanded #wa-messenger-root .wa-messenger-split.wa-has-crm-panel > .wa-left-pane {
    width: clamp(252px, 21cqi, 310px);
    max-width: 310px;
    flex: 0 0 auto;
  }
  #app-workspace.wa-crm-expanded #wa-messenger-root .wa-messenger-split.wa-has-crm-panel > .wa-crm-side-panel {
    width: clamp(328px, 31cqi, 460px);
    max-width: 460px;
    flex: 0 0 auto;
  }
}

/* Narrow messenger containers (< 880px): gracefully adapt CRM panel to same-page drawer overlay instead of squeezing panes */
@container wa-messenger (max-width: 879px) {
  #wa-chat-crm-panel.wa-crm-side-panel,
  .wa-crm-side-panel {
    display: flex !important;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(340px, 100%);
    max-width: 100%;
    flex: none !important;
    z-index: 35;
    box-shadow: -10px 0 28px rgba(0, 0, 0, 0.68);
  }
  .wa-crm-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

@container wa-messenger (max-width: 579px) {
  #wa-chat-crm-panel.wa-crm-side-panel,
  .wa-crm-side-panel {
    inset: 0;
    width: 100% !important;
    max-width: 100% !important;
    border-left: none;
  }
}

@media (max-width: 767px) {
  body.wa-mobile-active #app-workspace > div {
    padding: 0 !important;
  }
  body.wa-mobile-active main {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  #wa-chat-crm-panel.wa-crm-side-panel,
  .wa-crm-side-panel {
    display: flex !important;
    position: absolute;
    inset: 0;
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
    border-left: none;
    z-index: 35;
  }
  .wa-crm-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

.wa-crm-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  background: linear-gradient(180deg, rgba(24, 25, 32, 0.96) 0%, rgba(14, 15, 20, 0.98) 100%);
  border-bottom: 1px solid rgba(245, 198, 68, 0.22);
  flex-shrink: 0;
}

.wa-crm-side-title-wrap {
  min-width: 0;
  flex: 1 1 auto;
}

.wa-crm-side-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f5cb5c;
  margin-bottom: 2px;
}

.wa-crm-side-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

#wa-chat-crm-panel .crm-lead-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  background: rgba(24, 26, 34, 0.85);
  border: 1px solid rgba(245, 203, 92, 0.18);
  border-radius: 0.6rem;
}

#wa-chat-crm-panel .crm-select,
#wa-chat-crm-panel .crm-input-search {
  background: rgba(11, 14, 20, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f1f5f9;
  max-width: 100%;
  min-width: 0;
}

#wa-chat-crm-panel .crm-btn {
  font-size: 0.78rem;
  padding: 0.4rem 0.7rem;
}

#wa-chat-crm-panel .crm-btn-primary {
  background: linear-gradient(180deg, #ffe066 0%, #e6b800 100%);
  color: #1c1505;
  border: 1px solid #fae767;
  font-weight: 700;
}

.wa-crm-empty-box {
  background: rgba(22, 24, 32, 0.85);
  border: 1px dashed rgba(245, 203, 92, 0.35);
  border-radius: 0.75rem;
  padding: 1.15rem 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: center;
}

.wa-crm-alert-error {
  background: rgba(127, 29, 29, 0.35);
  border: 1px solid rgba(248, 113, 113, 0.5);
  color: #fecaca;
  border-radius: 0.6rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.78rem;
  line-height: 1.35;
}

/* Scoped Expanded CRM Workspace Top Bar & Return Control */
#wa-messenger-root .wa-crm-expanded-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 8px 14px 8px 48px;
  background: linear-gradient(180deg, rgba(22, 24, 32, 0.98) 0%, rgba(12, 13, 18, 0.98) 100%);
  border-bottom: 1px solid rgba(245, 198, 68, 0.28);
  flex-shrink: 0;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  position: relative;
  z-index: 40;
}

#wa-messenger-root .wa-crm-return-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  min-height: 32px;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(245, 198, 68, 0.55);
  background: linear-gradient(180deg, rgba(245, 198, 68, 0.18) 0%, rgba(212, 160, 23, 0.12) 100%);
  color: #ffe066;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#wa-messenger-root .wa-crm-return-btn:hover {
  background: linear-gradient(180deg, rgba(245, 198, 68, 0.28) 0%, rgba(212, 160, 23, 0.2) 100%);
  border-color: rgba(250, 231, 103, 0.85);
  color: #fff6cc;
}

#wa-messenger-root .wa-crm-return-btn:focus-visible {
  outline: 2px solid #f5c644;
  outline-offset: 2px;
}

#wa-messenger-root .wa-crm-expanded-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#wa-messenger-root .wa-crm-expanded-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 9999px;
  border: 1px solid rgba(245, 198, 68, 0.3);
  background: rgba(245, 198, 68, 0.1);
  color: #f5cb5c;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

@container wa-messenger (max-width: 579px) {
  #wa-messenger-root .wa-crm-expanded-bar {
    padding: 7px 10px 7px 42px;
    gap: 6px 8px;
  }
  #wa-messenger-root .wa-crm-expanded-meta {
    display: none;
  }
  #wa-messenger-root .wa-crm-return-btn {
    white-space: normal;
    text-align: left;
  }
}

@media (max-width: 767px) {
  #wa-messenger-root .wa-crm-expanded-bar {
    padding: 7px 10px 7px 42px;
  }
  #wa-messenger-root .wa-crm-expanded-meta {
    display: none;
  }
  #wa-messenger-root .wa-crm-return-btn {
    white-space: normal;
    text-align: left;
  }
}

@media (forced-colors: active) {
  .crm-kanban-board,
  #crmFunnelModalContainer .crm-modal-body {
    scrollbar-color: auto !important;
  }
}
