/* ============================================
   LeadFlow CRM — Bootstrap Icons Edition
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #6366f1;
  --primary-dk: #4f46e5;
  --primary-lt: #eef2ff;
  --success:    #10b981;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-400:   #9ca3af;
  --gray-600:   #4b5563;
  --gray-800:   #1f2937;
  --sidebar-w:  240px;
  --radius:     10px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,.1);
}

body { font-family: 'Inter', sans-serif; font-size: 14px; color: var(--gray-800); background: var(--gray-50); }

/* ---- LAYOUT ---- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100;
}
.sidebar-logo {
  padding: 18px 20px 14px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--gray-100);
}
.logo-icon { font-size: 22px; color: var(--primary); }
.logo-text  { font-size: 18px; font-weight: 700; color: var(--primary); letter-spacing: -.5px; }

.sidebar-nav { flex: 1; padding: 10px 10px; overflow-y: auto; }
.nav-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--gray-400); padding: 10px 12px 4px; margin-top: 2px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  text-decoration: none; color: var(--gray-600); font-weight: 500; font-size: 13.5px;
  margin-bottom: 2px; transition: all .15s;
}
.nav-item i { font-size: 16px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-item:hover  { background: var(--gray-100); color: var(--gray-800); }
.nav-item.active { background: var(--primary-lt); color: var(--primary); font-weight: 600; }

.sidebar-footer {
  padding: 14px; border-top: 1px solid var(--gray-100);
  display: flex; align-items: center; gap: 10px;
}
.user-info { flex: 1; min-width: 0; }
.user-name  { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 11px; color: var(--gray-400); text-transform: capitalize; }
.logout-btn { font-size: 18px; text-decoration: none; color: var(--gray-400); transition: color .15s; line-height: 1; }
.logout-btn:hover { color: var(--danger); }

.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--gray-200); padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.tz-badge {
  font-size: 12px; background: var(--primary-lt); color: var(--primary);
  padding: 4px 10px; border-radius: 20px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.tz-badge i { font-size: 13px; }
.date-now { font-size: 12px; color: var(--gray-400); white-space: nowrap; }
.content-area { padding: 24px 28px; flex: 1; }

/* ---- CARDS ---- */
.card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.card-title i { font-size: 16px; color: var(--primary); }
.card-body { padding: 20px; }

/* ---- STAT CARDS ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card  { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-icon  { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.stat-icon i { font-size: 18px; }
.stat-icon.purple { background: var(--primary-lt); color: var(--primary); }
.stat-icon.green  { background: #d1fae5; color: var(--success); }
.stat-icon.amber  { background: #fffbeb; color: var(--warning); }
.stat-icon.blue   { background: #eff6ff; color: #3b82f6; }
.stat-icon.red    { background: #fef2f2; color: var(--danger); }
.stat-label { font-size: 11px; color: var(--gray-400); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-sub   { font-size: 12px; color: var(--gray-400); margin-top: 4px; display: flex; align-items: center; gap: 4px; }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 11px; font-weight: 600; color: var(--gray-400); text-transform: uppercase;
  letter-spacing: .5px; padding: 10px 14px; background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200); text-align: left; white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ---- BADGES ---- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge i { font-size: 11px; }

.src-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.src-badge i { font-size: 12px; }
.src-badge.meta    { background: #dbeafe; color: #1d4ed8; }
.src-badge.network { background: #d1fae5; color: #065f46; }
.src-badge.google  { background: #fee2e2; color: #b91c1c; }
.src-badge.native  { background: #f3e8ff; color: #7c3aed; }
.src-badge.taboola { background: #ffedd5; color: #c2410c; }
.src-badge.manual  { background: var(--gray-100); color: var(--gray-600); }
.src-badge.other   { background: #fef3c7; color: #92400e; }

.priority-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.priority-badge i { font-size: 12px; }
.priority-badge.high   { color: var(--danger); }
.priority-badge.medium { color: var(--warning); }
.priority-badge.low    { color: var(--success); }

/* ---- LIVE PULSE ---- */
.lead-new-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--success); font-weight: 700; letter-spacing: .3px; margin-bottom: 3px;
}
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--success);
  animation: pulse 1.5s infinite; flex-shrink: 0;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,.5); }
  50%      { box-shadow: 0 0 0 5px rgba(16,185,129,0); }
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none; transition: all .15s; white-space: nowrap;
  font-family: inherit; line-height: 1.2;
}
.btn i { font-size: 14px; flex-shrink: 0; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dk); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { background: #059669; color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover   { background: #dc2626;  color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-outline  { background: #fff; border: 1px solid var(--gray-200); color: var(--gray-600); }
.btn-outline:hover  { background: var(--gray-50); color: var(--gray-800); }
.btn-sm  { padding: 5px 12px; font-size: 12px; }
.btn-xs  { padding: 3px 9px;  font-size: 11.5px; border-radius: 6px; }

/* ---- FORMS ---- */
.form-group   { margin-bottom: 16px; }
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--gray-600); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], input[type=datetime-local],
input[type=file], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--gray-200); border-radius: 8px;
  font-size: 13.5px; color: var(--gray-800); background: #fff; outline: none;
  transition: border-color .15s; font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11.5px; color: var(--gray-400); margin-top: 4px; }

