/* ==========================================================================
   EPC Business Partner Matrix — Design System
   Design #1: Modern Minimalist (Inter, Navy Background)
   Feature 003 — Phase A Static Mockups
   ========================================================================== */

/* --- CSS Variables (EPC Brand) --- */
:root {
  --color-primary: #1B365D;
  --color-accent: #EEC318;
  --color-text: #FFFFFF;
  --color-text-muted: rgba(255,255,255,0.6);
  --color-text-inverse: #1B365D;
  --bg-canvas: #1B365D;
  --bg-card: rgba(255,255,255,0.06);
  --bg-card-hover: rgba(255,255,255,0.10);
  --bg-card-active: rgba(255,255,255,0.14);
  --bg-accent-subtle: rgba(238,195,24,0.08);
  --border-color: rgba(255,255,255,0.10);
  --border-radius: 2px;
  --font-heading: 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-weight-heading: 700;
  --font-weight-body: 400;
  --sidebar-width: 220px;
  --header-height: 56px;

  /* Heatmap gradient */
  --heat-0: rgba(255,255,255,0.03);
  --heat-1: rgba(238,195,24,0.25);
  --heat-2: rgba(238,195,24,0.55);
  --heat-3: #EEC318;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  font-family: var(--font-body);
  font-weight: var(--font-weight-body);
  background: var(--bg-canvas);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-heading);
  line-height: 1.2;
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.4rem; margin-bottom: 1rem; }
h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Layout: Header --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(27,54,93,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 100;
  gap: 1rem;
}

.header__title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header__nav {
  margin-left: auto;
  display: flex;
  gap: 1rem;
}

.header__nav a {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  transition: color 0.2s;
}

.header__nav a:hover,
.header__nav a.active {
  color: var(--color-accent);
  text-decoration: none;
}

/* --- Layout: Sidebar + Main --- */
.layout {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

.sidebar {
  position: sticky;
  top: var(--header-height);
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar__link {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  border-radius: var(--border-radius);
  transition: background 0.2s, color 0.2s;
  margin-bottom: 0.25rem;
}

.sidebar__link:hover {
  background: var(--bg-card-hover);
  color: var(--color-text);
  text-decoration: none;
}

.sidebar__link.active {
  color: var(--color-accent);
  background: var(--bg-accent-subtle);
}

.main {
  flex: 1;
  padding: 2rem;
  max-width: 1100px;
  min-width: 0;
}

/* --- Section --- */
.section {
  margin-bottom: 3rem;
  opacity: 0;
  animation: fadeIn 0.5s ease forwards;
}

.section:nth-child(1) { animation-delay: 0.05s; }
.section:nth-child(2) { animation-delay: 0.1s; }
.section:nth-child(3) { animation-delay: 0.15s; }
.section:nth-child(4) { animation-delay: 0.2s; }
.section:nth-child(5) { animation-delay: 0.25s; }
.section:nth-child(6) { animation-delay: 0.3s; }
.section:nth-child(7) { animation-delay: 0.35s; }
.section:nth-child(8) { animation-delay: 0.4s; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.section__phase-tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  transition: background 0.2s;
}

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

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

/* --- Stat Card --- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  text-align: center;
}

.stat-card__value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-card__label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Mini Card --- */
.mini-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 0.75rem 1rem;
  transition: background 0.2s;
}

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

/* --- Avatar (initials-based) --- */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.avatar--owner {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.avatar--professional {
  background: var(--color-text);
  color: var(--color-text-inverse);
}

.avatar--both {
  background: linear-gradient(135deg, var(--color-accent) 50%, var(--color-text) 50%);
  color: var(--color-text-inverse);
}

.avatar--large {
  width: 72px;
  height: 72px;
  font-size: 1.4rem;
}

/* --- Teaser Card (Full — Accordion) --- */
.teaser-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.teaser-section {
  border-bottom: 1px solid var(--border-color);
}

.teaser-section:last-child {
  border-bottom: none;
}

.teaser-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  transition: background 0.2s;
  user-select: none;
}

.teaser-section__header:hover {
  background: var(--bg-card-hover);
}

.teaser-section__header::after {
  content: '▸';
  transition: transform 0.2s;
  color: var(--color-text-muted);
}

.teaser-section__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0 1.25rem;
}

.teaser-section.open .teaser-section__header::after {
  transform: rotate(90deg);
}

.teaser-section.open .teaser-section__body {
  max-height: 600px;
  padding: 0 1.25rem 1rem;
}

/* --- Teaser Identity Header --- */
.teaser-identity {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.25rem;
}

.teaser-identity__info {
  flex: 1;
}

.teaser-identity__name {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.teaser-identity__chinese {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.teaser-identity__role {
  font-size: 0.85rem;
  color: var(--color-accent);
}

/* --- Tags / Badges --- */
.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  border-radius: var(--border-radius);
  background: var(--bg-card-hover);
  color: var(--color-text);
  margin: 0.15rem 0.15rem 0.15rem 0;
}

.tag--accent {
  background: rgba(238,195,24,0.2);
  color: var(--color-accent);
}

.tag--serving {
  background: rgba(238,195,24,0.15);
  color: var(--color-accent);
  border: 1px solid rgba(238,195,24,0.3);
}

.tag--cert {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
}

/* --- Phase Indicator --- */
.phase-indicator {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.phase-step {
  width: 3rem;
  height: 4px;
  background: var(--bg-card-hover);
  border-radius: 2px;
  position: relative;
}

.phase-step.active {
  background: var(--color-accent);
}

.phase-step.completed {
  background: rgba(238,195,24,0.5);
}

.phase-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-left: 0.5rem;
}

/* --- Heatmap --- */
.heatmap-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.heatmap {
  display: grid;
  gap: 2px;
  min-width: 700px;
}

.heatmap__header {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  text-align: center;
  padding: 0.25rem;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
}

.heatmap__row-label {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  padding-right: 0.5rem;
  white-space: nowrap;
}

.heatmap__cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  min-height: 32px;
  border-radius: var(--border-radius);
  cursor: default;
  transition: filter 0.15s;
  position: relative;
}

