/* ==========================================================================
   Casa do Empreendedor CM - Relatório de Conversas Design System
   ========================================================================== */

:root {
  /* Color Tokens */
  --bg-dark: #070b13;
  --bg-surface: rgba(15, 23, 42, 0.72);
  --bg-surface-elevated: rgba(30, 41, 59, 0.65);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.4);
  
  /* Brand Accents */
  --emerald-primary: #10b981;
  --emerald-hover: #059669;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  --emerald-surface: rgba(6, 78, 59, 0.4);
  
  --cyan-accent: #06b6d4;
  --indigo-accent: #6366f1;
  --amber-accent: #f59e0b;
  --rose-accent: #f43f5e;
  
  /* Typography & Neutral Colors */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  /* Font Stacks */
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  
  /* Layout Dimensions */
  --sidebar-width: 380px;
  --header-height: 72px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  /* Shadows & Glassmorphism */
  --glass-blur: blur(20px);
  --glass-shadow: 0 12px 32px 0 rgba(0, 0, 0, 0.45);
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Ambient Glows */
.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
  transition: opacity 0.5s ease;
}

.glow-emerald {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #10b981 0%, transparent 70%);
  top: -150px;
  left: 10%;
}

.glow-indigo {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #6366f1 0%, transparent 70%);
  bottom: -200px;
  right: -100px;
}

.glow-cyan {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
  top: 40%;
  left: 60%;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  background: rgba(7, 11, 19, 0.85);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px var(--emerald-glow);
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.brand-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  color: #34d399;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--emerald-primary);
  box-shadow: 0 0 10px var(--emerald-primary);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Button Component Library */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--emerald-primary) 0%, var(--emerald-hover) 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--emerald-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-whatsapp {
  background: #25D366;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.btn-whatsapp:hover {
  background: #20bd5a;
  transform: translateY(-1px);
}

.btn-icon {
  padding: 10px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.btn-icon:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Dashboard Container */
.dashboard-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 28px;
  position: relative;
  z-index: 10;
}

/* KPI Cards Row */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition-smooth), border-color var(--transition-smooth);
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.16);
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon.emerald { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.kpi-icon.cyan { background: rgba(6, 182, 212, 0.15); color: #38bdf8; }
.kpi-icon.indigo { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.kpi-icon.amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

.kpi-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.kpi-val-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
}

.kpi-value-sm {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
}

.kpi-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.badge-emerald { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-cyan { background: rgba(6, 182, 212, 0.15); color: #38bdf8; border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-indigo { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; border: 1px solid rgba(99, 102, 241, 0.3); }

/* Workspace Split Layout */
.workspace-grid {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: 24px;
  height: calc(100vh - var(--header-height) - 170px);
  min-height: 600px;
}

/* Left Sidebar */
.sidebar-panel {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 14px;
  color: var(--text-subtle);
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.search-box input:focus {
  border-color: var(--emerald-primary);
  box-shadow: 0 0 0 2px var(--border-focus);
}

.filter-pills {
  display: flex;
  gap: 8px;
}

.filter-pill {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-pill:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.filter-pill.active {
  background: var(--emerald-surface);
  border-color: var(--emerald-primary);
  color: #34d399;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Conversation Item Card */
.conversa-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.conversa-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.05);
}

.conversa-item.active {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.35);
}

.item-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.conversa-item.active .item-avatar {
  background: linear-gradient(135deg, #064e3b 0%, #059669 100%);
  color: #ffffff;
  border-color: var(--emerald-primary);
}

.item-body {
  flex: 1;
  min-width: 0;
}

.item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.item-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-time {
  font-size: 0.72rem;
  color: var(--text-subtle);
  flex-shrink: 0;
}

.item-snippet {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
  line-height: 1.3;
}

.item-tags {
  display: flex;
  align-items: center;
  gap: 6px;
}

.item-tag {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
}

.item-tag.tag-highlight {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

/* Detail Panel / Chat Viewer */
.detail-panel {
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  box-shadow: 0 4px 12px var(--emerald-glow);
}

.chat-user-name {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
}

.chat-user-sub {
  font-size: 0.82rem;
  color: #38bdf8;
  font-weight: 500;
}

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

/* Lead Profile Info Card */
.lead-profile-card {
  padding: 14px 24px;
  background: rgba(30, 41, 59, 0.4);
  border-bottom: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  font-size: 0.82rem;
}

.profile-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.profile-label {
  color: var(--text-subtle);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.profile-value {
  color: var(--text-main);
  font-weight: 500;
}

.profile-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  font-weight: 600;
  width: fit-content;
}

/* Chat Messages Viewport */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-selection {
  margin: auto;
  text-align: center;
  max-width: 380px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.6;
}

.empty-selection h3 {
  font-family: var(--font-heading);
  color: #ffffff;
  margin-bottom: 8px;
}

.empty-selection p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Chat Bubbles */
.chat-row {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}

.chat-row.user-msg {
  align-self: flex-start;
}

.chat-row.assistant-msg {
  align-self: flex-end;
}

.bubble-author {
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 4px;
  padding: 0 4px;
}

.user-msg .bubble-author {
  color: #38bdf8;
}

.assistant-msg .bubble-author {
  color: #34d399;
  text-align: right;
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  position: relative;
  font-size: 0.9rem;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  word-break: break-word;
}

.user-msg .chat-bubble {
  background: #1e293b;
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: #f1f5f9;
  border-top-left-radius: 2px;
}

.assistant-msg .chat-bubble {
  background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #ffffff;
  border-top-right-radius: 2px;
}

.bubble-time {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 6px;
  text-align: right;
}

/* Modal Window */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #111827;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  box-shadow: var(--glass-shadow);
  transform: translateY(12px);
  transition: transform var(--transition-smooth);
  overflow: hidden;
}

.modal-overlay.open .modal-content {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.modal-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-icon.emerald {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: #ffffff;
}

.modal-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #ffffff;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.875rem;
  outline: none;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--emerald-primary);
  box-shadow: 0 0 0 2px var(--border-focus);
}

.form-help {
  font-size: 0.74rem;
  color: var(--text-subtle);
}

.report-preview-box {
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.preview-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #34d399;
  margin-bottom: 8px;
}

.preview-list {
  list-style: none;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-footer {
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: #1e293b;
  border: 1px solid var(--border-subtle);
  color: #ffffff;
  font-size: 0.875rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.25s ease forwards;
  min-width: 280px;
}

.toast.toast-success {
  border-color: rgba(16, 185, 129, 0.5);
  background: linear-gradient(135deg, #064e3b 0%, #1e293b 100%);
}

.toast.toast-error {
  border-color: rgba(244, 63, 94, 0.5);
  background: linear-gradient(135deg, #881337 0%, #1e293b 100%);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Loading Spinners */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--emerald-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .workspace-grid {
    grid-template-columns: 320px 1fr;
  }
  .lead-profile-card {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .navbar {
    padding: 0 16px;
  }
  .status-pill {
    display: none;
  }
  .dashboard-container {
    padding: 16px;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .workspace-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  .sidebar-panel {
    height: 380px;
  }
  .detail-panel {
    height: 520px;
  }
  .lead-profile-card {
    grid-template-columns: 1fr;
  }
}
