/* =====================================================
   AmeriTalk CRM — Stylesheet
   ===================================================== */

:root {
  --primary:       #1a56db;
  --primary-dark:  #1e429f;
  --primary-light: #e8f0fe;
  --success:       #0e9f6e;
  --success-light: #def7ec;
  --danger:        #f05252;
  --danger-light:  #fde8e8;
  --warning:       #e3a008;
  --warning-light: #fdf6b2;
  --gray-50:       #f9fafb;
  --gray-100:      #f3f4f6;
  --gray-200:      #e5e7eb;
  --gray-300:      #d1d5db;
  --gray-400:      #9ca3af;
  --gray-500:      #6b7280;
  --gray-600:      #4b5563;
  --gray-700:      #374151;
  --gray-800:      #1f2937;
  --gray-900:      #111827;
  --white:         #ffffff;
  --sidebar-w:     240px;
  --topbar-h:      60px;
  --radius:        8px;
  --shadow:        0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--gray-800); background: var(--gray-50); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; font-size: 14px; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---- LOGIN ---- */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #1e3a8a 0%, #1a56db 100%);
}
.login-card {
  background: var(--white); border-radius: 12px; padding: 48px 40px;
  width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--primary); }
.login-logo p  { color: var(--gray-500); font-size: 13px; margin-top: 4px; }
.login-card h2 { font-size: 20px; font-weight: 600; margin-bottom: 24px; color: var(--gray-800); }
.login-error { background: var(--danger-light); color: var(--danger); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; display: none; }

/* ---- APP SHELL ---- */
#app { display: none; height: 100vh; }

