/* CRM Lead Manager - stylesheet (vanilla CSS, no build step) */

:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --white: #ffffff;
  --text: #172b4d;
  --text-muted: #6b7280;
  --text-muted-strong: #4b5563;
  --border: #e5e7eb;
  --hover-bg: #f9fafb;
  --chip-bg: #f3f4f6;
  --divider: #f3f4f6;
  --muted-icon: #9ca3af;
  --input-border: #d1d5db;
  --blue: #0073ea;
  --blue-dark: #0060b9;
  --blue-soft: #eaf3ff;
  --red: #e2445c;
  --red-soft: #fde8ea;
  --red-text: #c22a42;
  --green: #00c875;
  --green-soft: #e1f9ee;
  --green-text: #048848;
  --warning-soft: #fff3e1;
  --warning-text: #b9700a;
  --whatsapp: #25d366;
  --whatsapp-dark: #1ebe5a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1320;
  --white: #1a2233;
  --text: #e5e9f0;
  --text-muted: #94a3b8;
  --text-muted-strong: #cbd5e1;
  --border: #2c3648;
  --hover-bg: #212b3d;
  --chip-bg: #232d40;
  --divider: #232d40;
  --muted-icon: #7c8aa0;
  --input-border: #3a4658;
  --blue-soft: #16283f;
  --red-soft: #3a1f26;
  --red-text: #ff96a6;
  --green-soft: #123527;
  --green-text: #4ade95;
  --warning-soft: #3a2c14;
  --warning-text: #f0a942;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

html {
  /* Setara tampilan browser di-zoom 90% (skala seluruh UI, bukan cuma teks). */
  zoom: 90%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

img, svg {
  display: block;
}

button {
  font-family: inherit;
  font-size: inherit;
}

/* ---------- Layout shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.main-col {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.main-content {
  flex: 1;
  width: 100%;
  padding: 20px 16px 96px;
}

.container {
  margin: 0 auto;
  width: 100%;
  max-width: 1100px;
}

@media (min-width: 640px) {
  .main-content {
    padding: 24px 24px 24px;
  }
}

@media (min-width: 768px) {
  .main-content {
    padding-bottom: 24px;
  }
}

/* ---------- Sidebar (desktop) ---------- */

.sidebar {
  display: none;
  width: 260px;
  flex-shrink: 0;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--white);
}

@media (min-width: 768px) {
  .sidebar {
    display: flex;
  }
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 64px;
  padding: 0 20px;
}

.logo-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  width: 32px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.logo-badge.sm {
  height: 28px;
  width: 28px;
  font-size: 12px;
}

.sidebar-logo-text {
  font-weight: 600;
  color: var(--text);
}

.sidebar-add {
  margin: 0 12px 8px;
}

.btn-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
}

.btn-add:hover {
  background: var(--blue-dark);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted-strong);
}

.nav-link:hover {
  background: var(--chip-bg);
}

.nav-link.active {
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.nav-badge {
  margin-left: auto;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 7px;
}

.sidebar-section {
  margin-top: 20px;
  padding: 0 12px;
  flex: 1;
}

.sidebar-section-title {
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-icon);
}

.sidebar-section .sidebar-nav {
  padding: 6px 0 0;
}

.dot {
  height: 10px;
  width: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
}

.sidebar-user-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  width: 28px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-footer form button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

/* ---------- Mobile header + bottom nav ---------- */

.mobile-header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}

@media (min-width: 768px) {
  .mobile-header {
    display: none;
  }
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--white);
  padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 768px) {
  .mobile-nav {
    display: none;
  }
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.mobile-nav-item.active {
  color: var(--blue);
}

.mobile-nav-item svg {
  height: 22px;
  width: 22px;
}

.mobile-nav-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  width: 28px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
}

/* ---------- Icons ---------- */

.icon {
  height: 16px;
  width: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon-fill {
  fill: currentColor;
  stroke: none;
}

/* ---------- Page header / typography ---------- */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted-icon);
  margin-bottom: 10px;
}

.back-link:hover {
  color: var(--text-muted-strong);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-muted-strong);
  cursor: pointer;
}

.btn:hover {
  background: var(--hover-bg);
}

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.btn-danger {
  background: var(--white);
  border-color: var(--red-soft);
  color: var(--red);
}

.btn-danger:hover {
  background: var(--red-soft);
}

.btn-whatsapp {
  background: var(--whatsapp);
  border-color: var(--whatsapp);
  color: #fff;
  font-weight: 600;
}

.btn-whatsapp:hover {
  background: var(--whatsapp-dark);
  border-color: var(--whatsapp-dark);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

/* ---------- Cards ---------- */

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 18px;
  margin-bottom: 16px;
}

.card:last-child {
  margin-bottom: 0;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 12px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.grid-2col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 992px) {
  .grid-2col {
    grid-template-columns: 2fr 1fr;
    align-items: start;
  }
}

/* ---------- Stat tiles (dashboard) ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

@media (min-width: 640px) {
  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 992px) {
  .stat-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.stat-tile {
  display: block;
  border-radius: var(--radius);
  padding: 16px;
  color: #fff;
  box-shadow: var(--shadow);
}

.stat-tile-label {
  font-size: 13px;
  opacity: 0.85;
}

.stat-tile-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 4px;
}

.followup-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 992px) {
  .followup-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.followup-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.followup-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
}

.followup-count {
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
}

.followup-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.followup-list li {
  border-top: 1px solid var(--divider);
}

.followup-list li:first-child {
  border-top: none;
}

.followup-list a {
  display: block;
  padding: 10px 16px;
}

.followup-list a:hover {
  background: var(--hover-bg);
}

.followup-empty {
  padding: 16px;
  color: var(--muted-icon);
  font-size: 13px;
}

/* ---------- Filter tabs / search ---------- */

