/* ============================================================
   Moho Client Management System — Design System
   ============================================================ */

:root {
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --success: #16A34A;
  --danger: #DC2626;
  --warning: #D97706;
  --dark: #1E293B;
  --text: #334155;
  --muted: #64748B;
  --bg: #F8FAFC;
  --border: #E2E8F0;
  --white: #FFFFFF;
  --sidebar-width: 240px;
  --navbar-height: 56px;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --font: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 14px;
}

body.crm-body,
body.auth-body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

/* Glass */
.glass-card {
  background: rgb(255, 255, 255);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.55);
}

/* Layout */
.crm-wrapper {
  display: flex;
  min-height: 100vh;
}

.crm-sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}

.crm-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.crm-content {
  flex: 1;
  padding: 16px 20px 24px;
}

.crm-footer {
  padding: 12px 20px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  background: var(--white);
}

/* Sidebar brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--navbar-height);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--dark);
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 14px;
  font-weight: 600;
}

.brand-text small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.sidebar-close {
  color: var(--muted);
  padding: 4px;
}

.sidebar-nav {
  padding: 12px 10px;
  overflow-y: auto;
  flex: 1;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
}

.sidebar-nav .nav-link i {
  font-size: 16px;
  width: 18px;
  color: var(--muted);
}

.sidebar-nav .nav-link:hover {
  background: #F1F5F9;
  color: var(--dark);
}

.sidebar-nav .nav-link.active {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
}

.sidebar-nav .nav-link.active i {
  color: var(--primary);
}

.sidebar-nav .text-danger-nav {
  color: var(--danger) !important;
}

.sidebar-nav .text-danger-nav i {
  color: var(--danger) !important;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 8px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 1035;
}

.sidebar-backdrop.show {
  display: block;
}

/* Navbar */
.crm-navbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  min-height: var(--navbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
}

.navbar-left,
.navbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--dark);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
}

.btn-icon:hover {
  background: #F1F5F9;
  color: var(--dark);
}

.btn-admin {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--white);
  font-size: 13px;
  color: var(--text);
}

.admin-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.admin-name {
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Notification bell */
.notification-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.notification-menu {
  width: 320px;
  max-width: calc(100vw - 24px);
  padding: 0;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  overflow: hidden;
}

.notification-header,
.notification-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.notification-footer {
  border-bottom: none;
  border-top: 1px solid var(--border);
  justify-content: center;
}

.notification-list {
  max-height: 320px;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #F1F5F9;
  cursor: pointer;
  font-size: 13px;
}

.notification-item:hover {
  background: #F8FAFC;
}

.notification-item.unread {
  background: rgba(37, 99, 235, 0.04);
}

.notification-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.notification-dot.high { background: var(--danger); }
.notification-dot.medium { background: var(--warning); }
.notification-dot.low { background: var(--primary); }

.notification-item .ni-title {
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 2px;
}

.notification-item .ni-msg {
  color: var(--muted);
  font-size: 12px;
}

/* Cards */
.card-soft {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-soft .card-body {
  padding: 14px 16px;
}

.card-soft .card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--dark);
}

/* KPI */
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  height: 100%;
  transition: border-color 0.15s;
}

.kpi-card.clickable {
  cursor: pointer;
}

.kpi-card.clickable:hover {
  border-color: #CBD5E1;
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-label i {
  font-size: 14px;
  opacity: 0.7;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.2;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.kpi-growth.positive { color: var(--success); }
.kpi-growth.negative { color: var(--danger); }

/* Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
}

.badge-active,
.badge-paid { background: rgba(22, 163, 74, 0.12); color: #15803D; }
.badge-terminated,
.badge-cancelled,
.badge-overdue { background: rgba(220, 38, 38, 0.12); color: #B91C1C; }
.badge-follow-up,
.badge-partial,
.badge-pending { background: rgba(217, 119, 6, 0.12); color: #B45309; }
.badge-onboarded,
.badge-new { background: rgba(37, 99, 235, 0.12); color: #1D4ED8; }
.badge-not-interested,
.badge-inactive { background: rgba(100, 116, 139, 0.14); color: #475569; }

/* Tables */
.table-crm {
  margin: 0;
  font-size: 13px;
}

.table-crm thead th {
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 10px 12px;
  white-space: nowrap;
}

.table-crm tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  border-bottom: 1px solid #F1F5F9;
  color: var(--text);
}

.table-crm tbody tr:hover {
  background: #F8FAFC;
}

.table-responsive-crm {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Forms */
.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--dark);
  margin-bottom: 4px;
}

