/*
 * CRM + Settings on the SignalWealth app theme (sw-theme.css). Loaded after the page's own <style>,
 * so these rules restyle the existing components without touching the page scripts.
 */

body { font-weight: 400; }

/* ── Sidebar ── */
.sidebar { width: 248px; background: var(--sw-surface); border-right: 1px solid var(--sw-border); }
.sidebar-brand { padding: 18px 16px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--sw-border); }
.sidebar-brand > div:not(.brand-logo) { min-width: 0; }
.brand-logo {
  width: 36px; height: 36px; margin: 0; flex-shrink: 0; border-radius: 9px; padding: 0;
  background: var(--sw-brand); border: 0; color: #FFFFFF;
}
.brand-logo svg { color: #FFFFFF; }
.brand-logo img { border-radius: 8px; }
/* A real logo shows as itself: no accent square behind it (Settings swaps the icon for an <img>). */
.brand-logo:has(img), .preview-mock-logo:has(img[src]:not([src=""])) { background: transparent; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-family: var(--sw-font-display); font-weight: 600; font-size: 15px; color: var(--sw-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub { font-size: 12px; letter-spacing: 0; text-transform: none; color: var(--sw-text-3); margin-top: 1px; }

.sidebar-nav { padding: 14px 12px; overflow-y: auto; }
.nav-section {
  font-size: 11px; letter-spacing: .06em; font-weight: 600; color: var(--sw-text-3);
  padding: 14px 10px 6px;
}
.sidebar-nav > .nav-section:first-child { padding-top: 2px; }
.nav-item {
  height: 38px; padding: 0 10px; gap: 10px; border-radius: 9px; border: 0; margin-bottom: 2px;
  font-size: 14px; font-weight: 500; color: var(--sw-text-2);
}
.nav-item:hover { color: var(--sw-text); background: var(--sw-overlay-1); }
.nav-item.active { color: var(--sw-accent); background: var(--sw-accent-soft); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; opacity: 1; stroke-width: 1.8; }
.nav-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
  background: var(--sw-surface-2); color: var(--sw-text-2);
}
.nav-item.active .nav-badge, .nav-badge.is-accent { background: var(--sw-accent-soft); color: var(--sw-accent); }

.sidebar-user { padding: 12px 14px; gap: 10px; border-top: 1px solid var(--sw-border); }
.user-avatar {
  width: 32px; height: 32px; font-size: 12px; background: var(--sw-surface-2); border: 0; color: var(--sw-text);
}
.user-info { flex: 1; }
.user-name { font-size: 14px; color: var(--sw-text); }
.user-role { font-size: 12px; text-transform: none; letter-spacing: 0; color: var(--sw-text-3); }
.sidebar-signout {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent; background: transparent;
  color: var(--sw-text-3); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.sidebar-signout:hover { color: var(--sw-text); background: var(--sw-overlay-1); }
.sidebar-signout svg { width: 17px; height: 17px; }

/* ── Top bar ── */
.main { background: var(--sw-bg); }
.topbar { height: 64px; padding: 0 28px; gap: 12px; background: var(--sw-surface); border-bottom: 1px solid var(--sw-border); }
.topbar-title { font-family: var(--sw-font-display); font-weight: 600; font-size: 19px; letter-spacing: -.01em; color: var(--sw-text); }
.topbar-sep { display: none; }
.search-wrap { max-width: 460px; margin-left: 12px; }
.search-wrap svg { left: 12px; width: 16px; height: 16px; color: var(--sw-text-3); }
.search-input {
  height: 40px; padding: 0 12px 0 36px; border-radius: var(--sw-radius); font-family: var(--sw-font-ui);
  font-size: 14px; font-weight: 400; background: var(--sw-bg); border: 1px solid var(--sw-border); color: var(--sw-text);
}
.search-input::placeholder { color: var(--sw-text-3); }
.search-input:focus { border-color: var(--sw-accent-dim); box-shadow: var(--sw-focus); }
.topbar-actions { gap: 8px; align-items: center; }
#notifBellBtn { width: 38px; height: 38px; padding: 0 !important; justify-content: center; }
#notifBellBtn svg { width: 18px; height: 18px; }
#notifPanel { border-radius: var(--sw-radius-lg); overflow: hidden; }
.topbar .contacts-only { display: none; }
body.view-contacts .topbar .contacts-only { display: flex; }

/* The sidebar is the navigation; the duplicate tab row goes. */
.view-tabs { display: none; }

/* ── Buttons ── */
.btn {
  height: 38px; padding: 0 14px; border-radius: var(--sw-radius); font-family: var(--sw-font-ui);
  font-size: 14px; font-weight: 500; letter-spacing: 0; gap: 6px;
}
.btn svg { width: 16px; height: 16px; }
.btn-ghost { background: var(--sw-surface); border: 1px solid var(--sw-border); color: var(--sw-text-2); }
.btn-ghost:hover { border-color: var(--sw-border-strong); color: var(--sw-text); }
.btn-ghost.active { background: var(--sw-accent-soft); border-color: transparent; color: var(--sw-accent); }
.btn-primary { background: var(--sw-btn); color: var(--sw-on-accent); border: 0; }
.btn-primary:hover { background: var(--sw-btn); filter: brightness(1.08); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-danger {
  height: 32px; border-radius: var(--sw-radius); border: 1px solid color-mix(in srgb, var(--sw-err) 40%, transparent);
  color: var(--sw-err); font-family: var(--sw-font-ui); font-size: 13px;
}
.btn-danger:hover { background: var(--sw-err-soft); }

/* ── Stats ── */
.stats-strip { background: var(--sw-surface); border-bottom: 1px solid var(--sw-border); }
.stat-box { padding: 14px 20px; border-right: 1px solid var(--sw-border); }
.stat-val { font-family: var(--sw-font-display); font-weight: 600; font-size: 24px; color: var(--sw-text); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--sw-text-2); margin-top: 6px; }
#statsStrip { display: none; }
body.view-contacts #statsStrip { display: flex; }

/* ── Dashboard cards ── */
#dashboardView { padding: 28px 28px 40px !important; gap: 20px !important; }
#dashboardView > div > div, #dashboardView > div[style*="border"] {
  border-radius: var(--sw-radius-lg);
}
#dashboardStats { gap: 16px !important; }
#dashboardView .detail-section-title {
  font-size: 15px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--sw-text);
}
#dashboardTodayContent { font-size: 14px !important; gap: 8px !important; }
#dashboardView > div[style*="border"], #dashboardView > div > div[style*="border"] { padding: 20px 22px !important; }
#dashboardStats .stat-box {
  border: 1px solid var(--sw-border) !important; border-radius: var(--sw-radius-lg); background: var(--sw-surface) !important;
  padding: 18px 20px; display: flex; flex-direction: column-reverse; gap: 8px;
}
#dashboardStats .stat-val { font-size: 28px; }
#dashboardStats .stat-label { margin-top: 0; }

