/* =============================================================================
   CPF Monthly Content Program — Stylesheet
   Brand colors and layout
   ============================================================================= */

:root {
  --navy: #721F31;
  --navy-dark: #5C1825;
  --gold: #B08642;
  --gold-dark: #8E6B30;
  --ink: #1A1A1A;
  --muted: #666666;
  --surface: #FFFFFF;
  --tint-warm: #F5F2EC;
  --tint-cool: #ECF2F5;
  --line: #DDDDDD;
  --line-strong: #BBBBBB;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.10);

  --pillar-spotlight: #721F31;
  --pillar-youth: #B08642;
  --pillar-cta: #2A6B85;
  --pillar-field: #A0522D;
  --pillar-impact: #6B2E6B;
  --pillar-occasion: #3D5A80;

  --status-planned: #888888;
  --status-progress: #2A6B85;
  --status-review: #B08642;
  --status-program-approval: #6B2E6B;
  --status-approved: #2E7D32;
  --status-published: #1565C0;
  --status-at-risk: #C62828;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-display: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--tint-warm);
}

/* ============================================================================
   Topbar
   ============================================================================ */
.topbar {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.topbar-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 30px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px;
  background: var(--gold);
  border-radius: 8px;
}
.brand-text { line-height: 1.2; }
.brand-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.brand-title em { font-style: italic; color: var(--gold); }
.brand-sub {
  font-size: 11px;
  opacity: 0.7;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.topbar-tabs { display: flex; gap: 4px; }
.tab-btn {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.75);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.tab-btn.active { background: rgba(255,255,255,0.15); color: #fff; }
.topbar-user { display: flex; align-items: center; gap: 14px; }
.user-info { text-align: right; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}
.logout-btn {
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 12px;
  border-radius: 5px;
  transition: background 0.15s;
}
.logout-btn:hover { background: rgba(255,255,255,0.1); }

/* ============================================================================
   Main area + tabs
   ============================================================================ */
.main-area {
  max-width: 1400px;
  margin: 0 auto;
  padding: 30px 24px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.page-head { margin-bottom: 24px; }
.page-head h1 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  color: var(--navy);
  letter-spacing: -0.01em;
}
.page-head p { margin: 0; color: var(--muted); font-size: 13px; max-width: 700px; }

/* ============================================================================
   Toolbar
   ============================================================================ */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.toolbar label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.toolbar input, .toolbar select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
}
.toolbar input:focus, .toolbar select:focus {
  outline: none; border-color: var(--navy);
  box-shadow: 0 0 0 2px rgba(114,31,49,0.10);
}
.toolbar > .btn { margin-left: auto; }

/* ============================================================================
   Buttons
   ============================================================================ */
.btn {
  display: inline-block;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--tint-warm); }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-dark); border-color: var(--navy-dark); }
.btn-danger { background: #fff; color: #C62828; border-color: #FFCDD2; }
.btn-danger:hover { background: #C62828; color: #fff; border-color: #C62828; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ============================================================================
   Stat cards (Overview)
   ============================================================================ */
.month-picker-row {
  margin-bottom: 16px;
}
.month-picker-row label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.month-picker-row select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 13px;
  background: #fff;
  font-family: inherit;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
}
.stat-num {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1;
}
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  font-weight: 600;
  margin-top: 6px;
}
.stat-card.stat-warning .stat-num { color: #C62828; }

.overview-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.overview-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
}
.overview-col h3 {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--navy);
  font-weight: 600;
}
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 40px; gap: 10px; align-items: center; font-size: 12px; }
.bar-fill {
  height: 18px; border-radius: 4px; background: var(--navy); min-width: 4px;
  transition: width 0.3s;
}
.bar-count { font-weight: 700; color: var(--ink); text-align: right; }

/* ============================================================================
   Data tables
   ============================================================================ */
.data-table {
  width: 100%;
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-collapse: separate;
  border-spacing: 0;
  box-shadow: var(--shadow-sm);
}
.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.data-table th {
  background: var(--tint-warm);
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--navy);
  font-weight: 700;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--tint-warm); }