/* Input with icon INSIDE — icon is decorative label above, not overlapping */
.input-with-icon { position: relative; }
.input-with-icon > i {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--gray-400); font-size: 14px; pointer-events: none; z-index: 1;
}
.input-with-icon > input,
.input-with-icon > select {
  padding-left: 34px;
}

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px;
  font-weight: 500; display: flex; align-items: center; gap: 8px;
}
.alert i { font-size: 16px; flex-shrink: 0; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: var(--primary-lt); color: var(--primary-dk); border: 1px solid #c7d2fe; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ---- AVATAR ---- */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.avatar-lg { width: 46px; height: 46px; font-size: 16px; border-radius: 12px; }

/* ---- LEAD CARD ---- */
.lead-card {
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 12px; box-shadow: var(--shadow); transition: box-shadow .15s;
}
.lead-card:hover  { box-shadow: var(--shadow-md); }
.lead-card.is-new { border-left: 4px solid var(--primary); }
.lead-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.lead-name { font-size: 16px; font-weight: 700; }

/* ---- ADDITIONAL MESSAGE BOX ---- */
.msg-box {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
  padding: 12px 14px; margin-top: 8px; font-size: 13px; line-height: 1.5; color: #92400e;
}
.msg-box-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: #b45309; margin-bottom: 4px; display: flex; align-items: center; gap: 5px;
}

