/* ==========================================================================
   Frame CRM — Twenty Features Extension
   - Switcher Kanban ⇄ Tabela (Spreadsheet View)
   - Slide-Over Record Detail Drawer
   - Command Palette Global (Cmd+K / Ctrl+K)
   - Signature Glow & 20px Button Standardization
   ========================================================================== */

/* 1. Pipeline View Toolbar & Switcher */
.pipeline-view-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
  padding: 12px 18px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 15px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 4px 20px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
}

.view-mode-toggle {
  display: inline-flex;
  align-items: center;
  background: rgba(2, 6, 23, 0.6);
  padding: 4px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  gap: 4px;
}

.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #94a3b8;
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.view-toggle-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.05);
}

.view-toggle-btn.active {
  color: #ffffff;
  background: #0063e1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 2px 8px rgba(0, 0, 0, 0.45);
}

.pipeline-quick-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-pill strong {
  color: #38bdf8;
  font-weight: 600;
}

.cmd-palette-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 12px;
  color: #cbd5e1;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 15px !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cmd-palette-btn:hover {
  background: rgba(51, 65, 85, 0.8);
  border-color: rgba(56, 189, 248, 0.4);
  color: #ffffff;
}

.cmd-palette-btn kbd {
  font-family: inherit;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
}

/* 2. Spreadsheet / Table View */
.pipeline-table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(11, 20, 38, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 32px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  margin-top: 10px;
}

.twenty-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  color: #cbd5e1;
  min-width: 900px;
}

.twenty-table th {
  background: rgba(15, 23, 42, 0.95);
  padding: 14px 18px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.twenty-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.twenty-table th.sortable:hover {
  color: #38bdf8;
}

.twenty-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
  transition: background 0.15s;
}

.twenty-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.twenty-table tbody tr:hover td {
  background: rgba(30, 58, 138, 0.15);
}

.table-lead-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-lead-avatar {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1e3a8a, #0063e1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
}

.table-lead-info strong {
  display: block;
  font-size: 13px;
  color: #f8fafc;
  font-weight: 600;
}

.table-lead-info small {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

.table-stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.table-stage-badge.stage-0 { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }
.table-stage-badge.stage-1 { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.table-stage-badge.stage-2 { background: rgba(234, 179, 8, 0.15); color: #facc15; border: 1px solid rgba(234, 179, 8, 0.3); }
.table-stage-badge.stage-3 { background: rgba(249, 115, 22, 0.15); color: #fb923c; border: 1px solid rgba(249, 115, 22, 0.3); }
.table-stage-badge.stage-4 { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.table-stage-badge.stage-5 { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

.table-score-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.score-high { background: rgba(34, 197, 94, 0.12); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.25); }
.score-mid { background: rgba(56, 189, 248, 0.12); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.25); }
.score-low { background: rgba(234, 179, 8, 0.12); color: #facc15; border: 1px solid rgba(234, 179, 8, 0.25); }

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

.table-action-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.table-action-btn:hover {
  background: #0063e1;
  color: #ffffff;
  border-color: #0063e1;
}

.table-wa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: rgba(37, 211, 102, 0.15);
  border: 1px solid rgba(37, 211, 102, 0.3);
  color: #25d366;
  text-decoration: none;
  transition: all 0.15s ease;
}

.table-wa-btn:hover {
  background: #25d366;
  color: #000000;
  transform: scale(1.05);
}

/* 3. Slide-Over Detail Drawer */
.twenty-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.65);
  backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

.twenty-drawer-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.twenty-lead-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 520px;
  max-width: 100vw;
  background: rgba(11, 18, 33, 0.96);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.6), inset 1px 0 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  z-index: 9999;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  color: #e2e8f0;
}

.twenty-lead-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  padding: 24px 28px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  position: relative;
}

.drawer-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.drawer-avatar {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1e3a8a, #0063e1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 4px 14px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
}

.drawer-title-group h2 {
  font-size: 18px;
  font-weight: 600;
  color: #f8fafc;
  margin: 0;
  line-height: 1.3;
}

.drawer-title-group p {
  font-size: 13px;
  color: #94a3b8;
  margin: 3px 0 0;
}

.drawer-close-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.drawer-close-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

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