/* ── Contacts list + detail ── */
.filter-bar { padding: 12px 20px; gap: 8px; background: var(--sw-surface); border-bottom: 1px solid var(--sw-border); }
.filter-chip {
  height: 32px; padding: 0 12px; border-radius: 999px; font-family: var(--sw-font-ui); font-size: 13px; letter-spacing: 0;
  border: 1px solid var(--sw-border); color: var(--sw-text-2); display: inline-flex; align-items: center;
}
.filter-chip:hover { border-color: var(--sw-border-strong); color: var(--sw-text); }
.filter-chip.active { background: var(--sw-accent-soft); border-color: transparent; color: var(--sw-accent); font-weight: 500; }
.filter-count { font-size: 13px; color: var(--sw-text-3); }
.contacts-pane { background: var(--sw-surface); }
.contact-row { padding: 12px 20px; border-bottom: 1px solid var(--sw-border); }
.contact-row:hover { background: var(--sw-overlay-1); }
.contact-row.selected { background: var(--sw-accent-soft); }
.contact-name { font-size: 14px; }
.contact-meta { font-size: 13px; color: var(--sw-text-2); }
.contact-avatar { border: 0 !important; }
.stage-pill {
  font-size: 12px; letter-spacing: 0; text-transform: none; padding: 3px 9px; border-radius: 999px;
  border-color: transparent !important; background: var(--sw-surface-2);
}
.detail-panel { background: var(--sw-surface); border-left: 1px solid var(--sw-border); }
.detail-name { font-family: var(--sw-font-display); font-weight: 600; font-size: 20px; }
.detail-email { font-size: 13px; }
.detail-avatar { border: 0 !important; }
.detail-section-title { font-size: 12px; letter-spacing: .04em; font-weight: 600; color: var(--sw-text-3); }
.field-label { font-size: 13px; color: var(--sw-text-3); }
.field-value { font-size: 14px; }
.stage-btn {
  height: 30px; padding: 0 12px; border-radius: 999px; font-family: var(--sw-font-ui); font-size: 12px;
  letter-spacing: 0; text-transform: none; color: var(--sw-text-2);
}
.stage-btn.active { background: color-mix(in srgb, var(--stage-color) 12%, transparent); }
.detail-empty p, .empty-state p { font-family: var(--sw-font-ui); font-style: normal; font-size: 14px; opacity: 1; color: var(--sw-text-2); }
.note-item { border-radius: var(--sw-radius); background: var(--sw-surface-2); border-color: transparent; }
.note-text { font-size: 14px; }
.note-meta { font-size: 12px; }
.note-type-badge, .tag-chip, .row-tag {
  font-size: 12px; letter-spacing: 0; text-transform: none; border-radius: 999px; padding: 2px 8px;
  border: 0; background: var(--sw-surface-2); color: var(--sw-text-2);
}

