/* public/css/dashboard-dark.css
 * Dark navy + mint redesign for the four active content pages
 * (Dashboard, Leads, Pipeline, Contacts). All rules are scoped with the
 * `-d` prefix so they cannot collide with legacy `.kpi-card`, `.table`,
 * `.feed-row` styles in workspace.css. Depth is achieved via color
 * contrast, NOT box-shadows.
 */

:root {
  --d-bg: #0a1628;
  --d-bg-2: #0d2137;
  --d-surface: #112638;
  --d-surface-2: #16314b;
  --d-border: rgba(255, 255, 255, 0.06);
  --d-border-2: rgba(255, 255, 255, 0.10);
  --d-fg: #ffffff;
  --d-fg-2: #cbd5e1;
  --d-fg-3: #7e94ad;
  --d-mint: #00e5a0;
  --d-mint-2: #00d4a8;
  --d-mint-dim: rgba(0, 229, 160, 0.12);
  --d-teal-grad: linear-gradient(135deg, rgba(0, 229, 160, 0.18) 0%, rgba(0, 212, 168, 0.06) 60%, transparent 100%);
  --d-radius: 16px;
}

/* Background anchor for the active section root the AppShell mounts each
 * section into. The shell wraps each route in #app-section-<key> then
 * appends it to #content-area; we paint the body inside it. */
.app-section[data-section="dashboard"],
.app-section[data-section="leads"],
.app-section[data-section="pipeline"],
.app-section[data-section="contacts"] {
  background: var(--d-bg);
  color: var(--d-fg);
  position: relative;
  font-family: 'Sora', 'DM Sans', system-ui, -apple-system, sans-serif;
}

/* ── Hero header band ───────────────────────────────────────────────────── */
.d-page {
  position: relative;
  background: var(--d-bg);
  color: var(--d-fg);
  font-family: 'Sora', 'DM Sans', system-ui, -apple-system, sans-serif;
  min-height: 100%;
  padding: 28px clamp(20px, 3vw, 40px) 60px;
}

.d-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--d-radius);
  border: 1px solid var(--d-border);
  background:
    var(--d-teal-grad),
    radial-gradient(ellipse at top right, rgba(0, 229, 160, 0.10), transparent 60%),
    var(--d-bg-2);
  padding: 32px clamp(20px, 3vw, 36px);
  margin-bottom: 28px;
}

.d-hero-grid-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 60px 60px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 0%, transparent 80%);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 0%, transparent 80%);
  pointer-events: none;
  opacity: 0.9;
}

.d-hero-content {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.d-hero-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--d-mint);
  margin-bottom: 10px;
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--d-mint-dim);
  border: 1px solid rgba(0, 229, 160, 0.30);
}

.d-hero-title {
  font-family: 'Sora', sans-serif;
  font-size: clamp(32px, 4.4vw, 52px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--d-fg);
  margin: 0;
}

.d-accent {
  color: var(--d-mint);
}

.d-hero-sub {
  margin: 14px 0 0;
  font-size: 15px;
  color: var(--d-fg-2);
  max-width: 560px;
  line-height: 1.5;
}

.d-hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Pill CTA ───────────────────────────────────────────────────────────── */
.d-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--d-mint);
  color: #04221b;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--d-mint);
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.d-pill:hover {
  background: var(--d-mint-2);
  border-color: var(--d-mint-2);
  transform: translateY(-1px);
}

.d-pill-ghost {
  background: transparent;
  color: var(--d-fg);
  border: 1px solid var(--d-border-2);
  font-weight: 600;
}

.d-pill-ghost:hover {
  border-color: var(--d-mint);
  color: var(--d-mint);
}

.d-pill-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* ── Card grids ─────────────────────────────────────────────────────────── */
.d-grid {
  display: grid;
  gap: 18px;
}

.d-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.d-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.d-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.d-card {
  background: var(--d-surface);
  border: 1px solid var(--d-border);
  border-radius: var(--d-radius);
  padding: 22px 24px;
  position: relative;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.d-card:hover {
  border-color: var(--d-border-2);
  background: var(--d-surface-2);
}

.d-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.d-card-title {
  font-family: 'Sora', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--d-fg);
  margin: 0;
}

.d-card-sub {
  font-size: 12px;
  color: var(--d-fg-3);
  margin-top: 2px;
}

/* ── Stat card ──────────────────────────────────────────────────────────── */
.d-stat-card {
  background: var(--d-surface);
  border: 1px solid var(--d-border);
  border-radius: var(--d-radius);
  padding: 22px 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 160ms ease, background-color 160ms ease;
  overflow: hidden;
}

.d-stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--d-teal-grad);
  opacity: 0.45;
  pointer-events: none;
}

.d-stat-card:hover {
  border-color: rgba(0, 229, 160, 0.30);
  background: var(--d-surface-2);
}

