/**
 * PatriotCompass Admin Console - Events Rebuild Styles
 * Calendar grid, event cards, backlog, batch progress, audit trail, model compare
 * Responsive: 1024px+ screens
 */

/* === COLOR TOKENS === */
:root {
  --cal-published: #10b981;
  --cal-approved-for-publish: #3b82f6;
  --cal-pending-review: #f59e0b;
  --cal-classification-approved: #93c5fd;
  --cal-awaiting-review: #94a3b8;
  --cal-empty: #f1f5f9;
  --cal-enhancement-failed: #ef4444;
  --cal-enhancing: #8b5cf6;
  --tier-free: #10b981;
  --tier-free-bg: #d1fae5;
  --tier-premium: #d97706;
  --tier-premium-bg: #fef3c7;
  --status-published-bg: #d1fae5;
  --status-published-text: #065f46;
  --status-approved-publish-bg: #dbeafe;
  --status-approved-publish-text: #1e40af;
  --status-pending-review-bg: #fef3c7;
  --status-pending-review-text: #92400e;
  --status-classification-approved-bg: #e0f2fe;
  --status-classification-approved-text: #075985;
  --status-awaiting-review-bg: #f1f5f9;
  --status-awaiting-review-text: #475569;
  --status-rejected-bg: #fee2e2;
  --status-rejected-text: #991b1b;
  --status-enhancing-bg: #ede9fe;
  --status-enhancing-text: #5b21b6;
  --status-failed-bg: #fee2e2;
  --status-failed-text: #991b1b;
  --status-removed-bg: #f1f5f9;
  --status-removed-text: #64748b;
  --status-insufficient-context-bg: #fef3c7;
  --status-insufficient-context-text: #92400e;
  --status-factcheck-review-bg: #fee2e2;
  --status-factcheck-review-text: #991b1b;
}

/* === CALENDAR GRID === */
.er-calendar {
  display: grid;
  grid-template-columns: auto repeat(31, 1fr);
  gap: 2px;
  background: var(--slate-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--slate-200);
}
.er-calendar-month-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-700);
  background: var(--slate-50);
  min-width: 36px;
}
.er-calendar-day-header {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--slate-500);
  background: var(--slate-50);
  padding: 2px;
}
.er-calendar-cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 20px;
  min-height: 20px;
  background: var(--cal-empty);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
  border: 1px solid transparent;
}
.er-calendar-cell:hover {
  transform: scale(1.3);
  z-index: 2;
  box-shadow: var(--shadow-md);
  border-color: var(--slate-400);
}
.er-calendar-cell.selected {
  border: 2px solid var(--patriot-blue);
  box-shadow: var(--shadow-focus-blue);
}
.er-calendar-cell.inactive { background: transparent; cursor: default; pointer-events: none; }
.er-calendar-cell[data-status="published"] { background: var(--cal-published); }
.er-calendar-cell[data-status="approved_for_publish"] { background: var(--cal-approved-for-publish); }
.er-calendar-cell[data-status="pending_publish_review"] { background: var(--cal-pending-review); }
.er-calendar-cell[data-status="classification_approved"] { background: var(--cal-classification-approved); }
.er-calendar-cell[data-status="awaiting_classification_review"] { background: var(--cal-awaiting-review); }
.er-calendar-cell[data-status="enhancement_failed"] { background: var(--cal-enhancement-failed); }
.er-calendar-cell[data-status="enhancing"] { background: var(--cal-enhancing); }

.er-calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--slate-50);
  border-radius: var(--radius-md);
}
.er-calendar-legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--slate-600); }
.er-calendar-legend-swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.1); }

/* === EVENT CARDS === */
.er-event-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  transition: var(--transition-all);
  overflow: hidden;
}
.er-event-card:hover { border-color: var(--slate-300); box-shadow: var(--shadow-sm); }
.er-event-card.expanded { border-color: var(--patriot-blue); box-shadow: var(--shadow-md); }

.er-event-card-collapsed {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
.er-event-score {
  font-size: 12px;
  font-weight: 700;
  color: var(--patriot-blue);
  background: #dbeafe;
  padding: 3px 7px;
  border-radius: var(--radius-full);
  min-width: 32px;
  text-align: center;
  flex-shrink: 0;
}
.er-event-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status chips */
.er-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.4;
}
.er-status-chip.published { background: var(--status-published-bg); color: var(--status-published-text); }
.er-status-chip.approved_for_publish { background: var(--status-approved-publish-bg); color: var(--status-approved-publish-text); }
.er-status-chip.pending_publish_review { background: var(--status-pending-review-bg); color: var(--status-pending-review-text); }
.er-status-chip.classification_approved { background: var(--status-classification-approved-bg); color: var(--status-classification-approved-text); }
.er-status-chip.awaiting_classification_review { background: var(--status-awaiting-review-bg); color: var(--status-awaiting-review-text); }
.er-status-chip.classification_rejected { background: var(--status-rejected-bg); color: var(--status-rejected-text); }
.er-status-chip.enhancing { background: var(--status-enhancing-bg); color: var(--status-enhancing-text); }
.er-status-chip.enhancement_failed { background: var(--status-failed-bg); color: var(--status-failed-text); }
.er-status-chip.removed { background: var(--status-removed-bg); color: var(--status-removed-text); }
.er-status-chip.insufficient_american_context { background: var(--status-insufficient-context-bg); color: var(--status-insufficient-context-text); }
.er-status-chip.pending_factcheck_review { background: var(--status-factcheck-review-bg); color: var(--status-factcheck-review-text); }