/* ── Forms ── */
.form-label { font-size: 13px; letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--sw-text-2); }
.form-input, .form-select, .note-input, .note-type-sel, .tag-input-wrap {
  border-radius: var(--sw-radius); background: var(--sw-surface); border: 1px solid var(--sw-border-strong);
  font-family: var(--sw-font-ui); font-size: 14px; font-weight: 400; color: var(--sw-text);
}
.form-input, .form-select { height: 40px; padding: 0 12px; }
textarea.form-input { height: auto; padding: 10px 12px; }
.form-input:focus, .form-select:focus, .note-input:focus, .tag-input-wrap:focus-within {
  border-color: var(--sw-accent-dim); box-shadow: var(--sw-focus);
}
.form-select option { background: var(--sw-surface); color: var(--sw-text); }
.tag-text-input { font-family: var(--sw-font-ui); font-size: 14px; }

/* ── Pipeline ── */
.pipeline-board { padding: 20px 28px; gap: 14px; }
.pipeline-col { width: 272px; }
.pipeline-col-header {
  border-radius: var(--sw-radius); border: 1px solid var(--sw-border); border-top: 3px solid var(--stage-col);
  border-bottom-width: 1px; background: var(--sw-surface);
}
.pipeline-col-name { font-size: 13px; letter-spacing: 0; text-transform: capitalize; font-weight: 600; color: var(--sw-text); }
.pipeline-col-count { font-family: var(--sw-font-ui); font-size: 13px; color: var(--sw-text-3); }
.pipeline-cards { border-radius: var(--sw-radius); background: var(--sw-overlay-1); gap: 8px; }
.pipeline-card { border-radius: var(--sw-radius); background: var(--sw-surface); border: 1px solid var(--sw-border); box-shadow: var(--sw-shadow-sm); }
.pipeline-card:hover { border-color: var(--sw-border-strong); box-shadow: var(--sw-shadow-md); }
.pipeline-card-name { font-size: 14px; }
.pipeline-card-meta { font-size: 13px; }
.pipeline-card-value { font-family: var(--sw-font-ui); font-weight: 600; font-size: 14px; color: var(--sw-text); font-variant-numeric: tabular-nums; }

/* ── Modal, toast, spinner ── */
.modal-overlay { background: var(--sw-scrim); backdrop-filter: blur(3px); }
.modal { border-radius: var(--sw-radius-lg); background: var(--sw-surface); border: 1px solid var(--sw-border); box-shadow: var(--sw-shadow-lg); width: 480px; }
.modal-title { font-family: var(--sw-font-display); font-weight: 600; font-size: 18px; }
.modal-close { border-radius: 8px; }
.modal-close:hover { background: var(--sw-overlay-1); }
.toast { border-radius: var(--sw-radius); background: var(--sw-text); color: var(--sw-surface); border: 0; box-shadow: var(--sw-shadow-lg); font-size: 14px; }
.spinner { border-color: var(--sw-border-strong); border-top-color: var(--sw-accent); }
.bulk-bar { background: var(--sw-accent-soft); border-bottom: 1px solid var(--sw-border); }
.bulk-bar-count { font-size: 14px; }
.import-result { border-radius: var(--sw-radius); }
.mobile-sidebar-overlay { background: var(--sw-scrim); }
.mobile-back-btn { font-family: var(--sw-font-ui); font-size: 14px; }