.d-stat-card > * {
  position: relative;
}

.d-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--d-mint-dim);
  border: 1px solid rgba(0, 229, 160, 0.30);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--d-mint);
}

.d-stat-icon svg {
  stroke: var(--d-mint);
  fill: none;
  stroke-width: 1.8;
}

.d-stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--d-fg-3);
}

.d-stat-value {
  font-family: 'Sora', sans-serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--d-fg);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.d-stat-delta {
  font-size: 12px;
  color: var(--d-fg-3);
  display: flex;
  gap: 6px;
  align-items: center;
}

.d-stat-delta-pos {
  color: var(--d-mint);
}

/* ── Chip ───────────────────────────────────────────────────────────────── */
.d-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--d-surface-2);
  color: var(--d-fg-2);
  border: 1px solid var(--d-border-2);
  white-space: nowrap;
}

.d-chip-mint {
  background: var(--d-mint-dim);
  color: var(--d-mint);
  border: 1px solid rgba(0, 229, 160, 0.30);
}

.d-chip-muted {
  background: var(--d-surface-2);
  color: var(--d-fg-2);
  border: 1px solid var(--d-border);
}

/* ── Filter bar ─────────────────────────────────────────────────────────── */
.d-filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  background: var(--d-surface);
  border: 1px solid var(--d-border);
  border-radius: var(--d-radius);
  margin-bottom: 18px;
}

.d-filterbar input,
.d-filterbar select {
  background: var(--d-bg-2);
  color: var(--d-fg);
  border: 1px solid var(--d-border-2);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 120ms ease;
}

.d-filterbar input:focus,
.d-filterbar select:focus {
  border-color: var(--d-mint);
}

.d-filterbar input[type="search"] {
  flex: 1;
  min-width: 220px;
}

/* ── Table ──────────────────────────────────────────────────────────────── */
.d-table-wrap {
  background: var(--d-surface);
  border: 1px solid var(--d-border);
  border-radius: var(--d-radius);
  overflow: auto;
}

.d-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Sora', 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  color: var(--d-fg);
}

.d-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--d-fg-3);
  padding: 14px 18px;
  border-bottom: 1px solid var(--d-border-2);
  background: var(--d-bg-2);
  position: sticky;
  top: 0;
}

.d-table tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--d-border);
  vertical-align: middle;
  color: var(--d-fg);
}

.d-table tbody tr {
  transition: background-color 120ms ease;
  cursor: pointer;
}

.d-table tbody tr:hover {
  background: var(--d-surface-2);
}

/* ── Avatar ─────────────────────────────────────────────────────────────── */
.d-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--d-mint), #0a8b6b 70%);
  color: #04221b;
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

.d-avatar-1 { background: radial-gradient(circle at 30% 30%, var(--d-mint), #0a8b6b 70%); }
.d-avatar-2 { background: radial-gradient(circle at 30% 30%, #4dd0c1, #166e75 70%); color: #021a18; }
.d-avatar-3 { background: radial-gradient(circle at 30% 30%, #58e0c4, #0d4e62 70%); color: #04221b; }
.d-avatar-4 { background: radial-gradient(circle at 30% 30%, #b6f5a0, #4a8c2b 70%); color: #1a2e0b; }
.d-avatar-5 { background: radial-gradient(circle at 30% 30%, #82f5d5, #217c66 70%); color: #04221b; }

/* ── Contact card ───────────────────────────────────────────────────────── */
.d-contact-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.d-contact-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.d-contact-name {
  font-family: 'Sora', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--d-fg);
  line-height: 1.2;
}

.d-contact-meta {
  font-size: 13px;
  color: var(--d-fg-2);
  line-height: 1.5;
}

.d-contact-meta div {
  margin-top: 2px;
}

.d-contact-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* ── Pipeline Kanban ─────────────────────────────────────────────────────── */
.d-kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(260px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 14px;
}

.d-column {
  background: var(--d-bg-2);
  border: 1px solid var(--d-border);
  border-radius: var(--d-radius);
  display: flex;
  flex-direction: column;
  min-height: 320px;
  min-width: 240px;
}

.d-column.is-active {
  border-top: 2px solid var(--d-mint);
  background: var(--d-surface);
}

.d-column-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--d-border);
  background: var(--d-surface);
  border-radius: var(--d-radius) var(--d-radius) 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.d-column.is-active .d-column-header {
  background: var(--d-mint-dim);
}

.d-column-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--d-fg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.d-column-meta {
  font-size: 11px;
  color: var(--d-fg-3);
}

.d-column-meta strong {
  color: var(--d-mint);
  font-weight: 700;
}

.d-column-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  overflow-y: auto;
}

.d-col-card {
  background: var(--d-surface);
  border: 1px solid var(--d-border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  position: relative;
  transition: border-color 120ms ease, background-color 120ms ease, transform 120ms ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.d-col-card:hover {
  border-color: var(--d-border-2);
  background: var(--d-surface-2);
  transform: translateY(-1px);
}

.d-col-card.is-active {
  border-left: 3px solid var(--d-mint);
}

.d-col-card-name {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--d-fg);
  line-height: 1.3;
}

.d-col-card-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--d-mint);
  font-variant-numeric: tabular-nums;
}

.d-col-card-meta {
  font-size: 11px;
  color: var(--d-fg-3);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* ── Pipeline funnel list (dashboard widget) ───────────────────────────── */
.d-funnel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--d-border);
}

.d-funnel-row:last-child {
  border-bottom: none;
}

.d-funnel-label {
  flex: 0 0 130px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--d-fg-3);
}

.d-funnel-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--d-bg-2);
  border-radius: 999px;
  overflow: hidden;
}

.d-funnel-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--d-mint) 0%, var(--d-mint-2) 100%);
  border-radius: 999px;
}