/* Sidebar */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--gray-900);
  display: flex; flex-direction: column; z-index: 100; overflow-y: auto;
}
.sidebar-brand {
  padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand h1 { font-size: 16px; font-weight: 700; color: var(--white); }
.sidebar-brand p  { font-size: 11px; color: var(--gray-400); margin-top: 2px; }
.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section-label {
  padding: 8px 20px 4px; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; color: var(--gray-500);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: var(--gray-400); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .15s; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover  { color: var(--white); background: rgba(255,255,255,.06); }
.nav-item.active { color: var(--white); background: var(--primary); }
.nav-item svg    { flex-shrink: 0; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user   { font-size: 12px; color: var(--gray-400); margin-bottom: 8px; }
.sidebar-user span { color: var(--white); font-weight: 500; }

/* Topbar */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h); background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; padding: 0 24px;
  justify-content: space-between; z-index: 90;
}
.topbar-title { font-size: 18px; font-weight: 600; color: var(--gray-800); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* Main content */
.main-content {
  margin-left: var(--sidebar-w); padding-top: var(--topbar-h);
  min-height: 100vh; padding: calc(var(--topbar-h) + 24px) 24px 24px;
}

/* ---- COMMON COMPONENTS ---- */

/* Card */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--gray-200);
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--gray-800); }
.card-body { padding: 20px; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--gray-200); padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 12px; font-weight: 500; color: var(--gray-500); text-transform: uppercase; letter-spacing: .05em; }
.stat-card .stat-value { font-size: 32px; font-weight: 700; color: var(--gray-800); margin: 4px 0; }
.stat-card .stat-sub   { font-size: 12px; color: var(--gray-400); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius); border: none;
  font-weight: 500; font-size: 13px; cursor: pointer; transition: all .15s;
}
.btn-primary  { background: var(--primary); color: var(--white); }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-success  { background: var(--success); color: var(--white); }
.btn-danger   { background: var(--danger); color: var(--white); }
.btn-outline  { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:hover  { background: var(--gray-50); }
.btn-ghost    { background: transparent; color: var(--gray-500); border: none; padding: 6px 10px; }
.btn-ghost:hover    { color: var(--gray-800); background: var(--gray-100); }
.btn-sm       { padding: 5px 10px; font-size: 12px; }
.btn-icon     { padding: 6px; border-radius: 6px; }

/* Table */
.table-wrap   { overflow-x: auto; }
table         { width: 100%; border-collapse: collapse; }
thead tr      { background: var(--gray-50); }
th            { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
td            { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td   { background: var(--gray-50); }
.table-link   { color: var(--primary); font-weight: 500; cursor: pointer; }
.table-link:hover { text-decoration: underline; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 600;
}
.badge-pharmacy { background: #ede9fe; color: #7c3aed; }
.badge-gym      { background: #d1fae5; color: #065f46; }
.badge-clinic   { background: #dbeafe; color: #1e40af; }
.badge-supplier { background: #fef3c7; color: #92400e; }
.badge-prospect { background: var(--gray-100); color: var(--gray-600); }
.badge-active   { background: var(--success-light); color: #065f46; }
.badge-inactive { background: var(--gray-100); color: var(--gray-500); }
.badge-churned  { background: var(--danger-light); color: #9b1c1c; }
.badge-lead       { background: #f3f4f6; color: #374151; }
.badge-contacted  { background: #dbeafe; color: #1e40af; }
.badge-demo       { background: #e0e7ff; color: #4338ca; }
.badge-proposal   { background: #fef3c7; color: #92400e; }
.badge-won        { background: var(--success-light); color: #065f46; }
.badge-lost       { background: var(--danger-light); color: #9b1c1c; }
.badge-high   { background: var(--danger-light); color: #9b1c1c; }
.badge-medium { background: var(--warning-light); color: #723b13; }
.badge-low    { background: var(--gray-100); color: var(--gray-600); }
.badge-open      { background: var(--primary-light); color: var(--primary-dark); }
.badge-completed { background: var(--success-light); color: #065f46; }
.badge-call     { background: #dbeafe; color: #1e40af; }
.badge-email    { background: #d1fae5; color: #065f46; }
.badge-meeting  { background: #ede9fe; color: #6d28d9; }
.badge-note     { background: var(--gray-100); color: var(--gray-600); }
.badge-demo-act { background: #fef3c7; color: #92400e; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-label  { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .03em; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--gray-300);
  border-radius: var(--radius); outline: none; background: var(--white); color: var(--gray-800); transition: border .15s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }
textarea.form-control { resize: vertical; min-height: 80px; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-item  { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray-700); cursor: pointer; }
.checkbox-item input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }

/* Search bar */
.search-bar { position: relative; }
.search-bar input { padding-left: 36px; }
.search-bar svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }

/* Filters row */
.filters-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal {
  background: var(--white); border-radius: 12px;
  width: 100%; max-width: 580px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 10px; }

/* Pipeline Kanban */
.kanban-board   { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 16px; }
.kanban-col     { flex: 0 0 240px; }
.kanban-col-header {
  padding: 10px 14px; border-radius: 8px 8px 0 0; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; display: flex; justify-content: space-between; align-items: center;
}
.kanban-cards   { background: var(--gray-100); border-radius: 0 0 8px 8px; padding: 8px; min-height: 100px; }
.kanban-card    {
  background: var(--white); border-radius: 6px; padding: 12px;
  margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; transition: box-shadow .15s;
  border-left: 3px solid transparent;
}
.kanban-card:hover    { box-shadow: var(--shadow-md); }
.kanban-card h4       { font-size: 13px; font-weight: 600; color: var(--gray-800); margin-bottom: 4px; }
.kanban-card .kc-acct { font-size: 12px; color: var(--gray-500); }
.kanban-card .kc-val  { font-size: 12px; color: var(--success); font-weight: 600; margin-top: 6px; }
.col-lead      .kanban-col-header { background: var(--gray-200); color: var(--gray-700); }
.col-contacted .kanban-col-header { background: #dbeafe; color: #1e40af; }
.col-demo      .kanban-col-header { background: #e0e7ff; color: #4338ca; }
.col-proposal  .kanban-col-header { background: #fef3c7; color: #92400e; }
.col-won       .kanban-col-header { background: var(--success-light); color: #065f46; }
.col-lost      .kanban-col-header { background: var(--danger-light); color: #9b1c1c; }

/* Activity feed */
.activity-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.act-call    { background: #dbeafe; color: #1e40af; }
.act-email   { background: #d1fae5; color: #065f46; }
.act-meeting { background: #ede9fe; color: #6d28d9; }
.act-demo    { background: #fef3c7; color: #92400e; }
.act-note    { background: var(--gray-100); color: var(--gray-600); }
.activity-body   { flex: 1; }
.activity-subject { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.activity-meta    { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.activity-notes   { font-size: 12px; color: var(--gray-600); margin-top: 4px; }

/* Tasks */
.task-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); align-items: flex-start; }
.task-item:last-child { border-bottom: none; }
.task-check input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--primary); }
.task-body   { flex: 1; }
.task-title  { font-size: 13px; font-weight: 500; color: var(--gray-800); }
.task-title.done { text-decoration: line-through; color: var(--gray-400); }
.task-meta   { font-size: 12px; color: var(--gray-400); margin-top: 3px; }
.task-overdue { color: var(--danger); font-weight: 600; }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--gray-400);
}
.empty-state svg { margin-bottom: 12px; }
.empty-state p   { font-size: 14px; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 18px; font-size: 13px; font-weight: 500; color: var(--gray-500);
  background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .15s;
}
.tab-btn:hover  { color: var(--gray-800); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Detail header */
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.detail-title  { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.detail-sub    { font-size: 13px; color: var(--gray-500); margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; }

/* Loading spinner */
.spinner {
  border: 3px solid var(--gray-200); border-top-color: var(--primary);
  border-radius: 50%; width: 32px; height: 32px; animation: spin .7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast notifications */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--gray-800); color: var(--white); padding: 12px 18px;
  border-radius: var(--radius); font-size: 13px; box-shadow: var(--shadow-md);
  animation: slideIn .2s ease; max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Utility */
.flex   { display: flex; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.mt-4   { margin-top: 16px; }
.mb-4   { margin-bottom: 16px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--gray-400); }
.text-right { text-align: right; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Services chips */
.service-chip {
  display: inline-flex; align-items: center; padding: 2px 8px;
  background: var(--primary-light); color: var(--primary-dark);
  border-radius: 999px; font-size: 11px; font-weight: 600; margin: 2px;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .main-content { margin-left: 200px; padding: calc(var(--topbar-h) + 16px) 16px 16px; }
  .topbar { left: 200px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Text/SMS activity type */
.badge-text-sms { background: #ecfdf5; color: #065f46; }
.act-text        { background: #d1fae5; color: #065f46; }
