/* ============================================
   CONVERSATION LAYOUT — 3-Zone Flex
   Variant A Clean Flow Design
   ============================================ */

/* --- Root container (already has Tailwind: flex h-screen overflow-hidden) --- */


/* =============================================
   ZONE 1: CLIENT SIDEBAR (280px, left)
   ============================================= */

.client-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid #e8eaed;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #d4d7e5 transparent;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.03);
}

.dark .client-sidebar {
  background: #1e293b;
  border-right-color: #334155;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}

/* --- Sidebar Header --- */
.client-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.dark .client-header {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.back-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.back-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.15s;
}

.back-btn:hover {
  background: #f1f5f9;
  color: #64748b;
}

.dark .back-btn:hover {
  background: #334155;
  color: #cbd5e1;
}

.back-btn svg {
  width: 20px;
  height: 20px;
}

.client-id {
  font-size: 13px;
  color: #94a3b8;
  font-weight: 500;
}

/* --- Avatar section --- */
.client-avatar-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.client-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.client-name {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

.dark .client-name {
  color: #f1f5f9;
}

.client-meta {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

/* --- Topbar Status Badge (read-only indicator) --- */
.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
}

.topbar-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.topbar-status--open {
  background: #dcfce7;
  color: #16a34a;
}

.topbar-status--open .topbar-status-dot {
  background: #16a34a;
  animation: statusPulse 2s ease-in-out infinite;
}

.topbar-status--closed {
  background: #f1f5f9;
  color: #64748b;
}

.topbar-status--closed .topbar-status-dot {
  background: #94a3b8;
}

.dark .topbar-status--open {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.dark .topbar-status--closed {
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Topbar Action Buttons (clickable) --- */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

/* --- Topbar action buttons (distinct styles per action) --- */
.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.15s ease;
}

.topbar-btn:active {
  transform: scale(0.96);
}

/* button_to wraps in <form> — reset inner button */
.topbar-btn > button[type="submit"] {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  cursor: pointer;
  padding: 0;
  margin: 0;
  line-height: 1;
}

/* Оброблено — green (review mark) */
.topbar-btn--done {
  color: #15803d;
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.topbar-btn--done:hover {
  background: #dcfce7;
  border-color: #86efac;
}
.topbar-btn--done-active {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: #16a34a;
  border: 1px solid #16a34a;
}

/* Завершити — blue/indigo (complete) */
.topbar-btn--complete {
  color: #4338ca;
  background: #eef2ff;
  border-color: #c7d2fe;
}
.topbar-btn--complete:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
}


/* Закрити — red (danger) */
.topbar-btn--close {
  color: #dc2626;
  background: #fef2f2;
  border-color: #fecaca;
}
.topbar-btn--close:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* Відкрити (reopen, used in closed state) */
.topbar-btn--open {
  color: #16a34a;
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.topbar-btn--open:hover {
  background: #dcfce7;
  border-color: #86efac;
}

/* AI On — slate (disable action) */
.topbar-btn--ai-on {
  color: #475569;
  background: #f8fafc;
  border-color: #e2e8f0;
}
.topbar-btn--ai-on:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* AI Off — amber (enable action) */
.topbar-btn--ai-off {
  color: #b45309;
  background: #fffbeb;
  border-color: #fcd34d;
}
.topbar-btn--ai-off:hover {
  background: #fef3c7;
  border-color: #fbbf24;
}

/* Dark mode */
.dark .topbar-btn--done {
  color: #86efac;
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
}
.dark .topbar-btn--done:hover {
  background: rgba(34, 197, 94, 0.2);
}
.dark .topbar-btn--done-active {
  color: #fff;
  background: #16a34a;
  border-color: #16a34a;
}
.dark .topbar-btn--complete {
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
}
.dark .topbar-btn--complete:hover {
  background: rgba(99, 102, 241, 0.2);
}

.dark .topbar-btn--close {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}
.dark .topbar-btn--close:hover {
  background: rgba(239, 68, 68, 0.2);
}
.dark .topbar-btn--open {
  color: #86efac;
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
}
.dark .topbar-btn--open:hover {
  background: rgba(34, 197, 94, 0.2);
}
.dark .topbar-btn--ai-on {
  color: #94a3b8;
  background: rgba(100, 116, 139, 0.1);
  border-color: rgba(100, 116, 139, 0.3);
}
.dark .topbar-btn--ai-on:hover {
  background: rgba(100, 116, 139, 0.2);
}
.dark .topbar-btn--ai-off {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
}
.dark .topbar-btn--ai-off:hover {
  background: rgba(245, 158, 11, 0.2);
}

/* Етап — purple (stage/tab move) */
.topbar-btn--stage {
  color: #7c3aed;
  background: #f5f3ff;
  border-color: #ddd6fe;
}
.topbar-btn--stage:hover {
  background: #ede9fe;
  border-color: #c4b5fd;
}
.dark .topbar-btn--stage {
  color: #c4b5fd;
  background: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.3);
}
.dark .topbar-btn--stage:hover {
  background: rgba(139, 92, 246, 0.2);
}

/* --- Info button & panel --- */
.topbar-info-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #3b82f6;
  background: #eff6ff;
  color: #3b82f6;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.topbar-info-btn:hover {
  background: #3b82f6;
  color: #fff;
}
.dark .topbar-info-btn {
  border-color: #60a5fa;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}
.dark .topbar-info-btn:hover {
  background: #3b82f6;
  color: #fff;
}

.topbar-info-panel {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 320px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 12px;
  z-index: 50;
  font-size: 12px;
  line-height: 1.5;
  color: #475569;
}
.dark .topbar-info-panel {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.topbar-info-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
}
.topbar-info-item + .topbar-info-item {
  border-top: 1px solid #f1f5f9;
}
.dark .topbar-info-item + .topbar-info-item {
  border-top-color: #334155;
}
.topbar-info-item strong {
  font-weight: 700;
  color: #1e293b;
}
.dark .topbar-info-item strong {
  color: #f1f5f9;
}
.topbar-info-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

/* --- Info Sections (Contacts, Auto, Tags, Notes, History) --- */
.info-section {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.dark .info-section {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.info-section:last-child {
  border-bottom: none;
}

/* --- Empty States --- */
.info-section .empty-state,
.info-section .text-slate-400 {
  font-size: 12px;
  color: #b0b4c8;
  font-style: normal;
}

.dark .info-section .empty-state,
.dark .info-section .text-slate-400 {
  color: #64748b;
}

.info-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-section-title::before {
  content: '';
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: #cbd5e1;
  flex-shrink: 0;
}

.dark .info-section-title::before {
  background: #475569;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  color: #334155;
  font-weight: 500;
}

.info-row:last-child {
  margin-bottom: 0;
}

.dark .info-row {
  color: #e2e8f0;
}

.info-row svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.info-row a {
  color: #f97316;
  text-decoration: none;
  font-weight: 500;
}

.info-row a:hover {
  text-decoration: underline;
}

/* --- Notes textarea --- */
.sidebar-notes-area {
  width: 100%;
  border: 1px solid #e8eaed;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 72px;
  transition: border-color 0.2s;
  background: #fafbfc;
  color: #1e293b;
}

.sidebar-notes-area:focus,
.info-section textarea:focus {
  outline: none;
  border-color: #f97316;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.08);
}

.dark .sidebar-notes-area {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

.dark .sidebar-notes-area:focus {
  border-color: #f97316;
}


/* =============================================
   ZONE 2: CHAT MAIN (flex-1, center)
   ============================================= */

.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #f7f8fa;
  overflow: hidden;
  position: relative;
}

.dark .chat-main {
  background: #0f172a;
}

/* --- Chat Topbar — 3-zone layout --- */
.chat-topbar {
  padding: 10px 20px;
  background: #ffffff;
  border-bottom: 1px solid #e8eaed;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  min-height: 56px;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.dark .chat-topbar {
  background: #1e293b;
  border-bottom-color: #334155;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Topbar zones */
.topbar-zone {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-zone--nav {
  flex-shrink: 0;
}

.topbar-zone--status {
  flex-shrink: 0;
}

.topbar-zone--actions {
  margin-left: auto;
  gap: 6px;
}

/* Navigation arrows */
.topbar-nav-arrow {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #64748b;
  transition: all 0.15s ease;
  cursor: pointer;
}

.topbar-nav-arrow:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.dark .topbar-nav-arrow:hover {
  background: #334155;
  color: #f1f5f9;
}

.topbar-nav-arrow--disabled {
  opacity: 0.25;
  pointer-events: none;
  cursor: default;
}

.topbar-nav-counter {
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  min-width: 32px;
  text-align: center;
  user-select: none;
}

.dark .topbar-nav-counter {
  color: #64748b;
}

/* Status badge (hero element) */
.topbar-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  border-radius: 20px;
  white-space: nowrap;
}

.topbar-status-badge .topbar-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.topbar-status-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Closed conversation label */
.topbar-closed-label {
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  padding: 4px 10px;
  background: #f1f5f9;
  border-radius: 6px;
}

.dark .topbar-closed-label {
  color: #64748b;
  background: #1e293b;
}

/* Divider between action groups */
.topbar-divider {
  width: 1px;
  height: 20px;
  background: #e2e8f0;
  margin: 0 4px;
  flex-shrink: 0;
}

.dark .topbar-divider {
  background: #334155;
}

.msg-count-badge {
  background: #f1f5f9;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
}

.dark .msg-count-badge {
  background: #334155;
}

/* --- "На підбір" pulsating button in topbar --- */
.topbar-pidbir-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 28px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: none;
  cursor: pointer;
  position: relative;
  animation: pidbir-pulse 0.8s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7), 0 2px 8px rgba(239, 68, 68, 0.4);
  transition: transform 0.15s ease;
}

.topbar-pidbir-btn:hover {
  transform: scale(1.08);
  background: linear-gradient(135deg, #dc2626, #b91c1c);
}

@keyframes pidbir-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7), 0 2px 8px rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(239, 68, 68, 0), 0 2px 14px rgba(239, 68, 68, 0.6);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0), 0 2px 8px rgba(239, 68, 68, 0.4);
  }
}

/* --- Messages Container --- */
.chat-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.dark .chat-messages-container {
  scrollbar-color: #475569 transparent;
}

.chat-messages-container::-webkit-scrollbar {
  width: 6px;
}

.chat-messages-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.dark .chat-messages-container::-webkit-scrollbar-thumb {
  background: #475569;
}

/* --- Chat Input Area --- */
.chat-input-area {
  padding: 14px 24px;
  background: #ffffff;
  flex-shrink: 0;
}

.dark .chat-input-area {
  background: #1e293b;
}

/* --- Reply Textarea --- */
.reply-textarea {
  width: 100%;
  border: 1.5px solid #e8eaed;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
  color: #1e293b;
  resize: none;
}

.reply-textarea:focus {
  outline: none;
  border-color: #f97316;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.reply-textarea::placeholder {
  color: #b0b4c8;
  font-weight: 400;
}

.dark .reply-textarea {
  background: #0f172a;
  border-color: #334155;
  color: #1e293b; /* dark for clipboard */
  -webkit-text-fill-color: #e2e8f0; /* light for display */
}

.dark .reply-textarea:focus {
  border-color: #f97316;
}


/* =============================================
   ZONE 3: CALCULATOR PANEL (400px, right)
   ============================================= */

.calc-panel-container {
  width: 400px;
  flex-shrink: 0;
  background: #ffffff;
  border-left: 1px solid #e8eaed;
  overflow: hidden;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.03);
}

