/* ═══════════════════════════════════════════════════
   LeadDesk CRM — style.css
   Palette:
     --ink       #0F1117   sidebar bg
     --slate     #1C2030   sidebar hover / card bg
     --surface   #F7F8FA   page bg
     --panel     #FFFFFF   card / panel bg
     --accent    #4F6EF7   primary blue
     --accent-lt #EEF1FE   accent tint
     --positive  #22C55E
     --warning   #F59E0B
     --negative  #EF4444
     --text-1    #0F1117   primary text
     --text-2    #6B7280   muted text
     --border    #E5E7EB
   ═══════════════════════════════════════════════════ */

/* ── Reset & base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:        #0F1117;
  --slate:      #1C2030;
  --surface:    #F7F8FA;
  --panel:      #FFFFFF;
  --accent:     #4F6EF7;
  --accent-lt:  #EEF1FE;
  --positive:   #22C55E;
  --warning:    #F59E0B;
  --negative:   #EF4444;
  --neutral:    #6B7280;
  --text-1:     #0F1117;
  --text-2:     #6B7280;
  --border:     #E5E7EB;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08);
  --sidebar-w:  230px;
  --topbar-h:   60px;
  --font-body:  'Inter', system-ui, sans-serif;
  --font-serif: 'DM Serif Display', Georgia, serif;
  --transition: 180ms ease;
}

html { font-size: 15px; }

body {
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text-1);
  display: flex;
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; border: none; background: none; }
img { display: block; max-width: 100%; }


/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--ink);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar__logo {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 17px;
  flex-shrink: 0;
}

.sidebar__name {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: #fff;
  letter-spacing: .01em;
}

.sidebar__nav {
  flex: 1;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__section-label {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 14px 8px 6px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  font-size: .875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.sidebar__link i { font-size: 1.1rem; flex-shrink: 0; }

.sidebar__link:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.sidebar__link.active {
  background: var(--accent);
  color: #fff;
}

.sidebar__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.sidebar__avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar__user-name {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: #fff;
}

.sidebar__user-role {
  display: block;
  font-size: .72rem;
  color: rgba(255,255,255,.4);
}


/* ── Layout shell ─────────────────────────────────── */
.layout {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}


/* ── Topbar ───────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar__toggle {
  color: var(--text-2);
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
}

.topbar__toggle:hover { color: var(--text-1); }

.topbar__breadcrumb {
  flex: 1;
  font-size: .8rem;
  color: var(--text-2);
  font-weight: 500;
  letter-spacing: .01em;
}

.topbar__breadcrumb a { color: var(--accent); }
.topbar__breadcrumb a:hover { text-decoration: underline; }

.topbar__actions { display: flex; align-items: center; gap: 8px; }

.topbar__icon-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 1.15rem;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.topbar__icon-btn:hover {
  background: var(--surface);
  color: var(--text-1);
}

.topbar__badge {
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--negative);
  border: 1.5px solid var(--panel);
}


/* ── Main content area ────────────────────────────── */
.main-content {
  flex: 1;
  padding: 28px 28px 48px;
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header__title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--text-1);
  line-height: 1.2;
}

.page-header__subtitle {
  font-size: .82rem;
  color: var(--text-2);
  margin-top: 3px;
}


/* ── Cards ────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card__title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-1);
}

.card__body { padding: 22px; }
.card__body--flush { padding: 0; }


/* ── Stat chips (for summary counts) ─────────────── */
.stat-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.stat-chip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  flex: 1;
  min-width: 120px;
  box-shadow: var(--shadow-sm);
}

.stat-chip__label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-2);
  margin-bottom: 6px;
}

.stat-chip__value {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--text-1);
  line-height: 1;
}


