/* ===== CRM System — Hebrew RTL ===== */
:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #eef2ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --sidebar-bg: #1e1b4b;
  --sidebar-text: #c7d2fe;
  --sidebar-active: #4f46e5;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-width: 240px;
  --topbar-h: 60px;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 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);
  --transition: 0.2s ease;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', Arial, sans-serif; background: var(--gray-50); color: var(--gray-800); direction: rtl; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: 0; right: 0; width: var(--sidebar-width);
  height: 100vh; background: var(--sidebar-bg);
  display: flex; flex-direction: column; z-index: 1000;
  transition: transform var(--transition);
}
.sidebar.collapsed { transform: translateX(100%); }
.sidebar-brand {
  padding: 20px 20px 16px; font-size: 18px; font-weight: 700;
  color: white; border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center;
}
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; color: var(--sidebar-text);
  text-decoration: none; font-size: 14.5px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
}
.sidebar-nav .nav-link i { width: 20px; text-align: center; font-size: 16px; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: white; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: white; }
.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--sidebar-active); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.user-name { color: white; font-size: 13px; font-weight: 600; }
.user-role { color: var(--sidebar-text); font-size: 11px; }
.btn-logout {
  margin-right: auto; color: var(--sidebar-text); font-size: 18px;
  background: none; border: none; cursor: pointer; padding: 4px;
  transition: color var(--transition);
}
.btn-logout:hover { color: #f87171; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-right: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-right var(--transition);
}
.main-content.full-width { margin-right: 0; }

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h); background: white; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.btn-sidebar-toggle {
  background: none; border: none; cursor: pointer; font-size: 20px;
  color: var(--gray-600); padding: 4px 8px; border-radius: 6px;
  transition: background var(--transition);
}
.btn-sidebar-toggle:hover { background: var(--gray-100); }
.topbar-title { font-size: 17px; font-weight: 700; color: var(--gray-800); flex: 1; }
.topbar-actions { display: flex; gap: 8px; }
.content-area { padding: 24px; }
.alerts-container { margin-bottom: 16px; }

/* ===== CARDS ===== */
.card {
  background: white; border-radius: var(--radius); border: 1px solid var(--gray-200);
  box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
  font-weight: 700; font-size: 15px; display: flex; align-items: center;
  gap: 8px; background: var(--gray-50); border-radius: var(--radius) var(--radius) 0 0;
}
.card-body { padding: 20px; }