.heatmap__cell:hover {
  filter: brightness(1.15);
}

.heatmap__cell[data-count="0"] { background: var(--heat-0); color: transparent; }
.heatmap__cell[data-count="1"],
.heatmap__cell[data-count="2"] { background: var(--heat-1); color: var(--color-text); }
.heatmap__cell[data-count="3"],
.heatmap__cell[data-count="4"],
.heatmap__cell[data-count="5"] { background: var(--heat-2); color: var(--color-text-inverse); }

/* 6+ uses bright gold with navy text */
.heatmap__cell.heat-high { background: var(--heat-3); color: var(--color-text-inverse); }

/* Tooltip */
.heatmap__cell[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 400;
  border-radius: var(--border-radius);
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

/* --- Table --- */
.data-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 800px;
}

.data-table thead {
  position: sticky;
  top: 0;
}

.data-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  background: rgba(27,54,93,0.95);
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

.data-table tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.data-table .flag {
  color: #e74c3c;
  font-weight: 700;
}

/* --- Completeness Bar --- */
.completeness {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.completeness__bar {
  width: 60px;
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  overflow: hidden;
}

.completeness__fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 2px;
}

.completeness__label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* --- Chart Placeholder --- */
.chart-placeholder {
  position: relative;
  width: 100%;
  border-radius: var(--border-radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.chart-placeholder img {
  width: 100%;
  height: auto;
  display: block;
}

.chart-placeholder__label {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  background: rgba(0,0,0,0.5);
  border-radius: var(--border-radius);
  color: var(--color-text-muted);
}

.chart-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.chart-legend__item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.chart-legend__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* --- Match Pairing --- */
.match-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.match-pair__connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  color: var(--color-accent);
  font-size: 0.75rem;
}

.match-pair__arrow {
  font-size: 1.5rem;
}

.match-pair__reason {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-align: center;
  max-width: 120px;
}

/* --- Serving Capacity Grid --- */
.serving-grid {
  display: grid;
  gap: 2px;
  overflow-x: auto;
}

.serving-grid__cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--border-radius);
  background: var(--bg-card);
  transition: filter 0.15s;
}

.serving-grid__cell.has-data {
  background: rgba(238,195,24,0.2);
  color: var(--color-accent);
}

.serving-grid__cell.multi-gifted {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

/* --- Coverage Indicator --- */
.coverage-list {
  list-style: none;
}

.coverage-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-color);
}

.coverage-item__name {
  flex: 1;
  font-weight: 500;
}

.coverage-item__bar {
  width: 120px;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
}

.coverage-item__fill {
  height: 100%;
  border-radius: 3px;
  background: var(--color-accent);
}

.coverage-item__fill.empty {
  background: rgba(255,255,255,0.1);
}

.coverage-item__pct {
  font-size: 0.85rem;
  font-weight: 700;
  width: 45px;
  text-align: right;
  color: var(--color-accent);
}

.coverage-item__pct.zero {
  color: var(--color-text-muted);
}

/* --- Tabs (Member View) --- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

.tab {
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  user-select: none;
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* --- Labeled Field --- */
.field {
  margin-bottom: 0.75rem;
}

.field__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.2rem;
}

.field__value {
  font-size: 0.9rem;
}

/* --- Business Card (within Teaser) --- */
.business-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.business-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.business-card__name {
  font-weight: 700;
  font-size: 1rem;
}

.business-card__role {
  font-size: 0.75rem;
  color: var(--color-accent);
  padding: 0.15rem 0.5rem;
  border: 1px solid rgba(238,195,24,0.3);
  border-radius: var(--border-radius);
}

/* --- Utility --- */
.text-muted { color: var(--color-text-muted); }
.text-accent { color: var(--color-accent); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .mobile-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: var(--header-height);
    background: rgba(27,54,93,0.95);
    backdrop-filter: blur(8px);
    z-index: 50;
    padding: 0 0.5rem;
  }

  .mobile-tabs a {
    padding: 0.6rem 0.75rem;
    font-size: 0.75rem;
    white-space: nowrap;
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
  }

  .mobile-tabs a.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
  }

  .main {
    padding: 1.25rem;
  }

  .match-pair {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .match-pair__connector {
    flex-direction: row;
    justify-content: center;
  }

  .heatmap { min-width: 500px; }
}

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

/* --- Print --- */
@media print {
  .header, .sidebar, .mobile-tabs {
    display: none !important;
  }

  .layout {
    display: block;
    margin-top: 0;
  }

  .main {
    max-width: 100%;
    padding: 0;
  }

  .section {
    opacity: 1 !important;
    animation: none !important;
    page-break-inside: avoid;
  }

  .teaser-section.open .teaser-section__body,
  .teaser-section__body {
    max-height: none;
    padding: 0 1.25rem 1rem;
  }

  .tab-content {
    display: block !important;
    page-break-before: always;
  }

  .chart-placeholder__label {
    display: none;
  }

  body {
    background: white;
    color: #1B365D;
    font-size: 11pt;
  }

  .card, .stat-card, .mini-card, .teaser-card, .business-card {
    border: 1px solid #ccc;
    background: white;
  }

  .stat-card__value { color: #1B365D; }
  .tag { border: 1px solid #ccc; background: #f5f5f5; color: #1B365D; }
}
