/* ==========================================================================
   The Nairobi Caucus Portal — Design System
   Grounded in institutional civic identity: paper-toned, hairline-ruled,
   restrained accent use. Loaded AFTER bootstrap.min.css — overrides
   Bootstrap's own CSS custom properties rather than fighting specificity.
   ========================================================================== */

/* ---- Fonts (self-hosted, no CDN dependency) ---- */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('/assets/fonts/fraunces/fraunces-latin-600-normal.woff2') format('woff2-variations'),
       url('/assets/fonts/fraunces/fraunces-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/assets/fonts/fraunces/fraunces-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/assets/fonts/fraunces/fraunces-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/assets/fonts/fraunces/fraunces-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/assets/fonts/fraunces/fraunces-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Fraunces'; font-style: italic; font-weight: 500; font-display: swap;
  src: url('/assets/fonts/fraunces/fraunces-latin-500-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Public Sans'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/assets/fonts/public-sans/public-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Public Sans'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/assets/fonts/public-sans/public-sans-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Public Sans'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/assets/fonts/public-sans/public-sans-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Public Sans'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/assets/fonts/public-sans/public-sans-latin-700-normal.woff2') format('woff2');
}

/* =========================================================
   CAUCUS PORTAL — DESIGN TOKENS
   Main Brand Colors:
   Navy:       #2A3954
   Light Gray: #E6EAED
   Red Accent: #E8464D
========================================================= */

:root {

  /* ---- Brand Colors ---- */

  /* Primary Navy */
  --cc-navy: #2A3954;
  --cc-navy-deep: #1D293D;
  --cc-navy-soft: #42516B;
  --cc-navy-light: #64718A;

  /* Neutral / Light */
  --cc-gray: #E6EAED;
  --cc-gray-light: #F4F6F8;
  --cc-gray-soft: #EEF1F3;
  --cc-gray-deep: #C9D0D6;

  /* Accent Red */
  --cc-red: #E8464D;
  --cc-red-hover: #D6383F;
  --cc-red-soft: #FCE9EA;
  --cc-red-dark: #B92F36;

  /* ---- Semantic Colors ---- */

  /* Text */
  --cc-ink: #2A3954;
  --cc-ink-soft: #536176;
  --cc-ink-faint: #8A96A3;

  /* Backgrounds */
  --cc-paper: #F4F6F8;
  --cc-paper-raised: #FFFFFF;
  --cc-paper-muted: #E6EAED;

  /* Borders */
  --cc-line: #D4DADF;
  --cc-line-soft: #E6EAED;

  /* Status Colors */
  --cc-success: #2F6B52;
  --cc-success-soft: #E8F3ED;

  --cc-warning: #C58B2A;
  --cc-warning-soft: #FFF4DD;

  --cc-danger: #E8464D;
  --cc-danger-soft: #FCE9EA;

  --cc-info: #3F6FA3;
  --cc-info-soft: #EAF1F8;


  /* =========================================================
     BOOTSTRAP THEME OVERRIDES
  ========================================================= */

  --bs-body-font-family:
    'Public Sans',
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  /* Body */
  --bs-body-bg: var(--cc-paper);
  --bs-body-color: var(--cc-ink);

  /* Borders */
  --bs-border-color: var(--cc-line);

  /* Primary */
  --bs-primary: var(--cc-navy);
  --bs-primary-rgb: 42, 57, 84;

  /* Secondary */
  --bs-secondary: var(--cc-navy-soft);
  --bs-secondary-rgb: 66, 81, 107;

  /* Success */
  --bs-success: var(--cc-success);
  --bs-success-rgb: 47, 107, 82;

  /* Danger */
  --bs-danger: var(--cc-red);
  --bs-danger-rgb: 232, 70, 77;

  /* Warning */
  --bs-warning: var(--cc-warning);
  --bs-warning-rgb: 197, 139, 42;

  /* Info */
  --bs-info: var(--cc-info);
  --bs-info-rgb: 63, 111, 163;

  /* Links */
  --bs-link-color: var(--cc-navy);
  --bs-link-color-rgb: 42, 57, 84;

  --bs-link-hover-color: var(--cc-red);
  --bs-link-hover-color-rgb: 232, 70, 77;

  /* Typography */
  --bs-heading-color: var(--cc-navy);

  /* Border Radius */
  --bs-border-radius: 0.375rem;
  --bs-border-radius-sm: 0.25rem;
  --bs-border-radius-lg: 0.5rem;

}

