/* ClubicOS Content Performance Dashboard */

:root {
  --ink: #0a0a0a;
  --paper: #f8f6f1;
  --accent: #e63322;
  --muted: #6b6560;
  --line: #d6d0c8;
  --surface: #edeae4;
  --green: #1a7a3a;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Header */
header {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 10;
}
header .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}
.logo { font-family: 'Space Grotesk', sans-serif; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.logo span { color: var(--accent); }
.nav-links { display: flex; gap: 24px; list-style: none; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: color 0.15s; }
.nav-links a:hover, .nav-links a.active { color: var(--ink); }

/* Main layout */
main { max-width: 1200px; margin: 0 auto; padding: 40px 24px 80px; }

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 24px;
}
.kpi-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.kpi-value { font-family: 'Space Grotesk', sans-serif; font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.kpi-value.accent { color: var(--accent); }
.kpi-sub { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-bar label { font-size: 0.85rem; color: var(--muted); font-weight: 500; }
select, input[type="date"] {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  outline: none;
  cursor: pointer;
}
select:focus, input[type="date"]:focus { border-color: var(--accent); }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: white; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead { border-bottom: 2px solid var(--line); }
th {
  padding: 14px 16px;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
th:hover { color: var(--ink); }
th.sort-asc::after { content: ' ↑'; }
th.sort-desc::after { content: ' ↓'; }
td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface); }

.article-title { font-weight: 600; color: var(--ink); max-width: 360px; }
.article-title a { text-decoration: none; color: inherit; }
.article-title a:hover { color: var(--accent); }
.article-slug { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.category-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
}
.category-tag.Hardware { background: #e8f4e8; color: #1a5c2a; border-color: #b8d8b8; }
.category-tag.Mobile { background: #e8f0ff; color: #1a3c8c; border-color: #b8c8f8; }
.category-tag.Sécurité { background: #fff4e8; color: #8c4a1a; border-color: #f8d8b8; }
.category-tag.Périphériques { background: #f4e8f8; color: #6a1a6a; border-color: #d8b8f8; }
.category-tag.IoT { background: #e8f8f4; color: #1a6a5c; border-color: #b8e8d8; }
.category-tag.Réseaux { background: #f8f4e8; color: #6a5c1a; border-color: #e8d8b8; }
.category-tag.Audio { background: #f8e8f0; color: #6a1a3c; border-color: #f8b8d0; }
.num { font-family: 'Space Grotesk', monospace; text-align: right; font-weight: 600; }
.ctr-bar-wrap { display: flex; align-items: center; gap: 8px; }
.ctr-bar { flex: 1; min-width: 60px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.ctr-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.ctr-val { font-size: 0.8rem; font-weight: 600; color: var(--ink); min-width: 40px; }
.revenue { font-family: 'Space Grotesk', monospace; text-align: right; font-weight: 700; color: var(--green); }
.date-cell { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

/* Source badge */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 5px;
  white-space: nowrap;
}
.source-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.source-badge.google  { background: #e8f4e8; color: #1a5c2a; }
.source-badge.google .dot { background: #22a83a; }
.source-badge.social { background: #e8f0ff; color: #1a3c8c; }
.source-badge.social .dot { background: #3864e8; }
.source-badge.direct { background: #fff4e8; color: #8c4a1a; }
.source-badge.direct .dot { background: #e88a1a; }
.source-badge.newsletter { background: #f4e8f8; color: #6a1a6a; }
.source-badge.newsletter .dot { background: #c43ae8; }
.source-badge.other { background: var(--surface); color: var(--muted); }
.source-badge.other .dot { background: var(--muted); }

/* Source distribution widget in KPI card */
.source-dist {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.source-bar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
}
.source-bar-row .slabel { font-weight: 600; min-width: 36px; }
.source-bar-row .bar {
  flex: 1;
  height: 5px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.source-bar-row .bar-fill { height: 100%; border-radius: 3px; }
.source-bar-row .bar-fill.google   { background: #22a83a; }
.source-bar-row .bar-fill.social   { background: #3864e8; }
.source-bar-row .bar-fill.direct   { background: #e88a1a; }
.source-bar-row .bar-fill.newsletter { background: #c43ae8; }
.source-bar-row .bar-fill.other    { background: var(--muted); }
.source-bar-row .scount { color: var(--muted); font-size: 0.68rem; min-width: 20px; text-align: right; }

/* Loading / empty / error states */
.loading { text-align: center; padding: 48px; color: var(--muted); font-size: 0.9rem; }
.empty { text-align: center; padding: 48px; color: var(--muted); }
.error { text-align: center; padding: 48px; color: var(--accent); font-size: 0.9rem; }
.error a { color: var(--ink); font-weight: 600; text-decoration: underline; margin-left: 4px; }

/* Responsive */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 1.4rem; }
  .filter-bar { flex-direction: column; align-items: flex-start; }
}