.d-funnel-count {
  flex: 0 0 50px;
  text-align: right;
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--d-mint);
  font-variant-numeric: tabular-nums;
}

/* ── Activity feed (dashboard widget) ───────────────────────────────────── */
.d-feed {
  display: flex;
  flex-direction: column;
}

.d-feed-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--d-border);
}

.d-feed-row:last-child {
  border-bottom: none;
}

.d-feed-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--d-mint);
  flex-shrink: 0;
}

.d-feed-dot.is-won { background: var(--d-mint); }
.d-feed-dot.is-lost { background: #fb7185; }
.d-feed-dot.is-neutral { background: var(--d-fg-3); }

.d-feed-text {
  flex: 1;
  font-size: 13px;
  color: var(--d-fg);
  line-height: 1.4;
  min-width: 0;
}

.d-feed-text strong {
  font-weight: 600;
}

.d-feed-time {
  font-size: 11px;
  color: var(--d-fg-3);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ── Slide-in detail panel ─────────────────────────────────────────────── */
.d-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 22, 40, 0.55);
  z-index: 30;
}

.d-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 92vw;
  background: var(--d-bg-2);
  border-left: 1px solid var(--d-border-2);
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--d-radius) 0 0 var(--d-radius);
}

.d-panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--d-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.d-panel-title {
  font-family: 'Sora', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--d-fg);
  margin: 0;
}

.d-panel-close {
  background: transparent;
  border: 1px solid var(--d-border-2);
  color: var(--d-fg-2);
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.d-panel-close:hover {
  color: var(--d-mint);
  border-color: var(--d-mint);
}

.d-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.d-panel-section {
  margin-bottom: 20px;
}

.d-panel-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--d-fg-3);
  font-weight: 700;
  margin: 0 0 8px;
}

.d-panel-block {
  background: var(--d-surface);
  border: 1px solid var(--d-border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--d-fg-2);
}

/* ── Empty / loading state ──────────────────────────────────────────────── */
.d-empty {
  background: var(--d-surface);
  border: 1px dashed var(--d-border-2);
  border-radius: var(--d-radius);
  padding: 50px 32px;
  text-align: center;
}

.d-empty-title {
  font-family: 'Sora', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--d-fg);
  margin: 0 0 6px;
}

.d-empty-sub {
  font-size: 14px;
  color: var(--d-fg-3);
  margin: 0 0 18px;
}

.d-loading {
  text-align: center;
  padding: 36px;
  font-size: 14px;
  color: var(--d-fg-3);
}

/* ── Move-to pill menu (Pipeline Kanban) ───────────────────────────────── */
.d-menu {
  position: absolute;
  z-index: 60;
  background: var(--d-bg-2);
  border: 1px solid var(--d-border-2);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.d-menu-item {
  background: transparent;
  border: none;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--d-fg);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.d-menu-item:hover {
  background: var(--d-mint-dim);
  color: var(--d-mint);
}

.d-menu-item.is-current {
  color: var(--d-mint);
  font-weight: 700;
  background: var(--d-mint-dim);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .d-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .d-kanban {
    grid-template-columns: repeat(5, minmax(260px, 1fr));
  }
}

@media (max-width: 768px) {
  .d-grid-4,
  .d-grid-3,
  .d-grid-2 {
    grid-template-columns: 1fr;
  }
  .d-hero-content {
    flex-direction: column;
    align-items: flex-start;
  }
  .d-hero-actions {
    width: 100%;
  }
  .d-pill {
    flex: 1;
    justify-content: center;
  }
  .d-kanban {
    grid-template-columns: repeat(5, 280px);
  }
  .d-page {
    padding: 18px 14px 40px;
  }
}