.dark .calc-panel-container {
  background: #1e293b;
  border-left-color: #334155;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
}


/* =============================================
   AI TOGGLE BUTTON
   ============================================= */

.ai-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid #e8eaed;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  color: #64748b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ai-toggle-btn.on,
.ai-toggle-btn[data-active="true"] {
  border-color: #f97316;
  background: #fff7ed;
  color: #f97316;
  box-shadow: 0 1px 4px rgba(249, 115, 22, 0.15);
}

.ai-toggle-btn .toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: background 0.2s;
}

.ai-toggle-btn.on .toggle-dot,
.ai-toggle-btn[data-active="true"] .toggle-dot {
  background: #f97316;
}

.dark .ai-toggle-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

.dark .ai-toggle-btn.on,
.dark .ai-toggle-btn[data-active="true"] {
  background: rgba(249, 115, 22, 0.1);
  border-color: #f97316;
  color: #f97316;
}


/* =============================================
   MESSAGE BUBBLE REFINEMENTS
   (These may already have Tailwind classes,
   but add overrides for consistency in the
   new wider chat area)
   ============================================= */

/* =============================================
   B1: MESSAGE HOVER ACTIONS
   ============================================= */

.message-hover-actions {
  position: absolute;
  top: -8px;
  right: 8px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transform: translateY(4px);
  transition: all 0.15s ease;
  pointer-events: none;
  z-index: 10;
}