/* ---- CALENDAR ---- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--gray-200); border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.cal-header-row { background: var(--primary); border-radius: var(--radius) var(--radius) 0 0; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; }
.cal-day-header { background: var(--gray-100); text-align: center; padding: 8px; font-size: 11px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; }
.cal-cell { background: #fff; min-height: 90px; padding: 6px 8px; }
.cal-cell.other-month { background: var(--gray-50); }
.cal-cell.today { background: var(--primary-lt); }
.cal-date-num { font-size: 12px; font-weight: 600; color: var(--gray-600); margin-bottom: 4px; }
.cal-cell.today .cal-date-num { color: var(--primary); font-weight: 800; }
.cal-event {
  font-size: 10.5px; background: var(--primary); color: #fff; border-radius: 4px;
  padding: 2px 6px; margin-bottom: 2px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; cursor: pointer; display: flex; align-items: center; gap: 3px;
}
.cal-event i { font-size: 10px; flex-shrink: 0; }
.cal-event.status-completed { background: var(--success); }
.cal-event.status-cancelled { background: var(--gray-400); }
.cal-event.status-no_show   { background: var(--danger); }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 999;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2); max-height: 90vh; overflow-y: auto;
}
.modal-header {
  padding: 18px 22px; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-title i { color: var(--primary); font-size: 18px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-400); line-height: 1; padding: 0; }
.modal-close:hover { color: var(--danger); }
.modal-body   { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--gray-200); display: flex; gap: 8px; justify-content: flex-end; }

/* ---- TABS ---- */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; overflow-x: auto; }
.tab-btn {
  padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--gray-400);
  background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .15s; display: flex; align-items: center; gap: 6px;
  font-family: inherit; white-space: nowrap; flex-shrink: 0;
}
.tab-btn i { font-size: 14px; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---- FILTER BAR ---- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.filter-bar select, .filter-bar input { width: auto; min-width: 140px; }

/* ---- COMMENTS ---- */
.comment-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.comment-item:last-child { border-bottom: none; }
.comment-body   { flex: 1; }
.comment-header { font-size: 12px; color: var(--gray-400); margin-bottom: 4px; }
.comment-text   { font-size: 13.5px; line-height: 1.5; }

/* ---- HISTORY ---- */
.history-item { display: flex; gap: 10px; padding: 8px 0; font-size: 12.5px; color: var(--gray-600); border-bottom: 1px solid var(--gray-100); align-items: flex-start; }
.history-item:last-child { border-bottom: none; }
.history-icon { color: var(--primary); font-size: 15px; margin-top: 1px; flex-shrink: 0; }

/* ---- PROGRESS ---- */
.progress { background: var(--gray-200); border-radius: 20px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; background: var(--primary); transition: width .3s; }

/* ---- DETAIL ROW ---- */
.detail-row { display: flex; padding: 9px 0; border-bottom: 1px solid var(--gray-100); align-items: center; gap: 0; }
.detail-row:last-child { border-bottom: none; }
.detail-label { width: 125px; flex-shrink: 0; font-size: 12px; font-weight: 600; color: var(--gray-400); white-space: nowrap; display: flex; align-items: center; gap: 6px; overflow: hidden; }
.detail-label i { font-size: 13px; flex-shrink: 0; }
.detail-value { font-size: 13.5px; flex: 1; color: var(--gray-800); }

/* ---- IMPORT/EXPORT ---- */
.upload-zone {
  border: 2px dashed var(--gray-200); border-radius: var(--radius); padding: 32px;
  text-align: center; cursor: pointer; transition: all .15s;
}
.upload-zone:hover  { border-color: var(--primary); background: var(--primary-lt); }
.upload-zone > i    { font-size: 36px; color: var(--gray-400); margin-bottom: 10px; display: block; }
.upload-zone:hover > i { color: var(--primary); }

/* ---- AGENT STAT CARDS ---- */
.agent-stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 16px; margin-bottom: 4px; }
.agent-stat-card {
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; min-width: 0;
}
.agent-stat-info { flex: 1; min-width: 0; }
.agent-stat-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-stat-status { font-size: 11px; color: var(--gray-400); margin: 3px 0 10px; display: flex; align-items: center; gap: 4px; }
.agent-stat-nums { display: flex; gap: 16px; flex-wrap: nowrap; align-items: center; }
.agent-stat-num  { display: flex; flex-direction: column; align-items: center; min-width: 36px; }
.agent-stat-num span.val { display: block; font-size: 18px; font-weight: 800; color: var(--gray-800); line-height: 1.1; white-space: nowrap; }
.agent-stat-num span.lbl { display: block; font-size: 9px; color: var(--gray-400); font-weight: 700; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; margin-top: 2px; text-align: center; }

/* ---- LOGIN ---- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px;
  width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo > i    { font-size: 40px; color: var(--primary); display: block; margin-bottom: 8px; }
.login-logo .logo-text { font-size: 22px; font-weight: 800; color: var(--primary); display: block; }
.login-logo p { color: var(--gray-400); font-size: 13px; margin-top: 4px; }

/* ---- MISC ---- */
.divider    { border: none; border-top: 1px solid var(--gray-200); margin: 16px 0; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-state > i { font-size: 38px; display: block; color: var(--gray-200); margin-bottom: 10px; }
.empty-state p   { font-size: 14px; }
.text-sm    { font-size: 12px; }
.text-gray  { color: var(--gray-400); }
.text-right { text-align: right; }
.font-bold  { font-weight: 700; }
.mt-4   { margin-top: 4px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mb-16  { margin-bottom: 16px; }
.flex   { display: flex; }
.flex-1 { flex: 1; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.role-manager { background: #f3e8ff; color: #8b5cf6; }

/* ---- BULK ACTION BAR ---- */
#bulk-bar {
  background: #fff; border: 1.5px solid var(--primary); border-radius: 10px;
  padding: 10px 16px; margin-bottom: 14px; align-items: center; gap: 12px; flex-wrap: wrap;
  animation: slideDown .2s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
#bulk-bar select { min-width: 180px; width: auto; font-size: 13px; }

/* Row highlight when selected */
tr.selected-row td { background: #eef2ff !important; }