.data-table input, .data-table select {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  font-size: 13px;
  font-family: inherit;
  border-radius: 4px;
}
.data-table input:focus, .data-table select:focus {
  outline: none;
  border-color: var(--navy);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(114,31,49,0.10);
}
.data-table .actions { white-space: nowrap; text-align: right; }
.data-table .actions button { margin-left: 6px; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.pill-active { background: #E8F5E9; color: #2E7D32; }
.pill-inactive { background: #F5F5F5; color: #999; }
.pill-admin { background: #FCE4EC; color: var(--navy); }
.pill-editor { background: #E3F2FD; color: #1565C0; }
.pill-viewer { background: #F5F5F5; color: #666; }

/* ============================================================================
   Post list
   ============================================================================ */
.post-list { display: flex; flex-direction: column; gap: 10px; }
.post-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 14px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 14px;
  align-items: center;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.post-card:hover { box-shadow: var(--shadow-md); }
.post-date {
  font-size: 11px;
  text-align: center;
  font-weight: 600;
  color: var(--muted);
  min-width: 60px;
  padding: 6px 8px;
  background: var(--tint-warm);
  border-radius: 6px;
}
.post-date-day { font-size: 18px; color: var(--navy); display: block; }
.post-body { min-width: 0; }
.post-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.post-meta { display: flex; gap: 12px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.post-meta-tag { background: var(--tint-warm); padding: 2px 8px; border-radius: 10px; }
.post-status {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.post-status-planned { background: #F5F5F5; color: var(--status-planned); }
.post-status-in_progress { background: #E3F2FD; color: var(--status-progress); }
.post-status-ready_review { background: #FFF8E1; color: var(--status-review); }
.post-status-program_focal_approval { background: #F3E5F5; color: var(--status-program-approval); }
.post-status-approved { background: #E8F5E9; color: var(--status-approved); }
.post-status-published { background: #E1F5FE; color: var(--status-published); }
.post-status-at_risk { background: #FFEBEE; color: var(--status-at-risk); }

.post-empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 50px 20px;
  text-align: center;
  color: var(--muted);
}

/* ============================================================================
   Team tab
   ============================================================================ */
.team-cols {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
}
.team-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
}
.team-col h3 {
  margin: 0 0 12px;
  color: var(--navy);
  font-size: 15px;
  font-weight: 600;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.team-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.team-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--tint-warm);
  border-radius: 5px;
  padding: 4px 8px;
}
.team-list input.team-name {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 8px;
  font-size: 13px;
  font-family: inherit;
  border-radius: 4px;
  min-width: 0;
}
.team-list input.team-name:focus {
  outline: none;
  border-color: var(--navy);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(114,31,49,0.10);
}
.add-row { display: flex; gap: 6px; }
.add-row input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
  font-family: inherit;
  min-width: 0;
}

/* ============================================================================
   Modal
   ============================================================================ */
[hidden] { display: none !important; }
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 600; color: var(--navy); }
.modal-close {
  background: transparent;
  border: 0;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.modal-body { padding: 22px 24px; }
.modal-foot {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 4px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 2px rgba(114,31,49,0.10);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============================================================================
   Toast
   ============================================================================ */
.toast-box { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px;
  font-size: 13px; box-shadow: var(--shadow-md);
  animation: slideIn 0.2s, fadeOut 0.3s ease 2.5s forwards;
}
.toast.toast-error { background: #C62828; }
.toast.toast-success { background: #2E7D32; }
@keyframes slideIn { from { transform: translateX(50px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(10px); } }

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 1000px) {
  .topbar-inner { grid-template-columns: 1fr; gap: 14px; }
  .topbar-tabs { overflow-x: auto; }
  .overview-cols, .team-cols { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .field-row { grid-template-columns: 1fr; }
  .post-card { grid-template-columns: auto 1fr; }
  .post-card .post-status { grid-column: 2; }
}

/* ============================================================================
   Misc utilities
   ============================================================================ */
.hidden { display: none !important; }
[data-needs-edit] { display: inline-block; }
body.role-viewer [data-needs-edit] { display: none !important; }