.flex.justify-start .message-hover-actions {
  right: -4px;
  left: auto;
}

.flex.justify-end .message-hover-actions {
  right: auto;
  left: 8px;
}

.group:hover .message-hover-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.hover-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.hover-action-btn:hover {
  background: #f8fafc;
  color: #f97316;
  border-color: #f97316;
}

.dark .hover-action-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

.dark .hover-action-btn:hover {
  background: #334155;
  color: #f97316;
  border-color: #f97316;
}


/* Ensure messages have proper max-width in wider chat */
.chat-messages-container .message-bubble-client,
.chat-messages-container .message-bubble-engineer,
.chat-messages-container .message-bubble-ai {
  max-width: 520px;
}

.chat-messages-container .message-bubble-system {
  max-width: 560px;
}


/* =============================================
   RESPONSIVE: Mobile/Tablet Overrides
   ============================================= */

/* On screens smaller than xl (1280px), client sidebar is hidden via Tailwind: hidden xl:flex */
/* On screens smaller than lg (1024px), calculator panel is hidden via Tailwind: hidden lg:flex */

/* Mobile: full-width chat */
@media (max-width: 1023px) {
  .chat-main {
    width: 100%;
  }

  .chat-topbar {
    padding: 12px 16px;
  }

  .chat-messages-container {
    padding: 16px;
  }

  .chat-input-area {
    padding: 12px 16px;
  }
}


