/* ============================================================
   WhatsApp Business Automation - Main Stylesheet
   ============================================================ */

:root {
  --primary: #25D366;
  --primary-dark: #128C7E;
  --accent: #075E54;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: 220px; height: 100vh;
  background: linear-gradient(180deg, #075E54, #128C7E);
  display: flex; flex-direction: column;
  padding: 0; z-index: 100;
  box-shadow: 4px 0 12px rgba(0,0,0,0.15);
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.sidebar-brand .logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
}
.sidebar-brand .logo-icon {
  width: 38px; height: 38px; background: var(--primary);
  border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 20px;
}
.sidebar-brand .logo-text {
  color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2;
}
.sidebar-brand .logo-sub { font-size: 10px; opacity: 0.7; font-weight: 400; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section-label {
  color: rgba(255,255,255,0.45);
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; padding: 16px 20px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: rgba(255,255,255,0.8);
  text-decoration: none; font-size: 13.5px; font-weight: 500;
  border-left: 3px solid transparent; transition: all 0.2s;
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,0.12);
  color: #fff; border-left-color: var(--primary);
}
.nav-item .icon { width: 18px; text-align: center; font-size: 16px; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 11px; color: rgba(255,255,255,0.5);
}

/* ---- Main Layout ---- */
.main-wrap {
  margin-left: 220px; min-height: 100vh;
  display: flex; flex-direction: column;
}

.topbar {
  background: #fff; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.content { padding: 24px; flex: 1; }

/* ---- Stats Cards ---- */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-card .stat-label { font-size: 12px; color: var(--text-light); font-weight: 500; text-transform: uppercase; }
.stat-card .stat-icon { font-size: 28px; }
.stat-card.primary { background: linear-gradient(135deg, #25D366, #128C7E); color: #fff; }
.stat-card.primary .stat-value, .stat-card.primary .stat-label { color: #fff; }

/* ---- Kanban Board ---- */
.kanban-wrap { overflow-x: auto; padding-bottom: 20px; }
.kanban-board {
  display: flex; gap: 14px; min-width: max-content; align-items: flex-start;
}
.kanban-col {
  width: 230px; background: #f8fafc;
  border-radius: var(--radius); padding: 12px 10px;
  border: 1px solid var(--border); flex-shrink: 0;
}
.kanban-col-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; padding: 0 4px;
}
.kanban-col-title {
  font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px;
}
.kanban-col-count {
  background: var(--border); color: var(--text-light);
  font-size: 11px; font-weight: 700; padding: 2px 7px;
  border-radius: 20px;
}

.lead-card {
  background: var(--card); border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 8px;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border-left: 3px solid transparent;
}
.lead-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.lead-card.score-hot    { border-left-color: #dc3545; }
.lead-card.score-warm   { border-left-color: #fd7e14; }
.lead-card.score-medium { border-left-color: #28a745; }
.lead-card.score-cool   { border-left-color: #17a2b8; }
.lead-card.score-cold   { border-left-color: #adb5bd; }

.lead-card .lead-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.lead-card .lead-phone { font-size: 12px; color: var(--text-light); }
.lead-card .lead-date {
  font-size: 11px; color: var(--text-light);
  margin-top: 6px; display: flex; align-items: center; gap: 4px;
}
.lead-card .lead-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px;
}

/* ---- Tables ---- */
.table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead { background: #f8fafc; }
th { padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 700; color: var(--text-light); text-transform: uppercase; border-bottom: 2px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: #f8fafc; }
tr:last-child td { border-bottom: none; }

/* ---- Badges ---- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; color: #fff;
}

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; color: var(--text);
  transition: border-color 0.2s; background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,211,102,0.15); }
select.form-control { appearance: none; cursor: pointer; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: none; transition: all 0.2s; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #dc3545; color: #fff; }
.btn-danger:hover { background: #c82333; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ---- Cards ---- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 16px; font-weight: 700; }
.card-body { padding: 20px; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card); border-radius: var(--radius);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-header {
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-light); }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Chat History ---- */
.chat-wrap { display: flex; flex-direction: column; gap: 10px; max-height: 400px; overflow-y: auto; padding: 4px; }
.chat-msg { max-width: 75%; display: flex; flex-direction: column; gap: 3px; }
.chat-msg.out { align-self: flex-end; }
.chat-msg.in  { align-self: flex-start; }
.chat-bubble {
  padding: 10px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.chat-msg.out .chat-bubble { background: #dcf8c6; border-bottom-right-radius: 3px; }
.chat-msg.in  .chat-bubble { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.chat-time { font-size: 10px; color: var(--text-light); padding: 0 4px; }
.chat-msg.out .chat-time { text-align: right; }

/* ---- Queue Status ---- */
.queue-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 1px solid var(--border); }
.queue-item:last-child { border-bottom: none; }
.queue-status { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.queue-status.pending  { background: #ffc107; }
.queue-status.sending  { background: #17a2b8; animation: pulse 1s infinite; }
.queue-status.sent     { background: #28a745; }
.queue-status.failed   { background: #dc3545; }
.queue-status.cancelled{ background: #adb5bd; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger  { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ---- Utility ---- */
.text-muted { color: var(--text-light); }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-3 { margin-bottom: 12px; }
.p-3 { padding: 12px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-brand .logo-text, .nav-item span, .nav-section-label { display: none; }
  .main-wrap { margin-left: 60px; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
}
