/* ============================================
   WA CRM Pro — Main Stylesheet
   ============================================ */

:root {
  --sidebar-width: 250px;
  --sidebar-bg: #0a1628;
  --sidebar-hover: #1a2b4a;
  --sidebar-active: #25d366;
  --wa-green: #25d366;
  --wa-dark: #075e54;
  --primary: #0d6efd;
  --topbar-h: 60px;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f0f2f5;
  margin: 0;
  color: #212529;
}

/* ── Sidebar ──────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-logo {
  width: 38px; height: 38px;
  background: var(--wa-green);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: white;
}
.brand-name { color: white; font-weight: 700; font-size: 1.05rem; }

.sidebar-nav { padding: 12px 8px; flex: 1; }
.nav-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.35);
  padding: 14px 12px 4px;
  font-weight: 600;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: rgba(255,255,255,0.7);
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.15s;
  margin-bottom: 2px;
}
.nav-link i { width: 18px; text-align: center; font-size: 0.9rem; }
.nav-link:hover { background: var(--sidebar-hover); color: white; }
.nav-link.active { background: rgba(37,211,102,0.15); color: var(--wa-green); font-weight: 600; }
.nav-link .badge-pill { margin-left: auto; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px;
  background: var(--wa-green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.85rem;
  flex-shrink: 0;
}
.user-name { color: white; font-size: 0.82rem; font-weight: 600; }
.user-role { color: rgba(255,255,255,0.5); font-size: 0.72rem; }

/* ── Main Content ─────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin 0.3s ease;
}

.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.topbar-title { font-weight: 600; font-size: 1rem; }
.topbar-avatar {
  width: 34px; height: 34px;
  background: var(--wa-green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.85rem;
}
.badge-notification {
  position: absolute; top: 2px; right: 2px;
  font-size: 0.6rem; padding: 2px 4px;
  min-width: 16px; border-radius: 10px;
}
.notification-dropdown { width: 320px; max-height: 400px; overflow-y: auto; }
.notification-item { white-space: normal; padding: 10px 16px; }
.notification-item.unread { background: #f0f8ff; border-left: 3px solid var(--primary); }

.page-content { padding: 24px; }
.alert-flash { margin-bottom: 0; }

/* ── Cards ────────────────────────────────────── */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.card-header { background: white; border-bottom: 1px solid #f0f0f0; font-weight: 600; }

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.stat-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.8rem; color: #6c757d; margin-top: 2px; }
.stat-trend { font-size: 0.75rem; margin-top: 4px; }

/* ── Inbox ────────────────────────────────────── */
.inbox-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - var(--topbar-h));
  margin: -24px;
  gap: 0;
}
.inbox-sidebar {
  border-right: 1px solid #e9ecef;
  background: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.inbox-search { padding: 12px; border-bottom: 1px solid #f0f0f0; }
.inbox-filters { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid #f0f0f0; overflow-x: auto; }
.inbox-filters .btn { white-space: nowrap; font-size: 0.78rem; }
.conversation-list { flex: 1; overflow-y: auto; }
.conversation-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f5f5f5;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.conversation-item:hover { background: #f8f9fa; }
.conversation-item.active { background: #e8f5e9; border-left: 3px solid var(--wa-green); }
.conversation-item.unread .conv-preview { font-weight: 600; color: #212529; }
.conv-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, #25d366, #075e54);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 1rem;
  flex-shrink: 0;
}
.conv-info { flex: 1; min-width: 0; }
.conv-name { font-weight: 600; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview { font-size: 0.78rem; color: #6c757d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-meta { flex-shrink: 0; text-align: right; }
.conv-time { font-size: 0.7rem; color: #adb5bd; }
.conv-badge { margin-top: 4px; }

.chat-area { display: flex; flex-direction: column; background: #e5ddd5; }
.chat-header {
  background: var(--wa-dark);
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.message-bubble {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  position: relative;
}
.message-in {
  background: white;
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.message-out {
  background: #d9fdd3;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.message-time { font-size: 0.65rem; color: #999; margin-top: 3px; text-align: right; }
.message-status i { font-size: 0.7rem; color: #53bdeb; }
.message-system {
  align-self: center;
  background: rgba(0,0,0,0.08);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.75rem;
  color: #555;
}
.chat-input-area {
  background: #f0f0f0;
  padding: 12px;
  flex-shrink: 0;
  border-top: 1px solid #ddd;
}
.chat-input-bar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: white;
  border-radius: 25px;
  padding: 6px 8px 6px 16px;
}
.chat-input-bar textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  max-height: 120px;
  font-size: 0.875rem;
  background: transparent;
}
.chat-send-btn {
  width: 40px; height: 40px;
  background: var(--wa-green);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

/* ── Kanban Board ─────────────────────────────── */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; }
.kanban-column {
  flex-shrink: 0;
  width: 280px;
  background: #f8f9fa;
  border-radius: var(--radius);
  padding: 12px;
}
.kanban-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 0.875rem;
}
.kanban-card {
  background: white;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  cursor: grab;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.12); }
.kanban-card.dragging { opacity: 0.5; transform: scale(1.02); }

/* ── Tables ───────────────────────────────────── */
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; color: #6c757d; font-weight: 600; }
.table td { vertical-align: middle; font-size: 0.875rem; }

/* ── Compliance Score ─────────────────────────── */
.compliance-score-circle {
  width: 120px; height: 120px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 8px solid;
}
.score-excellent { border-color: #198754; color: #198754; }
.score-good { border-color: #0dcaf0; color: #0dcaf0; }
.score-fair { border-color: #ffc107; color: #ffc107; }
.score-poor { border-color: #dc3545; color: #dc3545; }

/* ── Template Preview ─────────────────────────── */
.template-preview {
  background: #e5ddd5;
  border-radius: 12px;
  padding: 16px;
  min-height: 100px;
}
.template-bubble {
  background: white;
  border-radius: 12px;
  padding: 12px;
  max-width: 85%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.template-header-img { width: 100%; border-radius: 8px; margin-bottom: 8px; }
.template-body { font-size: 0.9rem; white-space: pre-wrap; }
.template-footer { font-size: 0.75rem; color: #999; margin-top: 6px; }
.template-btn {
  display: block;
  border: 1px solid #25d366;
  color: #25d366;
  border-radius: 6px;
  padding: 6px;
  text-align: center;
  margin-top: 6px;
  font-size: 0.8rem;
}

/* ── Auth Pages ───────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #0a1628 0%, #075e54 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.auth-logo {
  width: 60px; height: 60px;
  background: var(--wa-green);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: white;
  margin: 0 auto 20px;
}

/* ── Utilities ────────────────────────────────── */
.wa-green { color: var(--wa-green) !important; }
.bg-wa-green { background: var(--wa-green) !important; }
.text-small { font-size: 0.8rem; }
.fw-600 { font-weight: 600; }
.rounded-pill-sm { border-radius: 20px; }
.sidebar-toggle { color: #6c757d; padding: 0; }
.cursor-pointer { cursor: pointer; }

/* ── Responsive ───────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .inbox-layout { grid-template-columns: 1fr; }
  .kanban-board { flex-direction: column; }
  .kanban-column { width: 100%; }
  .page-content { padding: 16px; }
}

/* ── Campaign Stats ───────────────────────────── */
.campaign-funnel {
  display: flex;
  gap: 0;
}
.funnel-step {
  flex: 1;
  text-align: center;
  padding: 16px 8px;
  position: relative;
}
.funnel-step::after {
  content: '→';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  color: #adb5bd;
  font-size: 1.2rem;
}
.funnel-step:last-child::after { display: none; }
.funnel-value { font-size: 1.5rem; font-weight: 700; }
.funnel-label { font-size: 0.75rem; color: #6c757d; }

/* ── Scraper ──────────────────────────────────── */
.scraper-result-row { cursor: pointer; }
.scraper-result-row:hover { background: #f8f9fa; }
.scraper-result-row.selected { background: #e8f5e9; }

/* ── Scrollbar ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ── Quick Reply ──────────────────────────────── */
.quick-reply-list {
  position: absolute;
  bottom: 100%;
  left: 0; right: 0;
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 10px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100;
}
.quick-reply-item { padding: 10px 16px; cursor: pointer; font-size: 0.875rem; }
.quick-reply-item:hover { background: #f8f9fa; }
.quick-reply-shortcut { color: var(--wa-green); font-weight: 600; }