/* =============================================
   SCROLLBAR STYLING FOR SIDEBAR
   ============================================= */

.client-sidebar::-webkit-scrollbar {
  width: 4px;
}

.client-sidebar::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 2px;
}

.dark .client-sidebar::-webkit-scrollbar-thumb {
  background: #475569;
}

.client-sidebar::-webkit-scrollbar-thumb:hover {
  background: #cbd5e1;
}


/* =============================================
   A2: MESSAGES START FROM TOP
   (removed ::before spacer that caused visible
    empty zone when scrolling up — JS scrollToBottom
    handles initial scroll positioning)
   ============================================= */


/* =============================================
   C2: BUTTON PRESS FEEDBACK
   ============================================= */

.hover-action-btn:active,
.ai-toggle-btn:active,
.back-btn:active {
  transform: scale(0.95);
}


/* =============================================
   C3: INPUT FOCUS TRANSITIONS
   ============================================= */

.client-sidebar input,
.client-sidebar textarea,
.chat-input-area input,
.chat-input-area textarea,
.reply-textarea {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}


/* =============================================
   B4: KEYBOARD SHORTCUTS MODAL
   ============================================= */

.shortcuts-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.shortcuts-modal {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.dark .shortcuts-modal {
  background: #1e293b;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.shortcuts-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.shortcuts-modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

.dark .shortcuts-modal-header h3 {
  color: #f1f5f9;
}

.shortcuts-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #94a3b8;
  padding: 4px;
}

.shortcuts-modal-close:hover {
  color: #64748b;
}

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

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #475569;
}

.dark .shortcut-row {
  color: #cbd5e1;
}

.shortcut-row span {
  margin-left: auto;
}

.shortcut-row kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 6px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  color: #475569;
}

.dark .shortcut-row kbd {
  background: #0f172a;
  border-color: #334155;
  color: #cbd5e1;
}


/* =============================================
   B5: TYPING INDICATOR
   ============================================= */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 24px;
  color: #94a3b8;
  font-size: 13px;
  font-style: italic;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}


/* =============================================
   B7: SCROLL TO BOTTOM BUTTON
   ============================================= */

