/* ============================================
   CRM Pro — assets/css/app.css
   Design: Industrial Minimal + High Contrast
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ---- CSS Variables ---- */
:root {
  --bg: #ffffff;
  --bg2: #f3f3f3;
  --bg3: #ffffff;
  --bg4: #FFF1F5;
  --border: #999999;
  --border2: #999999;
  --text: #535353;
  --text2: #535353;
  --text3: #525c6e;
  --accent: #BF2446;
  --accent2:   #7c89ff;
  --green:     #10b981;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --purple:    #8b5cf6;
  --pink:      #ec4899;
  --blue:      #3b82f6;


  /* Status colors */
  --c-new:         #cccccc;
  --c-contacted:   #3b82f6;
  --c-qualified:   #f59e0b;
  --c-proposal:    #8b5cf6;
  --c-negotiation: #ec4899;
  --c-won:         #10b981;
  --c-lost:        #ef4444;

  --sidebar-w: 240px;
  --topbar-h:  60px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
  --transition: all .2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--text); }

h1,h2,h3,h4,h5 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  line-height: 1.2;
}

input, select, textarea, button { font-family: inherit; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

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

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}
.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 24px;
}
.nav-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text3);
  font-weight: 600;
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  position: relative;
}
.nav-item:hover {
  background: var(--bg3);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent);
  color: #fff;
}
.nav-item .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .8;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.3); }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: var(--transition);
}
.user-card:hover { background: var(--bg3); }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 10px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.user-info .user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.user-info .user-role {
  font-size: 11px;
  color: var(--text3);
  text-transform: capitalize;
}

/* ---- MAIN ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- TOPBAR ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---- PAGE CONTENT ---- */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ============================================
   COMPONENTS
   ============================================ */

/* ---- Cards ---- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.card-body { padding: 20px; }

/* ---- Stat Cards ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-color, var(--accent));
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text3);
  font-weight: 600;
  margin-bottom: 8px;
}
.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-sub {
  font-size: 12px;
  color: var(--text3);
}
.stat-icon {
  position: absolute;
  right: 16px;
  top: 16px;
  font-size: 28px;
  opacity: .15;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); color: #fff; }
.btn-secondary { background: var(--bg4); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--border2); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-warning { background: var(--yellow); color: #000; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 7px; width: 34px; height: 34px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text2);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  transition: var(--transition);
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(93,107,255,.15);
}
.form-control::placeholder { color: var(--text3); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.crm-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text3);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.crm-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  vertical-align: middle;
}
.crm-table tr:last-child td { border-bottom: none; }
.crm-table tr:hover td { background: var(--bg3); color: var(--text); }
.crm-table .lead-name { font-weight: 600; color: var(--text); }

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

/* ---- Modal ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
}
.modal-lg { max-width: 800px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
}
.modal-close {
  width: 30px; height: 30px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text2);
  font-size: 18px;
  transition: var(--transition);
}
.modal-close:hover { background: var(--red); color: #fff; border-color: var(--red); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ---- Pipeline Kanban ---- */
.pipeline-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  min-height: 500px;
}
.pipeline-col {
  flex: 0 0 260px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
}
.pipeline-col-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.pipeline-col-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pipeline-col-title {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  flex: 1;
}
.pipeline-col-count {
  background: var(--bg3);
  color: var(--text3);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}
.pipeline-col-body {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
.pipeline-card {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid var(--card-color, var(--accent));
}
.pipeline-card:hover {
  border-color: var(--card-color, var(--accent));
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.pipeline-card-name {
  font-weight: 600;
  color: var(--text);
  font-size: 13.5px;
  margin-bottom: 4px;
}
.pipeline-card-meta {
  font-size: 11.5px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.pipeline-card-value {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
}
.pipeline-col-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text3);
}

/* ---- Alerts ---- */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); color: #34d399; }
.alert-error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: #f87171; }
.alert-warning { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); color: #fbbf24; }
.alert-info    { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3); color: #60a5fa; }

/* ---- Filters Bar ---- */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.search-input {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-input input {
  padding-left: 36px;
  height: 38px;
}
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  pointer-events: none;
}
.filter-select {
  height: 38px;
  min-width: 130px;
  flex-shrink: 0;
}

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 0 4px;
}
.page-link {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
}
.page-link:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-info { font-size: 12px; color: var(--text3); padding: 0 8px; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text2); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ---- Timeline ---- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  position: relative;
}
.timeline-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 15px;
  top: 40px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg3);
  border: 2px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  z-index: 1;
}
.timeline-content { flex: 1; padding-top: 4px; }
.timeline-text { font-size: 13.5px; color: var(--text2); }
.timeline-meta { font-size: 11.5px; color: var(--text3); margin-top: 2px; }

/* ---- Chart Container ---- */
.chart-container {
  position: relative;
  width: 100%;
}

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 50%, rgba(93,107,255,.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(139,92,246,.06) 0%, transparent 40%);
}
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 48px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 32px 80px rgba(0,0,0,.5);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login-logo .icon {
  width: 48px; height: 48px;
  background: var(--accent);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: #fff;
}
.login-logo h1 { font-size: 24px; }
.login-logo p { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
}
.tab:hover { color: var(--text2); }
.tab.active { color: var(--accent2); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

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

/* ---- Utilities ---- */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.text-sm { font-size: 12px; } .text-xs { font-size: 11px; }
.text-muted { color: var(--text3); }
.text-success { color: var(--green); }
.text-danger { color: var(--red); }
.text-warning { color: var(--yellow); }
.font-bold { font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.w-100 { width: 100%; }
.text-right { text-align: right; }
.d-none { display: none; }