/* ===== KPI CARDS ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: white; border-radius: var(--radius); padding: 18px 20px;
  border: 1px solid var(--gray-200); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.kpi-card .kpi-label { font-size: 12px; color: var(--gray-600); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.kpi-card .kpi-value { font-size: 28px; font-weight: 800; color: var(--gray-800); line-height: 1.1; }
.kpi-card .kpi-sub { font-size: 12px; color: var(--gray-400); }
.kpi-card.primary { border-top: 3px solid var(--primary); }
.kpi-card.success { border-top: 3px solid var(--success); }
.kpi-card.warning { border-top: 3px solid var(--warning); }
.kpi-card.danger { border-top: 3px solid var(--danger); }

/* ===== LEADS TABLE ===== */
.table-responsive { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.leads-table { margin: 0; }
.leads-table thead th {
  background: var(--gray-50); border-bottom: 2px solid var(--gray-200);
  font-weight: 700; font-size: 13px; color: var(--gray-600);
  padding: 12px 14px; white-space: nowrap; text-align: right;
}
.leads-table tbody td { padding: 12px 14px; vertical-align: middle; font-size: 14px; border-color: var(--gray-100); }
.leads-table tbody tr { transition: background var(--transition); cursor: pointer; }
.leads-table tbody tr:hover { background: var(--primary-light); }

/* Full row coloring - distinct colors per status group */
.leads-table tbody tr.row-new td             { background: #ffffff !important; }
.leads-table tbody tr.row-no_answer td       { background: #fef08a !important; } /* צהוב */
.leads-table tbody tr.row-followup td        { background: #bfdbfe !important; } /* כחול */
.leads-table tbody tr.row-in_progress td     { background: #fed7aa !important; } /* כתום */
.leads-table tbody tr.row-waiting_payment td { background: #d9f99d !important; } /* ירוק-ליים */
.leads-table tbody tr.row-not_relevant td    { background: #e2e8f0 !important; color: #94a3b8 !important; } /* אפור */
.leads-table tbody tr.row-invalid td         { background: #ffe4e6 !important; color: #9f1239 !important; } /* ורוד-אדום */
.leads-table tbody tr.row-closed td          { background: #86efac !important; } /* ירוק */
.leads-table tbody tr.row-overdue td         { background: #fca5a5 !important; font-weight:700 !important; } /* אדום */
.leads-table tbody tr.row-today td           { background: #fde68a !important; font-weight:700 !important; } /* צהוב כהה */

.leads-table tbody tr[class*="row-"]:hover td { opacity: 0.88; }

/* Quick Status Filter Bar */
.status-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.status-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 2px solid transparent;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.status-filter-btn:hover {
  border-color: #6b7280;
  color: #111827;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.status-filter-btn.active {
  border-color: #1e1b4b;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  transform: translateY(-1px);
}
.filter-count {
  background: rgba(0,0,0,.15);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}

/* Color Legend */
.color-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  font-size: 12px;
  font-weight: 600;
}
.legend-item {
  padding: 4px 12px;
  border-radius: 20px;
  color: #374151;
  white-space: nowrap;
}

/* ===== STATUS BADGES ===== */
.badge { font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
.status-new { background: #dbeafe; color: #1d4ed8; }
.status-no_answer_1, .status-no_answer_2, .status-no_answer_3 { background: #fef3c7; color: #92400e; }
.status-followup, .status-thinking, .status-waiting_answer { background: #ede9fe; color: #5b21b6; }
.status-full_call_not_closed { background: #ffedd5; color: #9a3412; }
.status-waiting_payment { background: #fce7f3; color: #9d174d; }
.status-not_relevant, .status-denied_contact { background: #f3f4f6; color: #4b5563; }
.status-invalid_lead { background: #ffe4e6; color: #9f1239; }
.status-external_seller { background: #ede9fe; color: #5b21b6; }
.status-closed_workshop, .status-closed_course { background: #dcfce7; color: #14532d; }
.status-emphasized { background: #fef9c3; color: #854d0e; border: 1px solid #f59e0b; }

/* ===== FILTERS BAR ===== */
.filters-bar {
  background: white; border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.filters-bar .row { gap: 0; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.filter-group .form-control, .filter-group .form-select {
  font-size: 13px; border-radius: 6px; padding: 6px 10px; height: 34px;
}

/* ===== FORMS ===== */
.form-label { font-weight: 600; font-size: 13px; color: var(--gray-700, #374151); margin-bottom: 5px; }
.form-control, .form-select {
  border-radius: 8px; border: 1.5px solid var(--gray-200);
  font-size: 14px; padding: 9px 12px; transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); outline: none;
}
.form-section { background: var(--gray-50); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.form-section-title { font-weight: 700; font-size: 14px; color: var(--primary); margin-bottom: 12px; }

/* ===== BUTTONS ===== */
.btn { border-radius: 8px; font-weight: 600; font-size: 14px; padding: 8px 18px; transition: all var(--transition); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm { font-size: 12px; padding: 5px 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; }

/* Quick action buttons */
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-actions .btn { display: flex; align-items: center; gap: 6px; }

/* ===== LEAD DETAIL ===== */
.lead-header {
  background: white; border-radius: var(--radius); border: 1px solid var(--gray-200);
  padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.lead-name { font-size: 24px; font-weight: 800; color: var(--gray-800); margin-bottom: 4px; }
.lead-meta { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; }
.lead-meta-item { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--gray-600); }
.lead-meta-item a { color: inherit; text-decoration: none; }
.lead-meta-item a:hover { color: var(--primary); }

/* ===== TIMELINE ===== */
.timeline { padding: 0; list-style: none; }
.timeline-item {
  display: flex; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-icon {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; color: var(--primary);
}
.timeline-body { flex: 1; }
.timeline-desc { font-size: 13.5px; color: var(--gray-800); margin-bottom: 2px; }
.timeline-meta { font-size: 11.5px; color: var(--gray-400); }

/* ===== CALL CARD ===== */
.call-card {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: 8px; padding: 14px 16px; margin-bottom: 10px;
}
.call-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.call-card-date { font-size: 12px; color: var(--gray-400); }
.call-field { margin-bottom: 8px; }
.call-field label { font-size: 11px; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: .4px; display: block; margin-bottom: 2px; }
.call-field p { font-size: 13.5px; color: var(--gray-800); margin: 0; }
.interest-dots { display: flex; gap: 3px; }
.interest-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--gray-200); }
.interest-dot.filled { background: var(--primary); }

/* ===== FOLLOWUPS ===== */
.followup-section { margin-bottom: 28px; }
.followup-section-title {
  font-size: 15px; font-weight: 700; padding: 10px 16px;
  border-radius: 8px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.followup-section-title.overdue { background: var(--danger-light); color: var(--danger); }
.followup-section-title.today { background: var(--warning-light); color: var(--warning); }
.followup-section-title.tomorrow { background: var(--primary-light); color: var(--primary); }
.followup-section-title.inactive { background: var(--gray-100); color: var(--gray-600); }
.followup-row {
  background: white; border: 1px solid var(--gray-200); border-radius: 8px;
  padding: 14px 16px; margin-bottom: 8px; display: flex;
  align-items: center; gap: 12px; box-shadow: var(--shadow);
}
.followup-row:hover { border-color: var(--primary); }
.followup-info { flex: 1; }
.followup-name { font-weight: 700; font-size: 14px; }
.followup-sub { font-size: 12px; color: var(--gray-600); margin-top: 2px; }
.followup-actions { display: flex; gap: 6px; }

/* ===== STATS SECTION ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.stat-box {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: 8px; padding: 12px 14px; text-align: center;
}
.stat-box .stat-val { font-size: 22px; font-weight: 800; color: var(--primary); }
.stat-box .stat-lbl { font-size: 11px; color: var(--gray-600); font-weight: 500; margin-top: 2px; }

/* ===== AUTH ===== */
.auth-page {
  min-height: 100vh; background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  display: flex; align-items: center; justify-content: center;
}
.auth-box {
  background: white; border-radius: 16px; padding: 40px 36px;
  width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .icon { font-size: 40px; color: var(--primary); }
.auth-logo h1 { font-size: 22px; font-weight: 800; color: var(--gray-800); margin: 8px 0 4px; }
.auth-logo p { font-size: 14px; color: var(--gray-400); }

/* ===== PAGINATION ===== */
.pagination { justify-content: center; gap: 4px; }
.page-link { border-radius: 6px !important; color: var(--primary); border-color: var(--gray-200); font-size: 13px; }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ===== MODAL ===== */
.modal-header { border-bottom: 1px solid var(--gray-200); }
.modal-footer { border-top: 1px solid var(--gray-200); }
.modal-title { font-weight: 700; }

/* ===== REPORT TABLES ===== */
.report-table th { background: var(--primary-light); color: var(--primary); font-weight: 700; font-size: 13px; }
.progress { height: 6px; border-radius: 10px; }
.progress-bar { background: var(--primary); border-radius: 10px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-right: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .content-area { padding: 16px; }
  .leads-table thead th:nth-child(n+5) { display: none; }
  .leads-table tbody td:nth-child(n+5) { display: none; }
  .lead-meta { flex-direction: column; gap: 8px; }
  .quick-actions { flex-direction: column; }
  .quick-actions .btn { justify-content: center; }
}

/* ===== UTILITIES ===== */
.text-primary-custom { color: var(--primary); }
.bg-primary-light { background: var(--primary-light); }
.fw-700 { font-weight: 700; }
.gap-8 { gap: 8px; }
.rounded-pill-custom { border-radius: 20px; }
.cursor-pointer { cursor: pointer; }
.no-data { text-align: center; padding: 40px; color: var(--gray-400); }
.no-data i { font-size: 40px; margin-bottom: 12px; display: block; }
.divider { border: 0; border-top: 1px solid var(--gray-200); margin: 16px 0; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 999; display: none; }
.overlay.show { display: block; }