.chat-main .scroll-to-bottom-btn {
  position: absolute;
  bottom: 80px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #e8eaed;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
  z-index: 20;
}

.chat-main .scroll-to-bottom-btn:hover {
  background: #f97316;
  color: #fff;
  border-color: #f97316;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.3);
}

.dark .chat-main .scroll-to-bottom-btn {
  background: #334155;
  border-color: #475569;
  color: #94a3b8;
}

.dark .chat-main .scroll-to-bottom-btn:hover {
  background: #f97316;
  color: #fff;
  border-color: #f97316;
}


/* =============================================
   B8: CALCULATOR STICKY TOTAL FOOTER
   ============================================= */

.calc-panel-container {
  display: flex;
  flex-direction: column;
}

.calc-panel-container .parts-calculator {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Parts list takes remaining space and scrolls */
.calc-panel-container .calc-parts-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  min-height: 80px;
  max-height: none;
}

.calc-panel-container .calc-parts-list::-webkit-scrollbar {
  width: 6px;
}

.calc-panel-container .calc-parts-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.dark .calc-panel-container .calc-parts-list::-webkit-scrollbar-thumb {
  background: #475569;
}

/* Add button, totals, actions — all pinned to bottom */
.calc-panel-container .calc-btn--add {
  flex-shrink: 0;
}

.calc-panel-container .calc-totals {
  flex-shrink: 0;
}

.calc-panel-container .calc-actions {
  flex-shrink: 0;
}


/* =============================================
   MESSAGE LABELS AND TIMESTAMPS — REFINED
   ============================================= */

/* Message sender labels */
.chat-messages-container .text-xs.font-semibold {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
}

/* AI label — orange */
.chat-messages-container .flex.justify-end .text-xs.font-semibold {
  color: #f97316;
}

/* Message timestamps — more muted */
.chat-messages-container .message-timestamp {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 400;
}


/* =============================================
   CALCULATOR PANEL — POLISHED CARDS & INPUTS
   ============================================= */

/* Calculator header */
.calc-panel-container .parts-calculator-header,
.calc-panel-container > div:first-child {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #e8eaed;
}

.calc-panel-container .parts-calculator-header h2,
.calc-panel-container .parts-calculator-header .text-lg {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}

.dark .calc-panel-container .parts-calculator-header h2 {
  color: #f1f5f9;
}

.calc-panel-container .parts-calculator-header .text-sm {
  font-size: 12px;
  color: #8b8fa3;
}

/* Part cards — elevation and hover */
.calc-panel-container .rounded-xl.border {
  background: #f7f8fa;
  border: 1.5px solid #e8eaed !important;
  border-radius: 14px !important;
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.calc-panel-container .rounded-xl.border:hover {
  border-color: #f97316 !important;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.1);
}

.dark .calc-panel-container .rounded-xl.border {
  background: #0f172a;
  border-color: #334155 !important;
}

.dark .calc-panel-container .rounded-xl.border:hover {
  border-color: #f97316 !important;
}

/* Calculator form inputs — polish */
.calc-panel-container input[type="text"],
.calc-panel-container input[type="number"],
.calc-panel-container select {
  border: 1.5px solid #e8eaed;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s;
  background: #fff;
  color: #1e293b;
}

.calc-panel-container input:focus,
.calc-panel-container select:focus {
  outline: none;
  border-color: #f97316;
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.08);
}