body { letter-spacing: 0.01em; }

h1, h2, h3, h4, h5, h6, .cc-display {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  color: var(--cc-ink);
  letter-spacing: -0.01em;
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Buttons: ink primary, gold reserved for one accent per screen ---- */
.btn { font-weight: 600; border-radius: var(--bs-border-radius); }
.btn-primary {
  background-color: var(--cc-ink); border-color: var(--cc-ink); color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: #0d1830; border-color: #0d1830; color: #fff;
}
.btn-outline-primary {
  color: var(--cc-ink); border-color: var(--cc-ink);
}
.btn-outline-primary:hover {
  background-color: var(--cc-ink); border-color: var(--cc-ink);
}
.btn-outline-danger { color: var(--cc-clay); border-color: var(--cc-clay); }
.btn-outline-danger:hover { background-color: var(--cc-clay); border-color: var(--cc-clay); }
.btn-outline-success { color: var(--cc-forest); border-color: var(--cc-forest); }
.btn-outline-success:hover { background-color: var(--cc-forest); border-color: var(--cc-forest); }

/* ---- Cards: hairline border, no soft-shadow-on-everything ---- */
.card {
  border: 1px solid var(--cc-line);
  border-radius: 0.5rem;
  box-shadow: none;
}
.shadow-sm { box-shadow: 0 1px 2px rgba(20, 33, 61, 0.06) !important; }

/* ---- Stat cards: the number carries the weight, not a colored badge ---- */
.cc-stat {
  background: var(--cc-paper-raised);
  border: 1px solid var(--cc-line);
  border-radius: 0.5rem;
  padding: 1.25rem 1.5rem;
  position: relative;
}
.cc-stat-icon {
  position: absolute; top: 1.25rem; right: 1.25rem;
  color: var(--cc-line);
  font-size: 1.5rem;
}
.cc-stat-label {
  font-family: 'Public Sans', sans-serif;
  font-size: 0.8125rem;
  color: var(--cc-ink-soft);
  margin-bottom: 0.375rem;
  font-weight: 600;
}
.cc-stat-value {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 2.25rem;
  line-height: 1;
  color: var(--cc-ink);
}
.cc-stat-value.cc-accent { color: var(--cc-gold-deep); }
.cc-stat-value.cc-warn { color: var(--cc-clay); }

/* ---- KPI color variants — each stat card gets a purposeful accent, not a uniform look ---- */
.cc-stat { border-left: 3px solid var(--cc-line); }
.cc-stat--ink { border-left-color: var(--cc-ink); }
.cc-stat--ink .cc-stat-icon { color: var(--cc-ink); opacity: 0.35; }
.cc-stat--gold { border-left-color: var(--cc-gold); }
.cc-stat--gold .cc-stat-icon { color: var(--cc-gold); opacity: 0.5; }
.cc-stat--forest { border-left-color: var(--cc-forest); }
.cc-stat--forest .cc-stat-icon { color: var(--cc-forest); opacity: 0.45; }
.cc-stat--steel { border-left-color: var(--cc-steel); }
.cc-stat--steel .cc-stat-icon { color: var(--cc-steel); opacity: 0.45; }
.cc-stat--clay { border-left-color: var(--cc-clay); }
.cc-stat--clay .cc-stat-icon { color: var(--cc-clay); opacity: 0.45; }

/* ---- Audit log event-type badges ---- */
.cc-badge-clay { background: #F7E9E9; color: #8A3235; border: 1px solid #E3B8B9; }
.cc-badge-forest { background: #E7EFEB; color: var(--cc-forest); border: 1px solid #BFD5C8; }
.cc-badge-gold { background: #FBF3E7; color: var(--cc-gold-deep); border: 1px solid #E8D3AE; }
.cc-badge-steel { background: #E8EDF4; color: var(--cc-steel); border: 1px solid #C0CEE0; }
.cc-badge-ink { background: var(--cc-paper); color: var(--cc-ink-soft); border: 1px solid var(--cc-line); }
.cc-badge-clay, .cc-badge-forest, .cc-badge-gold, .cc-badge-steel, .cc-badge-ink {
    font-size: 0.7rem; font-weight: 600; padding: 0.25rem 0.55rem; border-radius: 0.3rem;
}

/* ---- Document Library view modes ---- */
.cc-view-toggle .btn { padding: 0.3rem 0.55rem; }
.cc-view-toggle .btn.active { background: var(--cc-ink); border-color: var(--cc-ink); color: #fff; }

.cc-doclist-large { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.cc-doclist-small { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.75rem; }
.cc-doc-tile {
    background: var(--cc-paper-raised); border: 1px solid var(--cc-line); border-radius: 0.5rem;
    padding: 1.25rem 0.75rem; text-align: center; text-decoration: none; color: var(--cc-ink);
    display: block; transition: 0.15s;
}
.cc-doc-tile:hover { border-color: var(--cc-gold); box-shadow: 0 2px 10px rgba(20,33,61,0.08); text-decoration: none; }
.cc-doc-tile i { font-size: 2.25rem; color: var(--cc-gold-deep); display: block; margin-bottom: 0.5rem; }
.cc-doclist-small .cc-doc-tile { padding: 0.75rem 0.5rem; }
.cc-doclist-small .cc-doc-tile i { font-size: 1.5rem; }
.cc-doc-tile-title { font-size: 0.8125rem; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cc-doclist-small .cc-doc-tile-title { font-size: 0.7rem; }
.cc-doc-tile-meta { font-size: 0.7rem; color: var(--cc-ink-faint); margin-top: 0.25rem; }

/* ---- Gallery: modern interactive polish ---- */
.cc-gallery-trigger { transition: transform 0.2s ease; }
.cc-photo-card { transition: transform 0.18s ease, box-shadow 0.18s ease; }
.cc-photo-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(20,33,61,0.12); }
.cc-lightbox-stage img { animation: cc-lightbox-in 0.2s ease; }
@keyframes cc-lightbox-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
.cc-lightbox { animation: cc-fade-in 0.15s ease; }
@keyframes cc-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- App shell: sidebar + content, replacing a bare top navbar ---- */
.cc-shell { display: flex; min-height: 100vh; }
.cc-sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--cc-paper-raised);
  border-right: 1px solid var(--cc-line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.cc-sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  display: flex; align-items: center; gap: 0.625rem;
}
.cc-sidebar-brand img { height: 28px; width: auto; }
.cc-sidebar-brand span {
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.0625rem; color: var(--cc-ink);
}
.cc-nav { padding: 0.5rem 0.75rem; flex: 1; }
.cc-nav-section {
  font-size: 0.6875rem; font-weight: 700; color: var(--cc-ink-faint);
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 1rem 0.75rem 0.375rem;
}
.cc-nav-link {
  display: flex; align-items: center; gap: 0.625rem;
  padding: 0.5rem 0.75rem; border-radius: 0.375rem;
  color: var(--cc-ink-soft); font-weight: 500; font-size: 0.9rem;
  border-left: 3px solid transparent;
}
.cc-nav-link:hover { background: var(--cc-paper); color: var(--cc-ink); text-decoration: none; }
.cc-nav-link.active {
  background: var(--cc-paper);
  color: var(--cc-ink);
  border-left-color: var(--cc-gold);
  font-weight: 600;
}
.cc-nav-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; color: var(--cc-ink-faint); }
.cc-nav-link.active i, .cc-nav-link:hover i { color: var(--cc-gold-deep); }

.cc-sidebar-foot {
  padding: 1rem 1.25rem; border-top: 1px solid var(--cc-line-soft);
  font-size: 0.8125rem;
}
.cc-user-name { font-weight: 600; color: var(--cc-ink); }
.cc-user-role { color: var(--cc-ink-faint); font-size: 0.75rem; }

.cc-main { flex: 1; min-width: 0; }
.cc-topbar {
  background: var(--cc-paper-raised);
  border-bottom: 1px solid var(--cc-line);
  padding: 0.875rem 1.75rem;
  display: flex; align-items: center; justify-content: space-between;
}
.cc-bell { position: relative; color: var(--cc-ink-soft); font-size: 1.2rem; }
.cc-bell .badge {
  position: absolute; top: -6px; right: -8px; font-size: 0.6rem;
  background: var(--cc-clay); border: 2px solid var(--cc-paper-raised);
}
.cc-content { padding: 1.75rem; }

/* ---- Auth pages ---- */
.cc-auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--cc-paper);
  background-image: radial-gradient(circle at 15% 15%, rgba(176,141,87,0.06), transparent 45%),
                     radial-gradient(circle at 85% 85%, rgba(31,71,57,0.06), transparent 45%);
}
.cc-auth-card {
  max-width: 440px; width: 100%; background: var(--cc-paper-raised);
  border: 1px solid var(--cc-line); border-radius: 0.75rem;
  padding: 2.5rem; box-shadow: 0 4px 24px rgba(20,33,61,0.06);
}
.cc-auth-brand { text-align: center; margin-bottom: 1.75rem; }
.cc-auth-brand img { height: 40px; width: auto; }

/* ---- Empty states: an invitation to act, not a dead end ---- */
.cc-empty {
  text-align: center; padding: 3rem 1.5rem; color: var(--cc-ink-faint);
}
.cc-empty i { font-size: 2rem; color: var(--cc-line); display: block; margin-bottom: 0.75rem; }
.cc-empty-inline { padding: 1.25rem; color: var(--cc-ink-faint); font-size: 0.875rem; }

/* ---- Activity feed: compact rows, not a sparse full-width table ---- */
.cc-activity-row {
  display: flex; align-items: baseline; gap: 0.75rem;
  padding: 0.625rem 0; border-bottom: 1px solid var(--cc-line-soft);
  font-size: 0.875rem;
}
.cc-activity-row:last-child { border-bottom: none; }
.cc-activity-time { color: var(--cc-ink-faint); font-size: 0.75rem; white-space: nowrap; width: 7.5rem; flex-shrink: 0; }
.cc-activity-actor { font-weight: 600; width: 9rem; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-activity-desc { color: var(--cc-ink-soft); flex: 1; min-width: 0; }

/* ---- Tables: hairlines, not zebra-stripe defaults ---- */
.table { --bs-table-border-color: var(--cc-line-soft); }
.table thead th {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--cc-ink-faint); font-weight: 700; border-bottom-width: 1px;
}

/* ---- Badges ---- */
.badge.bg-light { background-color: var(--cc-paper) !important; color: var(--cc-ink-soft) !important; border: 1px solid var(--cc-line); }

/* ---- Forms ---- */
.form-control, .form-select {
  border-color: var(--cc-line); border-radius: 0.375rem;
  background-color: var(--cc-paper-raised);
}
.form-control:focus, .form-select:focus {
  background-color: var(--cc-paper-raised);
  border-color: var(--cc-gold); box-shadow: 0 0 0 0.2rem rgba(176, 141, 87, 0.15);
}
.form-control:disabled { background-color: var(--cc-paper); }
.form-label { font-weight: 600; font-size: 0.875rem; color: var(--cc-ink-soft); }

@media (max-width: 767.98px) {
  .cc-sidebar { position: fixed; left: -260px; z-index: 1040; transition: left 0.2s ease; }
  .cc-sidebar.cc-open { left: 0; }
  .cc-content { padding: 1.25rem; }
}
