/* ===== Dashboard Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #25D366;
  --green-dark: #128C7E;
  --green-light: #DCF8C6;
  --teal: #075E54;
  --bg: #0a0a0f;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --bg-surface: #111118;
  --bg-elevated: #1a1a24;
  --text: #f0f0f5;
  --text-muted: #8b8b9e;
  --text-dim: #5a5a6e;
  --border: rgba(255,255,255,0.08);
  --border-active: rgba(37,211,102,0.3);
  --radius: 12px;
  --radius-lg: 16px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --sidebar-w: 240px;
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
}

.sidebar-header { margin-bottom: 32px; padding: 0 8px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.2rem;
}
.sidebar-logo { width: 32px; height: 32px; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-card-hover); color: var(--text); }
.nav-item.active { background: rgba(37,211,102,0.1); color: var(--green); }

.sidebar-footer { padding-top: 12px; border-top: 1px solid var(--border); }

/* ===== Main Content ===== */
.main {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ===== Stats Bar ===== */
.stats-bar {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}

.stat-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
}
.stat-card.highlight {
  border-color: rgba(37,211,102,0.2);
  background: rgba(37,211,102,0.05);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.stat-card.highlight .stat-value { color: var(--green); }

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

/* ===== Views ===== */
.view { display: none; flex: 1; min-height: 0; }
.view.active { display: flex; flex-direction: column; }

/* ===== Conversations Layout ===== */
.conversations-layout {
  display: grid;
  grid-template-columns: 300px 1fr 280px;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

/* Conversation List */
.convo-list {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.convo-list-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.convo-list-header h2 { font-size: 1rem; font-weight: 700; }

.convo-filters { display: flex; gap: 4px; }
.filter-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
}
.filter-btn.active, .filter-btn:hover {
  background: rgba(37,211,102,0.1);
  color: var(--green);
  border-color: rgba(37,211,102,0.2);
}

.convo-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.convo-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.convo-item:hover { background: var(--bg-card-hover); }
.convo-item.active {
  background: rgba(37,211,102,0.05);
  border-color: rgba(37,211,102,0.15);
}

.convo-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.convo-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.convo-time {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.convo-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convo-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.convo-score {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(37,211,102,0.15);
  color: var(--green);
}
.convo-score.cold { background: rgba(100,116,139,0.15); color: #94a3b8; }
.convo-score.warm { background: rgba(245,158,11,0.15); color: #f59e0b; }
.convo-score.hot { background: rgba(239,68,68,0.15); color: #ef4444; }

.convo-stage {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: capitalize;
}

/* Chat Detail */
.chat-detail {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  background: rgba(37,211,102,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--green);
}

.chat-header-info { flex: 1; }
.chat-header-name { font-size: 0.95rem; font-weight: 600; }
.chat-header-phone { font-size: 0.75rem; color: var(--text-muted); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  animation: fadeIn 0.3s ease;
}
.chat-msg.customer {
  align-self: flex-start;
  background: rgba(255,255,255,0.08);
  border-bottom-left-radius: 4px;
}
.chat-msg.assistant {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(37,211,102,0.2), rgba(18,140,126,0.2));
  border-bottom-right-radius: 4px;
}

.chat-msg-time {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 4px;
  text-align: right;
}
.chat-msg-ai {
  font-size: 0.6rem;
  color: var(--green);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-msg-ai svg { width: 10px; height: 10px; }

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

/* Profile Panel */
.profile-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.profile-header {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin: 0 auto 12px;
}

.profile-name { font-size: 1.1rem; font-weight: 700; }
.profile-company { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.profile-score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 12px;
}
.profile-score.cold { background: rgba(100,116,139,0.15); color: #94a3b8; }
.profile-score.warm { background: rgba(245,158,11,0.15); color: #f59e0b; }
.profile-score.hot { background: rgba(239,68,68,0.15); color: #ef4444; }
.profile-score.very-hot { background: rgba(37,211,102,0.15); color: var(--green); }

.profile-body { padding: 16px 20px; }

.profile-section {
  margin-bottom: 20px;
}
.profile-section-title {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 8px;
}

.profile-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.profile-field:last-child { border-bottom: none; }
.profile-field-label { font-size: 0.8rem; color: var(--text-muted); }
.profile-field-value { font-size: 0.8rem; font-weight: 500; color: var(--text); text-align: right; }

.profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.profile-tag {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 500;
  background: rgba(37,211,102,0.1);
  color: var(--green);
  border: 1px solid rgba(37,211,102,0.15);
}

.profile-intent {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.5;
  padding: 10px;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ===== Customers View ===== */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.view-header h2 { font-size: 1.25rem; font-weight: 700; }

.customer-filters select {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
}
.customer-filters select option { background: var(--bg-surface); }

.customers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  overflow-y: auto;
}

.customer-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.customer-card:hover {
  border-color: rgba(37,211,102,0.2);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.customer-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.customer-card-avatar {
  width: 44px;
  height: 44px;
  background: rgba(37,211,102,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--green);
  flex-shrink: 0;
}

.customer-card-info { flex: 1; min-width: 0; }
.customer-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.customer-card-company {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.customer-card-score {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}

.customer-card-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.customer-card-detail {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}
.customer-card-detail .label { color: var(--text-muted); }
.customer-card-detail .value { color: var(--text); font-weight: 500; text-transform: capitalize; }

/* ===== Simulator ===== */
.simulator-layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 24px;
  flex: 1;
  min-height: 0;
}

.sim-phone {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sim-phone-header {
  padding: 14px 16px;
  background: var(--teal);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sim-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.sim-avatar svg { width: 18px; height: 18px; }
.sim-name { font-size: 0.9rem; font-weight: 600; color: #fff; }
.sim-status { font-size: 0.7rem; color: rgba(255,255,255,0.7); }

.sim-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #0b0b12;
  background-image: radial-gradient(rgba(37,211,102,0.03) 1px, transparent 1px);
  background-size: 20px 20px;
  min-height: 300px;
}

.sim-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  animation: fadeIn 0.3s ease;
}
.sim-msg.customer {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(37,211,102,0.2), rgba(18,140,126,0.2));
  border-bottom-right-radius: 4px;
}
.sim-msg.assistant {
  align-self: flex-start;
  background: rgba(255,255,255,0.08);
  border-bottom-left-radius: 4px;
}
.sim-msg .ai-badge {
  font-size: 0.6rem;
  color: var(--green);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sim-typing {
  align-self: flex-start;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(255,255,255,0.08);
  display: flex;
  gap: 4px;
}
.sim-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}
.sim-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.sim-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

.sim-input {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sim-input input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: var(--font);
  outline: none;
}
.sim-input input:focus { border-color: var(--green); }
.sim-input input::placeholder { color: var(--text-dim); }

.sim-send-row {
  display: flex;
  gap: 8px;
}
.sim-send-row input { flex: 1; }

.sim-send-btn {
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}
.sim-send-btn:hover { transform: scale(1.05); }
.sim-send-btn svg { width: 18px; height: 18px; }

.sim-info {
  padding: 24px;
}
.sim-info h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.sim-info p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 24px;
}

.sim-presets h4 {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 12px;
}

.preset-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.preset-btn:hover {
  background: var(--bg-card-hover);
  border-color: rgba(37,211,102,0.2);
}

/* ===== Empty States ===== */
.empty-state, .chat-placeholder, .profile-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  height: 100%;
}
.empty-icon { width: 48px; height: 48px; color: var(--text-dim); margin-bottom: 12px; }
.empty-state p, .chat-placeholder p, .profile-placeholder p {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}
.empty-state span {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .conversations-layout { grid-template-columns: 280px 1fr; }
  .profile-panel { display: none; }
}

@media (max-width: 900px) {
  .sidebar { width: 60px; min-width: 60px; padding: 12px 8px; }
  .sidebar-brand span, .nav-item span, .sidebar-footer span { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item svg { margin: 0; }
  .sidebar-header { margin-bottom: 16px; }
  .sidebar-brand { justify-content: center; }

  .stats-bar { flex-wrap: wrap; }
  .stat-card { min-width: 100px; }

  .conversations-layout { grid-template-columns: 1fr; }
  .simulator-layout { grid-template-columns: 1fr; }
}
