/* ==========================================================================
   WhatsApp-Style Legal ERP Simulator Stylesheet
   Módulo 9 + Módulo 3 + Requirements 2026-07-22
   ========================================================================== */

:root {
  --wa-bg: #E5DDD5;
  --wa-green: #00a884;
  --wa-dark-green: #075e54;
  --wa-user-bubble: #DCF8C6;
  --wa-assistant-bubble: #FFFFFF;
  --wa-text-primary: #111b21;
  --wa-text-secondary: #667781;
  --panel-bg: #f0f2f5;
  --card-bg: #ffffff;
  --border-color: #e9edef;
  --primary-blue: #007bff;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: #d1d7db;
  color: var(--wa-text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header principal del ERP */
.app-header {
  height: 60px;
  background-color: var(--wa-dark-green);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

.app-title-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-title {
  font-size: 18px;
  font-weight: 600;
}

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

.btn-header {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}

.btn-header:hover {
  background: rgba(255, 255, 255, 0.25);
}

.mock-mode-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  background: #fff3cd;
  color: #856404;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 600;
}

/* Layout principal en 3 columnas */
.main-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Columna 1: Historial de Conversaciones Recientes */
.sidebar-recents {
  width: 280px;
  background-color: var(--card-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 14px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 14px;
  color: var(--wa-text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.recents-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
}

.recent-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.15s;
}

.recent-item:hover {
  background-color: #f5f6f6;
}

.recent-item.active {
  background-color: #e9edef;
}

.recent-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.recent-date {
  font-size: 11px;
  color: var(--wa-text-secondary);
  font-weight: normal;
}

.recent-preview {
  font-size: 12.5px;
  color: var(--wa-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tabs superiores de conversaciones paralelas */
.tabs-bar {
  display: flex;
  background-color: #e9edef;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.tab-item {
  padding: 8px 16px;
  font-size: 13px;
  background: #d9e0e4;
  border-right: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

}

.tab-item.active {
  background: var(--card-bg);
  font-weight: 600;
  border-bottom: 2px solid var(--wa-green);
}

.tab-close {
  font-size: 14px;
  color: #888;
  border-radius: 50%;
  padding: 0 4px;
}

.tab-close:hover {
  background: #ccc;
  color: #333;
}

/* Columna 2: Chat principal estilo WhatsApp */
.chat-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--wa-bg);
  position: relative;
}

.chat-header {
  height: 60px;
  background-color: #f0f2f5;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.chat-avatar-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--wa-dark-green);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
}

.chat-title {
  font-size: 15px;
  font-weight: 600;
}

.chat-subtitle {
  font-size: 12px;
  color: var(--wa-text-secondary);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Área de mensajes */
.chat-messages {
  flex: 1;
  padding: 16px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-image: radial-gradient(rgba(0,0,0,0.03) 1px, transparent 0);
  background-size: 16px 16px;
}

/* Burbujas de chat */
.bubble-container {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  margin-bottom: 4px;
}

.bubble-container.user {
  align-self: flex-end;
}

.bubble-container.assistant {
  align-self: flex-start;
}

.bubble {
  padding: 8px 12px 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
  position: relative;
}

.bubble-user {
  background-color: var(--wa-user-bubble);
  border-bottom-right-radius: 2px;
}

.bubble-assistant {
  background-color: var(--wa-assistant-bubble);
  border-bottom-left-radius: 2px;
}

.bubble-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
}

.bubble-time {
  font-size: 10.5px;
  color: var(--wa-text-secondary);
}

.bubble-debug-tag {
  font-size: 10px;
  background: #eef2f5;
  color: #555;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: auto;
  border: 1px solid #dcdcdc;
}

/* Typing Dots Animation (Módulo 9) */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: white;
  border-radius: 12px;
  border-bottom-left-radius: 2px;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.typing-dots .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #888;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dots .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* Área de input de chat */
.chat-input-bar {
  height: 62px;
  background-color: #f0f2f5;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border-color);
}

.chat-input {
  flex: 1;
  height: 42px;
  border: none;
  outline: none;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 14.5px;
  background: white;
}

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--wa-green);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: transform 0.1s;
}

.btn-send:hover {
  transform: scale(1.05);
}

/* Columna 3: Lead Panel (Ficha + Termostato) */
.lead-panel {
  width: 360px;
  background-color: var(--panel-bg);
  border-left: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--wa-text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Checklist de Datos */
.checklist-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
}

.checklist-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--wa-text-primary);
}