.dark .calc-panel-container input[type="text"],
.dark .calc-panel-container input[type="number"],
.dark .calc-panel-container select {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

/* Summary cards */
.calc-panel-container .bg-slate-50 {
  background: #f7f8fa;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

/* Price value — orange */
.calc-panel-container .text-orange-500,
.calc-panel-container .text-orange-600 {
  color: #f97316 !important;
  font-weight: 700;
}

/* Profit value — green */
.calc-panel-container .text-green-500,
.calc-panel-container .text-green-600 {
  color: #2e7d32 !important;
  font-weight: 700;
}

/* Summary labels */
.calc-panel-container .text-xs.uppercase {
  font-size: 11px;
  color: #8b8fa3;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Add Part button — dashed */
.calc-panel-container .border-dashed {
  width: 100%;
  padding: 12px;
  border: 2px dashed #d4d7e5 !important;
  border-radius: 12px !important;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: #8b8fa3;
  cursor: pointer;
  transition: all 0.2s;
}

.calc-panel-container .border-dashed:hover {
  border-color: #f97316 !important;
  color: #f97316;
  background: #fff7ed;
}

/* Action buttons — refined */
.calc-panel-container button[class*="slate"]:hover {
  background: #e8eaed;
}

.calc-panel-container button[class*="amber"]:hover {
  background: #ffe0b2;
}

/* Checkbox accent */
.calc-panel-container input[type="checkbox"] {
  accent-color: #f97316;
}


/* =============================================
   SEND BUTTONS — POLISHED
   ============================================= */

/* Main send (AI) button */
.chat-input-area button[class*="gradient"] {
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
  transition: box-shadow 0.2s, filter 0.2s;
}

.chat-input-area button[class*="gradient"]:hover {
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
  filter: brightness(1.05);
}


/* =============================================
   MESSAGE ENTRANCE ANIMATION
   ============================================= */

@keyframes message-slide-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-message-in {
  animation: message-slide-in 0.25s ease-out;
}


/* =============================================
   SCROLLBAR REFINEMENT — UNIFIED
   ============================================= */

.client-sidebar::-webkit-scrollbar-thumb,
.chat-messages-container::-webkit-scrollbar-thumb {
  background: #d4d7e5;
  border-radius: 3px;
}

.client-sidebar::-webkit-scrollbar-thumb:hover,
.chat-messages-container::-webkit-scrollbar-thumb:hover {
  background: #b0b4c8;
}

.dark .client-sidebar::-webkit-scrollbar-thumb,
.dark .chat-messages-container::-webkit-scrollbar-thumb {
  background: #475569;
}


/* =============================================
   GLOBAL HOVER AND TRANSITIONS
   ============================================= */

/* Links in sidebar — orange on hover */
.client-sidebar a:hover {
  color: #f97316;
}


/* =============================================
   CLIENT JOURNEY TRACKER (sidebar)
   ============================================= */

.journey-tracker {
  padding: 2px 0;
}

.journey-step {
  display: flex;
  gap: 10px;
  min-height: 32px;
}

.journey-step:last-child {
  min-height: auto;
}

.journey-step-line-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 16px;
  flex-shrink: 0;
  padding-top: 4px;
}

/* Dot base */
.journey-step-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s ease;
}

/* Line between dots */
.journey-step-line {
  width: 2px;
  flex: 1;
  min-height: 12px;
  margin: 2px 0;
  transition: background-color 0.2s ease;
}

/* Content area */
.journey-step-content {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  flex: 1;
  padding-bottom: 8px;
  min-width: 0;
}

.journey-step:last-child .journey-step-content {
  padding-bottom: 0;
}

.journey-step-label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dark .journey-step-label {
  color: #94a3b8;
}

.journey-step-date {
  font-size: 10px;
  color: #94a3b8;
  flex-shrink: 0;
  margin-left: 8px;
}

.dark .journey-step-date {
  color: #64748b;
}

.journey-step-subtitle {
  font-size: 10px;
  color: #3b82f6;
  width: 100%;
  margin-top: 1px;
}

.dark .journey-step-subtitle {
  color: #60a5fa;
}

/* --- Completed state --- */
.journey-step--completed .journey-step-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
}

.journey-step--completed .journey-step-line {
  background: #10b981;
}

.journey-step--completed .journey-step-label {
  color: #334155;
  font-weight: 600;
}

.dark .journey-step--completed .journey-step-dot {
  background: #34d399;
}

.dark .journey-step--completed .journey-step-line {
  background: #34d399;
}

.dark .journey-step--completed .journey-step-label {
  color: #e2e8f0;
}

/* --- Active state (pulsing orange) --- */
.journey-step--active .journey-step-dot {
  background: #f97316;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
  animation: journeyPulse 2s ease-in-out infinite;
}

.journey-step--active .journey-step-line {
  background: repeating-linear-gradient(
    to bottom,
    #cbd5e1 0px,
    #cbd5e1 4px,
    transparent 4px,
    transparent 8px
  );
}