/* Tier badges */
.er-tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.er-tier-badge.free { background: var(--tier-free-bg); color: var(--tier-free); }
.er-tier-badge.premium { background: var(--tier-premium-bg); color: var(--tier-premium); }

/* Expanded state */
.er-event-card-expanded {
  display: none;
  padding: 16px;
  border-top: 1px solid var(--slate-100);
}
.er-event-card.expanded .er-event-card-expanded { display: block; }
.er-event-description { font-size: 13px; color: var(--slate-700); line-height: 1.6; margin-bottom: 12px; }
.er-event-field { margin-bottom: 12px; }
.er-event-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.er-event-field-value {
  font-size: 13px;
  color: var(--slate-700);
  line-height: 1.5;
  padding: 8px 12px;
  background: var(--slate-50);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--patriot-blue);
}
.er-event-model-info {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--slate-500);
  padding: 8px 12px;
  background: var(--slate-50);
  border-radius: var(--radius-sm);
  margin-top: 12px;
}
.er-event-model-info span { display: inline-flex; align-items: center; gap: 4px; }
.er-event-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--slate-100);
}
.er-event-actions .btn { font-size: 12px; padding: 6px 12px; }
.er-event-actions .btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* === BACKLOG PANEL === */
.er-backlog {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  background: #ffffff;
  margin-top: 24px;
  overflow: hidden;
}
.er-backlog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--slate-50);
  border-bottom: 1px solid var(--slate-200);
  cursor: pointer;
  user-select: none;
  transition: background var(--duration-fast) var(--ease-out);
}
.er-backlog-header:hover { background: var(--slate-100); }
.er-backlog-header h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--slate-800);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.er-backlog-count {
  font-size: 11px;
  font-weight: 600;
  background: var(--patriot-blue);
  color: white;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.er-backlog-toggle {
  font-size: 14px;
  color: var(--slate-400);
  transition: transform var(--duration-base) var(--ease-out);
}
.er-backlog.open .er-backlog-toggle { transform: rotate(180deg); }
.er-backlog-body { display: none; max-height: 400px; overflow-y: auto; }
.er-backlog.open .er-backlog-body { display: block; }
.er-backlog-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--slate-100);
}
.er-backlog-filter-chip {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--slate-300);
  background: white;
  cursor: pointer;
  transition: var(--transition-colors);
}
.er-backlog-filter-chip:hover { border-color: var(--patriot-blue); color: var(--patriot-blue); }
.er-backlog-filter-chip.active { background: var(--patriot-blue); color: white; border-color: var(--patriot-blue); }
.er-backlog-group { border-bottom: 1px solid var(--slate-100); }
.er-backlog-group:last-child { border-bottom: none; }
.er-backlog-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--slate-50);
}
.er-backlog-group-date { font-size: 13px; font-weight: 600; color: var(--slate-700); }
.er-backlog-group-count { font-size: 11px; color: var(--slate-500); }
.er-backlog-group-link { font-size: 11px; color: var(--patriot-blue); text-decoration: none; font-weight: 500; }
.er-backlog-group-link:hover { text-decoration: underline; }
.er-backlog-group-events { padding: 4px 16px 8px; }
.er-backlog-event-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 12px; color: var(--slate-600); }

/* === BATCH PROGRESS BAR === */
.er-batch-progress {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.er-batch-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.er-batch-progress-label { font-size: 13px; font-weight: 600; color: var(--slate-700); }
.er-batch-progress-stats { font-size: 12px; color: var(--slate-500); }
.er-batch-progress-bar {
  position: relative;
  height: 8px;
  background: var(--slate-100);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.er-batch-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--patriot-blue) 0%, var(--info-blue) 100%);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-out);
}
.er-batch-progress-fill.failed { background: linear-gradient(90deg, var(--error-red) 0%, var(--error-red-light) 100%); }
.er-batch-progress-fill.paused { background: linear-gradient(90deg, var(--warning-amber) 0%, var(--warning-amber-light) 100%); }
.er-batch-progress-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.er-batch-progress-eta { font-size: 11px; color: var(--slate-500); }
.er-batch-progress-controls { display: flex; gap: 6px; }
.er-batch-progress-controls .btn { font-size: 11px; padding: 4px 10px; }