.check-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
}

.check-icon.done {
  background-color: #d1e7dd;
  color: #0f5132;
}

.check-icon.pending {
  background-color: #e9edef;
  color: #888;
}

.field-val {
  font-weight: 600;
  font-size: 12.5px;
  color: #0f5132;
}

.field-val.pending {
  font-weight: normal;
  color: #888;
  font-style: italic;
}

/* Progress Bar Component */
.progress-bar-container {
  margin: 10px 0;
}

.progress-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--wa-text-secondary);
}

.progress-bar-track {
  height: 10px;
  background-color: #e9edef;
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffc107, #28a745);
  transition: width 0.4s ease;
}

/* Banner de reclasificación de rubro (Misión 7) */
.reclassification-banner {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  animation: fadeIn 0.3s ease-in;
}

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

/* Dropdown Rubro Selector */
.rubro-selector-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.rubro-select {
  flex: 1;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  background: #f8f9fa;
  cursor: pointer;
}

.rubro-confidence-tag {
  font-size: 11px;
  font-weight: bold;
  background: #e2e3e5;
  padding: 4px 6px;
  border-radius: 4px;
  color: #383d41;
}

/* Badges de estado (Misión 4) */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.active {
  background-color: #d1e7dd;
  color: #0f5132;
}

.status-badge.handed_off {
  background-color: #fff3cd;
  color: #856404;
}

.status-badge.assigned {
  background-color: #cff4fc;
  color: #055160;
}

.status-badge.closed {
  background-color: #e2e3e5;
  color: #383d41;
}

/* Botón ⭐ Promover a few-shot (Misión 8) */
.btn-promote {
  width: 100%;
  background: linear-gradient(135deg, #6f42c1, #4e2a84);
  color: white;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  box-shadow: 0 2px 4px rgba(111, 66, 193, 0.2);
  transition: opacity 0.2s;
}

.btn-promote:hover {
  opacity: 0.9;
}

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 560px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #666;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 14px 20px;
  background: #f8f9fa;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-secondary {
  background: #e9edef;
  color: #333;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--wa-green);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

/* Few-shot Promote Turn Selector List */
.turn-select-item {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  background: #fafafa;
}

.turn-select-item.selected {
  border-color: #6f42c1;
  background: #f3ebf9;
}

.turn-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 12.5px;
  margin-bottom: 4px;
}

.turn-preview-text {
  font-size: 13px;
  color: #444;
  line-height: 1.35;
  background: white;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px dashed #ccc;
}

.presidio-tag {
  color: #d63384;
  font-weight: bold;
}

/* Debug Drawer / Controls (Misión 5) */
.debug-drawer {
  position: absolute;
  top: 60px;
  right: 0;
  width: 320px;
  background: white;
  border-left: 1px solid var(--border-color);
  box-shadow: -2px 4px 10px rgba(0,0,0,0.1);
  padding: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.debug-control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.debug-control-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--wa-text-secondary);
  text-transform: uppercase;
}

.debug-select, .debug-btn {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 12.5px;
  background: #f8f9fa;
  cursor: pointer;
}

.debug-btn-danger {
  background: #f8d7da;
  color: #842029;
  border-color: #f5c2c7;
}

/* Responsive adjustments */
@media (max-width: 992px) {
  .sidebar-recents {
    width: 200px;
  }
  .lead-panel {
    width: 300px;
  }
}