.form-control,
.form-select {
  font-size: 13.5px;
  border-color: var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-section {
  margin-bottom: 20px;
}

.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.form-text,
.invalid-feedback {
  font-size: 12px;
}

/* Buttons */
.btn {
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
}

.btn-sm {
  font-size: 12.5px;
  padding: 5px 10px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
}

.btn-outline-secondary {
  border-color: var(--border);
  color: var(--text);
}

.btn-outline-secondary:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
  color: var(--dark);
}

/* Filters bar */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin-bottom: 14px;
}

.filters-bar .form-control,
.filters-bar .form-select {
  min-width: 140px;
}

/* Compact filters (Clients / laptop) */
.filters-bar-compact {
  gap: 6px;
  align-items: center;
}

.filters-bar-compact .form-control,
.filters-bar-compact .form-select {
  min-width: 0;
  width: auto;
  font-size: 12.5px;
  padding: 4px 8px;
  height: 32px;
  line-height: 1.3;
}

.filters-bar-compact .filter-search {
  flex: 1 1 180px;
  min-width: 160px;
  max-width: 240px;
}

.filters-bar-compact .filter-sm {
  flex: 0 1 118px;
  width: 118px;
  max-width: 130px;
}

.filters-bar-compact .filter-city {
  flex: 0 0 90px;
  width: 90px;
  max-width: 90px;
}

.filters-bar-compact .filter-date {
  flex: 0 0 118px;
  width: 118px;
  max-width: 128px;
}

.filters-bar-compact .filter-per-page {
  flex: 0 0 64px;
  width: 64px;
  max-width: 64px;
  min-width: 64px;
}

.filters-bar-compact .btn {
  height: 32px;
  padding: 4px 10px;
  font-size: 12.5px;
  white-space: nowrap;
}

.filters-bar-compact .search-input-wrap i {
  left: 8px;
  font-size: 12px;
}

.filters-bar-compact .search-input-wrap .form-control {
  padding-left: 28px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
}

.search-input-wrap i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
}

.search-input-wrap .form-control {
  padding-left: 32px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-state i {
  font-size: 36px;
  opacity: 0.4;
  margin-bottom: 10px;
  display: block;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--dark);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  margin-bottom: 14px;
}

/* Auth pages */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at top left, rgba(37, 99, 235, 0.08), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(37, 99, 235, 0.05), transparent 45%),
    var(--bg);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 24px;
}

.auth-brand .brand-mark {
  width: 44px;
  height: 44px;
  font-size: 20px;
  margin: 0 auto 10px;
}

.auth-brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--dark);
  margin: 0 0 4px;
}

.auth-brand p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.auth-card .btn-primary {
  width: 100%;
  padding: 10px;
}

.auth-links {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
}

/* Offcanvas client detail */
.offcanvas-crm {
  width: 480px !important;
  max-width: 100vw;
}

.offcanvas-crm .offcanvas-header {
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
}

.offcanvas-crm .offcanvas-body {
  padding: 16px;
}

.detail-section {
  margin-bottom: 18px;
}

.detail-section h6 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}

.detail-item label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 1px;
}

.detail-item span {
  font-size: 13px;
  color: var(--dark);
  font-weight: 500;
}

.payment-summary-box {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.payment-summary-box .ps-label {
  font-size: 11px;
  color: var(--muted);
}

.payment-summary-box .ps-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--dark);
}

/* Mobile client cards */
.client-card-mobile {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.client-card-mobile .cc-name {
  font-weight: 600;
  color: var(--dark);
  font-size: 14px;
}

.client-card-mobile .cc-meta {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0;
}

.client-card-mobile .cc-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}

.client-card-mobile .cc-actions {
  margin-top: 10px;
  display: flex;
  gap: 6px;
}

/* Timeline / history */
.history-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #F1F5F9;
  font-size: 13px;
}

.history-item:last-child {
  border-bottom: none;
}

.history-date {
  min-width: 80px;
  color: var(--muted);
  font-size: 12px;
}

/* Spinner */
.spinner-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: -2px;
  margin-right: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Charts */
.chart-wrap {
  position: relative;
  height: 280px;
}

/* Pagination */
.pagination-crm .page-link {
  font-size: 13px;
  color: var(--text);
  border-color: var(--border);
  padding: 5px 10px;
}

.pagination-crm .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
}

.nav-pills .nav-link {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
}

.nav-pills .nav-link.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Utility */
.text-muted-sm {
  font-size: 12px;
  color: var(--muted);
}

.fw-600 { font-weight: 600; }

.gap-8 { gap: 8px; }

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 12px;
}

.list-compact .list-group-item {
  padding: 10px 12px;
  font-size: 13px;
  border-color: #F1F5F9;
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
  outline: none;
}