/* ── Settings ── */
.settings-layout { background: var(--sw-bg); }
.settings-nav { background: var(--sw-surface); border-right: 1px solid var(--sw-border); padding: 16px 12px; min-width: 216px; }
.settings-nav-item { white-space: nowrap; }
.settings-nav-item {
  height: 38px; padding: 0 12px; border-radius: 9px; border: 0 !important; gap: 10px; font-size: 14px; font-weight: 500;
  color: var(--sw-text-2); display: flex; align-items: center; margin-bottom: 2px;
}
.settings-nav-item:hover { background: var(--sw-overlay-1); color: var(--sw-text); }
.settings-nav-item.active { background: var(--sw-accent-soft); color: var(--sw-accent); font-weight: 600; }
.settings-nav-item svg { width: 18px; height: 18px; }
.section-heading { font-family: var(--sw-font-display); font-weight: 600; font-size: 22px; letter-spacing: -.01em; color: var(--sw-text); }
.section-sub { font-size: 14px; color: var(--sw-text-2); }
.form-block { background: var(--sw-surface); border: 1px solid var(--sw-border); border-radius: var(--sw-radius-lg); overflow: hidden; }
.form-block-header { border-bottom: 1px solid var(--sw-border); background: transparent; }
.form-block-title { font-size: 15px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--sw-text); }
.form-hint { font-size: 13px; color: var(--sw-text-3); }
.save-status { font-size: 13px; }
.color-swatch { border-radius: 8px; overflow: hidden; }
.sw-appearance { display: flex; flex-wrap: wrap; gap: 10px; }
.sw-appearance-opt {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: var(--sw-radius);
  border: 1px solid var(--sw-border-strong); cursor: pointer; font-size: 14px; color: var(--sw-text);
}
.sw-appearance-opt:has(input:checked) { border-color: var(--sw-accent); background: var(--sw-accent-soft); }
.sw-appearance-opt input { accent-color: var(--sw-accent); }
.preview-mock { border: 1px solid var(--sw-border); border-radius: var(--sw-radius-lg); background: var(--sw-bg); }
.preview-mock-topbar { background: var(--sw-surface); border-bottom: 1px solid var(--sw-border); height: 44px; }
.preview-mock-logo { width: 26px; height: 26px; border-radius: 7px; background: var(--sw-brand); border: 0; }
.preview-mock-logo svg { color: #FFFFFF; }
.preview-mock-name { font-family: var(--sw-font-display); font-weight: 600; font-size: 14px; color: var(--sw-text); }
.preview-mock-body { padding: 14px; gap: 12px; background: var(--sw-bg); }
.preview-mock-sidebar { width: 110px; height: 76px; border-radius: 9px; background: var(--sw-surface); border: 1px solid var(--sw-border); position: relative; }
.preview-mock-sidebar::after { content: ''; position: absolute; left: 8px; right: 8px; top: 10px; height: 18px; border-radius: 6px; background: var(--sw-accent-soft); }
.preview-mock-content {
  height: 76px; border-radius: 9px; background: var(--sw-surface); border: 1px solid var(--sw-border);
  display: flex; align-items: center; justify-content: flex-end; gap: 14px; padding: 0 14px;
}
.preview-mock-link { font-size: 13px; color: var(--sw-accent); }
.preview-mock-btn { font-size: 13px; font-weight: 500; color: #FFFFFF; background: var(--sw-btn); border-radius: 8px; padding: 7px 12px; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--sw-border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }

@media (max-width: 768px) {
  .topbar { padding: 10px 14px; height: auto; }
  .search-wrap { margin-left: 0; max-width: none; order: 3; flex: 1 1 100%; width: 100%; }
  .topbar-actions { margin-left: auto; }
  #dashboardView { padding: 16px !important; }
  .pipeline-board { padding: 14px; }
}