.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
}

.filter-tab {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-muted-strong);
}

.filter-tab.active {
  color: #fff;
  border-color: transparent;
}

.search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 20px;
}

.search-input-wrap {
  position: relative;
  flex: 1 1 240px;
  max-width: 320px;
}

.search-input-wrap input {
  width: 100%;
}

.search-form select {
  width: auto;
  flex: 0 1 220px;
}

.search-form .btn {
  flex: 0 0 auto;
}

.search-input-wrap .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-icon);
}

.search-input-wrap input {
  padding-left: 32px;
}

/* ---------- Forms ---------- */

.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .form-row-2 {
    grid-template-columns: 1fr 1fr;
  }
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted-strong);
  margin-bottom: 4px;
}

.required {
  color: var(--red);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
}

textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

.w-auto {
  width: auto;
  display: inline-block;
}

/* ---------- Alerts ---------- */

.alert {
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-error {
  background: var(--red-soft);
  color: var(--red-text);
}

.alert-success {
  background: var(--green-soft);
  color: var(--green-text);
}

.alert-info {
  background: var(--chip-bg);
  color: var(--text-muted-strong);
}

/* ---------- Board groups (leads list) ---------- */

.board-group {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 16px;
}

.board-group summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}

.board-group summary::-webkit-details-marker {
  display: none;
}

.board-group-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.board-group-count {
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
}

.chevron {
  height: 16px;
  width: 16px;
  color: var(--muted-icon);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.board-group[open] summary .chevron {
  transform: rotate(180deg);
}

.board-group-empty {
  padding: 0 16px 16px;
  color: var(--muted-icon);
  font-size: 13px;
}

/* Desktop table */
.lead-table {
  display: none;
  width: 100%;
  border-collapse: collapse;
}

@media (min-width: 768px) {
  .lead-table {
    display: table;
  }
}

.lead-table thead tr {
  background: var(--hover-bg);
  border-top: 1px solid var(--divider);
}

.lead-table th {
  text-align: left;
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.lead-table td {
  padding: 12px 16px;
  border-top: 1px solid var(--divider);
  font-size: 14px;
  vertical-align: top;
}

.lead-table tr:hover td {
  background: var(--hover-bg);
}

.lead-name-link {
  font-weight: 500;
  color: var(--text);
}

.lead-name-link:hover {
  text-decoration: underline;
}

.text-muted {
  color: var(--muted-icon);
}

.text-muted-strong {
  color: var(--text-muted-strong);
}

.text-overdue {
  color: var(--red);
  font-weight: 600;
}

.text-today {
  color: var(--warning-text);
  font-weight: 600;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

/* Mobile cards */
.lead-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--divider);
}

@media (min-width: 768px) {
  .lead-cards {
    display: none;
  }
}

.lead-cards li {
  border-top: 1px solid var(--divider);
}

.lead-cards li:first-child {
  border-top: none;
}

.lead-cards a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
}

.lead-cards a:active {
  background: var(--hover-bg);
}

.lead-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lead-card-name {
  font-weight: 500;
  color: var(--text);
}

.status-pill {
  flex-shrink: 0;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
}

.program-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
}

/* ---------- Lead detail ---------- */

.lead-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

@media (min-width: 640px) {
  .lead-header {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }
}

.lead-header-info {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  width: 48px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.lead-header-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.lead-header-name h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.lead-contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

.lead-contact-row span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lead-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 639px) {
  .lead-actions .btn-label {
    display: none;
  }
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.timeline-item {
  border-left: 2px solid var(--border);
  padding-left: 14px;
}

.timeline-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted-icon);
}

.timeline-note {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--text-muted-strong);
  white-space: pre-wrap;
}

.meta-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.meta-list div {
  display: flex;
  justify-content: space-between;
}

.meta-list span:last-child {
  color: var(--text-muted-strong);
}

/* ---------- Programs page ---------- */

.program-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .program-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 992px) {
  .program-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.program-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.program-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.program-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  width: 36px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  flex-shrink: 0;
}

.program-card-actions {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.empty-state {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 32px;
  text-align: center;
  color: var(--muted-icon);
  font-size: 13px;
}

/* ---------- Auth pages ---------- */

.auth-wrap {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

.auth-box {
  width: 100%;
  max-width: 380px;
}

.auth-header {
  text-align: center;
  margin-bottom: 20px;
}

.auth-header .logo-badge {
  margin: 0 auto;
}

.auth-header h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 12px 0 4px;
}

.auth-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* ---------- Settings page ---------- */

.theme-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted-strong);
}

.theme-option input {
  width: auto;
  margin: 0;
}

.theme-option.selected {
  border-color: var(--blue);
  color: var(--text);
  background: var(--blue-soft);
}

.theme-preview {
  display: inline-block;
  height: 20px;
  width: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.theme-preview-light {
  background: linear-gradient(135deg, #ffffff 50%, #f6f7fb 50%);
}

.theme-preview-dark {
  background: linear-gradient(135deg, #1a2233 50%, #0d1320 50%);
}

.about-content h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 20px 0 8px;
}

.about-content h3:first-child {
  margin-top: 0;
}

.about-content p {
  font-size: 13px;
  color: var(--text-muted-strong);
  line-height: 1.6;
  margin: 0 0 8px;
}

.about-content ol {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-muted-strong);
  line-height: 1.8;
}

.about-content code {
  background: var(--chip-bg);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
}