/* === AUDIT TRAIL === */
.er-audit-trail {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--slate-100);
}
.er-audit-trail-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.er-audit-list { list-style: none; padding: 0; margin: 0; position: relative; }
.er-audit-list::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--slate-200);
  border-radius: 1px;
}
.er-audit-item {
  position: relative;
  padding-left: 20px;
  padding-bottom: 10px;
  font-size: 12px;
  line-height: 1.4;
}
.er-audit-item:last-child { padding-bottom: 0; }
.er-audit-item::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--slate-300);
  border: 2px solid white;
}
.er-audit-item.recent::before { background: var(--patriot-blue); }
.er-audit-timestamp { font-size: 10px; color: var(--slate-400); display: block; margin-bottom: 2px; }
.er-audit-action { color: var(--slate-700); font-weight: 500; }
.er-audit-actor { color: var(--slate-500); font-weight: 400; }
.er-audit-transition { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; color: var(--slate-500); margin-top: 2px; }
.er-audit-transition-arrow { color: var(--slate-400); }

/* === MODEL COMPARE VIEW === */
.er-compare-view { display: grid; gap: 16px; margin-top: 16px; }
.er-compare-view.cols-2 { grid-template-columns: 1fr 1fr; }
.er-compare-view.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.er-compare-view.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.er-compare-variant {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.er-compare-variant.promoted { border-color: var(--success-green); box-shadow: 0 0 0 2px rgba(16,185,129,0.15); }
.er-compare-variant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--slate-50);
  border-bottom: 1px solid var(--slate-100);
}
.er-compare-variant-model { font-size: 12px; font-weight: 600; color: var(--slate-700); }
.er-compare-variant-cost { font-size: 11px; color: var(--slate-500); }
.er-compare-variant-body { padding: 12px; flex: 1; font-size: 12px; color: var(--slate-700); line-height: 1.5; }
.er-compare-variant-field { margin-bottom: 10px; }
.er-compare-variant-field-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 3px;
}
.er-compare-variant-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--slate-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.er-compare-variant-tokens { font-size: 10px; color: var(--slate-400); }
.er-compare-promote-btn {
  font-size: 11px;
  padding: 4px 10px;
  background: var(--success-green);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition-colors);
}
.er-compare-promote-btn:hover { background: var(--success-green-dark); }
.er-compare-promote-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* === DATE NAVIGATION (MM-DD picker) === */
.er-date-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}
.er-date-nav select {
  padding: 8px 12px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--slate-700);
  background: white;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out);
}
.er-date-nav select:hover { border-color: var(--patriot-blue); }
.er-date-nav select:focus { outline: none; border-color: var(--patriot-blue); box-shadow: var(--shadow-focus-blue); }
.er-date-nav-separator { font-size: 16px; font-weight: 700; color: var(--slate-400); }

/* === UNIFIED DAY VIEW === */
.er-day-view { display: flex; flex-direction: column; gap: 8px; }
.er-day-view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.er-day-view-title { font-size: 16px; font-weight: 700; color: var(--slate-800); }
.er-day-view-count { font-size: 12px; color: var(--slate-500); }

/* === MANUAL ADD FORM === */
.er-manual-form {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}
.er-manual-form-title { font-size: 14px; font-weight: 700; color: var(--slate-800); margin-bottom: 12px; }
.er-manual-form .form-group { margin-bottom: 12px; }
.er-manual-form label { display: block; font-size: 12px; font-weight: 600; color: var(--slate-600); margin-bottom: 4px; }
.er-manual-form input,
.er-manual-form textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--slate-700);
  font-family: inherit;
  transition: border-color var(--duration-fast) var(--ease-out);
}
.er-manual-form input:focus,
.er-manual-form textarea:focus { outline: none; border-color: var(--patriot-blue); box-shadow: var(--shadow-focus-blue); }
.er-manual-form textarea { resize: vertical; min-height: 80px; }

/* === RESPONSIVE === */
@media (min-width: 1024px) {
  .er-calendar { grid-template-columns: auto repeat(31, minmax(18px, 1fr)); }
}
@media (max-width: 1279px) {
  .er-compare-view.cols-4 { grid-template-columns: 1fr 1fr; }
  .er-compare-view.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1023px) {
  .er-calendar { grid-template-columns: auto repeat(31, minmax(14px, 1fr)); gap: 1px; }
  .er-calendar-month-label { font-size: 9px; padding: 2px 4px; min-width: 28px; }
  .er-compare-view.cols-2,
  .er-compare-view.cols-3,
  .er-compare-view.cols-4 { grid-template-columns: 1fr; }
  .er-batch-progress-footer { flex-direction: column; gap: 8px; align-items: flex-start; }
}