.dark .journey-step--active .journey-step-line {
  background: repeating-linear-gradient(
    to bottom,
    #475569 0px,
    #475569 4px,
    transparent 4px,
    transparent 8px
  );
}

.journey-step--active .journey-step-label {
  color: #f97316;
  font-weight: 600;
}

.dark .journey-step--active .journey-step-label {
  color: #fb923c;
}

/* --- Pending state --- */
.journey-step--pending .journey-step-dot {
  width: 8px;
  height: 8px;
  background: transparent;
  border: 1.5px solid #cbd5e1;
}

.dark .journey-step--pending .journey-step-dot {
  border-color: #475569;
}

.journey-step--pending .journey-step-line {
  background: repeating-linear-gradient(
    to bottom,
    #e2e8f0 0px,
    #e2e8f0 4px,
    transparent 4px,
    transparent 8px
  );
}

.dark .journey-step--pending .journey-step-line {
  background: repeating-linear-gradient(
    to bottom,
    #334155 0px,
    #334155 4px,
    transparent 4px,
    transparent 8px
  );
}

/* --- Skipped state (bypassed step) --- */
.journey-step--skipped .journey-step-dot {
  width: 8px;
  height: 8px;
  background: #cbd5e1;
  border: none;
}

.dark .journey-step--skipped .journey-step-dot {
  background: #475569;
}

.journey-skip-icon {
  width: 6px;
  height: 6px;
  color: #fff;
}

.journey-step--skipped .journey-step-line {
  background: repeating-linear-gradient(
    to bottom,
    #cbd5e1 0px,
    #cbd5e1 4px,
    transparent 4px,
    transparent 8px
  );
}

.dark .journey-step--skipped .journey-step-line {
  background: repeating-linear-gradient(
    to bottom,
    #475569 0px,
    #475569 4px,
    transparent 4px,
    transparent 8px
  );
}

.journey-step--skipped .journey-step-label {
  color: #94a3b8;
  text-decoration: line-through;
}

.dark .journey-step--skipped .journey-step-label {
  color: #64748b;
}

/* --- Active state: no padding-top offset (keeps 16px dot centered) --- */
.journey-step--active .journey-step-line-area {
  padding-top: 0;
}

/* --- Clickable step link --- */
.journey-step-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.journey-step-link:hover .journey-step-label {
  color: #f97316;
}

.dark .journey-step-link:hover .journey-step-label {
  color: #fb923c;
}

/* Override .client-sidebar a:hover for journey links */
.client-sidebar .journey-step-link {
  color: inherit;
}

.client-sidebar .journey-step-link:hover {
  color: inherit;
}

.client-sidebar .journey-step-link:hover .journey-step-label {
  color: #f97316;
}

.dark .client-sidebar .journey-step-link:hover .journey-step-label {
  color: #fb923c;
}

/* --- Topbar form.button_to fix (bug #2) --- */
.topbar-actions form.button_to {
  display: contents;
}

/* Pulse animation */
@keyframes journeyPulse {
  0%, 100% {
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.1);
  }
}

/* --- Journey step enter animation (for Turbo Stream updates) --- */
@keyframes journeyStepEnter {
  from {
    opacity: 0.5;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.journey-step-enter {
  animation: journeyStepEnter 0.3s ease-out both;
}

/* Stagger animation for each step */
.journey-step-enter:nth-child(1) { animation-delay: 0s; }
.journey-step-enter:nth-child(2) { animation-delay: 0.03s; }
.journey-step-enter:nth-child(3) { animation-delay: 0.06s; }
.journey-step-enter:nth-child(4) { animation-delay: 0.09s; }
.journey-step-enter:nth-child(5) { animation-delay: 0.12s; }
.journey-step-enter:nth-child(6) { animation-delay: 0.15s; }
.journey-step-enter:nth-child(7) { animation-delay: 0.18s; }
.journey-step-enter:nth-child(8) { animation-delay: 0.21s; }

/* Smooth transitions for dot/line state changes */
.journey-step-dot {
  transition: width 0.3s ease, height 0.3s ease, background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.journey-step-line {
  transition: background 0.3s ease;
}

.journey-step-label {
  transition: color 0.3s ease, font-weight 0.2s ease;
}