/* Drawer Action Bar */
.drawer-action-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.drawer-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 16px !important;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  white-space: nowrap;
}

.drawer-action-btn.wa {
  background: rgba(37, 211, 102, 0.15);
  color: #25d366;
  border-color: rgba(37, 211, 102, 0.3);
}

.drawer-action-btn.wa:hover {
  background: #25d366;
  color: #000000;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4);
}

.drawer-action-btn.cal {
  background: rgba(0, 0, 0, 0.45);
  color: #38bdf8;
  border-color: rgba(0, 0, 0, 0.45);
}

.drawer-action-btn.cal:hover {
  background: #0063e1;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.drawer-action-btn.chatwoot {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.3);
}

.drawer-action-btn.chatwoot:hover {
  background: #9333ea;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.4);
}

/* Drawer Stage Selector */
.drawer-stage-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 14px 18px;
}

.drawer-stage-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 8px;
}

.drawer-stage-select {
  width: 100%;
  padding: 10px 14px;
  background: rgba(2, 6, 23, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.drawer-stage-select:focus {
  border-color: #38bdf8;
}

/* Key Attributes Grid */
.drawer-attributes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 16px 18px;
}

.attribute-item label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 4px;
}

.attribute-item .val {
  font-size: 14px;
  font-weight: 500;
  color: #f1f5f9;
}

.attribute-item .val-money {
  color: #38bdf8;
  font-weight: 700;
  font-size: 16px;
}

/* SofIA AI Intelligence Card */
.drawer-sofia-card {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.8), rgba(30, 58, 138, 0.25));
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 15px;
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.sofia-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sofia-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #38bdf8;
}

.sofia-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.sofia-summary {
  font-size: 12px;
  line-height: 1.55;
  color: #cbd5e1;
  background: rgba(2, 6, 23, 0.4);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Drawer Timeline */
.drawer-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-item {
  display: flex;
  gap: 12px;
  position: relative;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #0063e1;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.45);
  margin-top: 5px;
  flex-shrink: 0;
}

.timeline-content {
  flex: 1;
}

.timeline-content strong {
  display: block;
  font-size: 12px;
  color: #f1f5f9;
}

.timeline-content small {
  display: block;
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

/* Drawer Notes */
.drawer-notes-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-notes-box label {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
}

.drawer-notes-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: #f8fafc;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 80px;
  outline: none;
}

.drawer-notes-textarea:focus {
  border-color: #38bdf8;
}

.drawer-footer {
  padding: 16px 28px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-footer-btn {
  padding: 10px 18px;
  border-radius: 15px !important;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.drawer-footer-btn.primary {
  background: #0063e1;
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 14px rgba(0, 0, 0, 0.45);
}

.drawer-footer-btn.primary:hover {
  background: #1d7afc;
}

.drawer-footer-btn.danger {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.25);
}

.drawer-footer-btn.danger:hover {
  background: #ef4444;
  color: #ffffff;
}

/* 4. Command Palette (Cmd+K) */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s;
}

.cmd-palette-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.cmd-palette-modal {
  width: 620px;
  max-width: 92vw;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 15px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(24px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.96);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.cmd-palette-backdrop.is-open .cmd-palette-modal {
  transform: scale(1);
}

.cmd-search-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cmd-search-icon {
  color: #64748b;
  flex-shrink: 0;
}

.cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: #f8fafc;
  font-family: inherit;
}

.cmd-input::placeholder {
  color: #64748b;
}

.cmd-esc-badge {
  font-size: 11px;
  color: #64748b;
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cmd-results-list {
  max-height: 380px;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cmd-group-label {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.12s;
  color: #cbd5e1;
  font-size: 13px;
}

.cmd-item:hover, .cmd-item.selected {
  background: rgba(0, 0, 0, 0.45);
  color: #ffffff;
}

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

.cmd-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #38bdf8;
  flex-shrink: 0;
}

.cmd-item-title {
  font-weight: 500;
}

.cmd-item-desc {
  font-size: 11px;
  color: #94a3b8;
  margin-left: 6px;
}

.cmd-item-shortcut {
  font-size: 11px;
  color: #64748b;
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 6px;
  border-radius: 4px;
}

.cmd-footer {
  padding: 10px 18px;
  background: rgba(2, 6, 23, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