/* ── Table ────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}

thead tr {
  border-bottom: 1px solid var(--border);
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-2);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--surface); }

tbody td {
  padding: 13px 16px;
  color: var(--text-1);
  vertical-align: middle;
}

.td-name { font-weight: 600; }
.td-muted { color: var(--text-2); font-size: .8rem; }

.table-link {
  color: var(--accent);
  font-weight: 500;
}

.table-link:hover { text-decoration: underline; }


/* ── Badges / flags ───────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge--new          { background: var(--accent-lt);        color: var(--accent); }
.badge--positive     { background: #DCFCE7;                 color: #15803D; }
.badge--neutral      { background: #F3F4F6;                 color: var(--neutral); }
.badge--about_to_enroll { background: #FEF9C3;              color: #A16207; }
.badge--negative     { background: #FEE2E2;                 color: #B91C1C; }
.badge--not_providing{ background: #F3F4F6;                 color: var(--neutral); }
.badge--future       { background: #F0FDF4;                 color: #166534; }
.badge--joined_se    { background: #EDE9FE;                 color: #6D28D9; }


/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .84rem;
  font-weight: 600;
  transition: opacity var(--transition), box-shadow var(--transition);
}

.btn:hover { opacity: .88; }
.btn:active { opacity: .78; }

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(79,110,247,.35);
}

.btn--ghost {
  background: var(--surface);
  color: var(--text-1);
  border: 1px solid var(--border);
}

.btn--danger {
  background: var(--negative);
  color: #fff;
}

.btn--sm {
  padding: 6px 12px;
  font-size: .78rem;
}


/* ── Form elements ────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .875rem;
  color: var(--text-1);
  background: var(--panel);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,110,247,.12);
}

.form-control::placeholder { color: var(--text-2); }

select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint { font-size: .75rem; color: var(--text-2); margin-top: 4px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 8px;
}


/* ── Detail info grid ─────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0;
}

.info-item {
  padding: 16px 20px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.info-item:nth-child(3n) { border-right: none; }

.info-item__label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-2);
  margin-bottom: 5px;
}

.info-item__value {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-1);
}


/* ── Timeline (follow-ups) ────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }

.timeline-item {
  display: flex;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent-lt);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.timeline-body { flex: 1; }

.timeline-meta {
  font-size: .75rem;
  color: var(--text-2);
  margin-bottom: 5px;
}

.timeline-comment {
  font-size: .875rem;
  color: var(--text-1);
  line-height: 1.6;
}


/* ── Alerts / messages ────────────────────────────── */
.messages {
  padding: 0 28px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: .84rem;
  font-weight: 500;
  background: var(--accent-lt);
  color: var(--accent);
  border: 1px solid rgba(79,110,247,.2);
}

.alert--error, .alert--danger {
  background: #FEE2E2;
  color: #B91C1C;
  border-color: rgba(239,68,68,.2);
}

.alert--success {
  background: #DCFCE7;
  color: #15803D;
  border-color: rgba(34,197,94,.2);
}

.alert--warning {
  background: #FEF9C3;
  color: #A16207;
  border-color: rgba(245,158,11,.2);
}

.alert__close {
  margin-left: auto;
  color: inherit;
  opacity: .6;
  font-size: .9rem;
  display: flex;
  align-items: center;
}

.alert__close:hover { opacity: 1; }


/* ── Pagination ───────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px;
  border-top: 1px solid var(--border);
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
}

.pagination a:hover { background: var(--surface); color: var(--text-1); }

.pagination .current {
  background: var(--accent);
  color: #fff;
}


/* ── Empty state ──────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-2);
}

.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; }

.empty-state__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}

.empty-state__desc { font-size: .84rem; }


/* ── Responsive / sidebar collapse ───────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 0 100vw rgba(0,0,0,.4);
  }

  .layout {
    margin-left: 0;
  }

  .main-content { padding: 20px 16px 40px; }

  .page-header { flex-direction: column; align-items: flex-start; }

  .info-grid { grid-template-columns: 1fr 1fr; }
  .info-item:nth-child(3n) { border-right: 1px solid var(--border); }
  .info-item:nth-child(2n) { border-right: none; }
}

.has-error .form-control {
  border-color: var(--negative);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .1);
}

.form-error {
  display: block;
  font-size: .75rem;
  color: var(--negative);
  margin-top: 4px;
}