/* CLASSIC METADATA — Application-level styles
   Supplements: cod-tokens.css → cod-bootstrap-overrides.css → this file
   Load order: cod-tokens.css, cod-bootstrap-overrides.css, [tabulator-cod-overrides.css], app.css */

/* ─────────────────────────────────────────────────────────
   Global typography
   ───────────────────────────────────────────────────────── */
body {
  font-family: var(--cod-font-body);
  color: var(--cod-gray);
}

h1, h2, h3, h4, h5, h6,
.font-heading {
  font-family: var(--cod-font-heading);
}

/* ─────────────────────────────────────────────────────────
   Top Navbar (dashboard, admin)
   ───────────────────────────────────────────────────────── */
.navbar-cod {
  background-color: var(--cod-blue);
  border-bottom: 3px solid var(--cod-gold);
}

.navbar-cod .navbar-brand {
  font-family: var(--cod-font-heading);
  color: var(--cod-gold) !important;
  letter-spacing: 0.1em;
  font-size: 1.25rem;
}

.navbar-cod .nav-link,
.navbar-cod .navbar-text {
  color: rgba(255, 255, 255, 0.85);
}

.navbar-cod .nav-link:hover {
  color: #fff;
}

.navbar-cod .nav-link.active {
  color: var(--cod-gold);
  border-bottom: 2px solid var(--cod-gold);
}

/* ─────────────────────────────────────────────────────────
   Auth pages
   ───────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: var(--cod-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: var(--cod-border-radius);
  border: 0;
  box-shadow: 0 8px 40px rgba(8, 22, 41, 0.45);
}

.auth-card .auth-brand {
  font-family: var(--cod-font-heading);
  color: var(--cod-blue);
  letter-spacing: 0.1em;
  font-size: 1.5rem;
}

.auth-card .auth-subtitle {
  color: var(--cod-gray);
  font-size: 0.9rem;
}

/* ─────────────────────────────────────────────────────────
   Study Editor — Sidebar
   ───────────────────────────────────────────────────────── */
.editor-layout {
  display: flex;
  min-height: 100vh;
}

.study-sidebar {
  width: 264px;
  min-width: 264px;
  background: var(--cod-blue);
  min-height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-app-name {
  font-family: var(--cod-font-heading);
  color: var(--cod-gold);
  letter-spacing: 0.1em;
  font-size: 0.85rem;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.sidebar-study-name {
  font-family: var(--cod-font-heading);
  color: #fff;
  font-size: 1.05rem;
  line-height: 1.3;
  margin-bottom: 0.35rem;
}

.sidebar-completion-text {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.78rem;
}

.sidebar-overall-pct {
  color: var(--cod-gold);
  font-weight: 600;
}

/* Section nav */
.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
}

.sidebar-section-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  border-left: 4px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.sidebar-section-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.sidebar-section-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-left-color: var(--cod-gold);
}

.sidebar-section-label {
  flex: 1;
  font-size: 0.875rem;
}

.sidebar-section-pct {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.45);
}

.sidebar-section-link.active .sidebar-section-pct {
  color: rgba(255, 255, 255, 0.7);
}

/* Progress rings */
.progress-ring-wrap {
  flex-shrink: 0;
}

.progress-ring__track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 2.5;
}

.progress-ring__fill {
  fill: none;
  stroke: var(--cod-gold);
  stroke-width: 2.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.progress-ring__fill.complete {
  stroke: var(--cod-gold-bright);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-exit-link {
  color: rgba(174, 145, 66, 0.75);
  font-size: 0.85rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sidebar-exit-link:hover {
  color: var(--cod-gold);
}

/* ─────────────────────────────────────────────────────────
   Study Editor — Content Area
   ───────────────────────────────────────────────────────── */
.study-content {
  margin-left: 264px;
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  background: var(--cod-warm-white);
  display: flex;
  flex-direction: column;
}

.content-topbar {
  background: #fff;
  border-bottom: 1px solid #dee2e6;
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.content-topbar .breadcrumb {
  margin: 0;
  font-size: 0.85rem;
}

.autosave-indicator {
  font-size: 0.78rem;
  color: var(--cod-gray);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.autosave-indicator .spinner-border {
  width: 0.85rem;
  height: 0.85rem;
  border-width: 2px;
}

.content-scroll {
  flex: 1;
  padding: 1.75rem 2rem;
  width: 100%;
}

.content-bottombar {
  background: #fff;
  border-top: 1px solid #dee2e6;
  position: sticky;
  bottom: 0;
  z-index: 50;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* ─────────────────────────────────────────────────────────
   Field Group Cards
   ───────────────────────────────────────────────────────── */
.field-group-card {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: var(--cod-border-radius);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.field-group-card .group-header {
  background: transparent;
  border-bottom: 1px solid #dee2e6;
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-group-card .group-title {
  font-family: var(--cod-font-heading);
  color: var(--cod-blue);
  margin: 0;
  font-size: 1.1rem;
  font-weight: normal;
}

.field-group-card .group-body {
  padding: 1.25rem;
}

/* Field helpers */
.field-required-marker {
  color: #c53030;
  margin-left: 0.2rem;
}

.field-help {
  font-size: 0.8rem;
  color: #888;
  margin-top: 0.25rem;
}

.field-error {
  font-size: 0.8rem;
  color: #c53030;
  margin-top: 0.25rem;
  display: none;
}

.field-error.visible {
  display: block;
}

/* Distribution field */
.distribution-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.distribution-row input[type="text"] {
  flex: 2;
}

.distribution-row input[type="number"] {
  flex: 1;
  max-width: 100px;
}

.distribution-add-btn {
  font-size: 0.8rem;
  color: var(--cod-blue-bright);
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  margin-top: 0.25rem;
}

/* ─────────────────────────────────────────────────────────
   Cohort / Event List Views
   ───────────────────────────────────────────────────────── */
.item-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.item-list-table th {
  font-size: 0.85rem;
  font-weight: 600;
  color: #111;
}

.item-list-table td {
  vertical-align: middle;
}

.item-status-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-weight: 500;
}

.status-complete {
  background: #d1fae5;
  color: #065f46;
}

.status-in-progress {
  background: #fef3c7;
  color: #92400e;
}

.status-empty {
  background: #f3f4f6;
  color: #6b7280;
}

/* ─────────────────────────────────────────────────────────
   Review & Export
   ───────────────────────────────────────────────────────── */
.completion-hero {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: var(--cod-border-radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.completion-hero-ring {
  flex-shrink: 0;
}

.completion-hero-text .pct-label {
  font-family: var(--cod-font-heading);
  font-size: 2.5rem;
  color: var(--cod-blue);
  line-height: 1;
}

.tier-summary-card {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: var(--cod-border-radius);
  padding: 1.25rem;
  height: 100%;
}

.tier-summary-card .tier-name {
  font-family: var(--cod-font-heading);
  color: var(--cod-blue);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

/* ─────────────────────────────────────────────────────────
   Snackbar
   ───────────────────────────────────────────────────────── */
.snackbar-container {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.snackbar {
  background: var(--cod-gray-dark);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--cod-border-radius);
  font-size: 0.875rem;
  min-width: 240px;
  max-width: 380px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px);
  animation: snackbar-in 0.25s forwards, snackbar-out 0.25s 3.75s forwards;
}

.snackbar.snackbar-success {
  background: var(--cod-green);
}

.snackbar.snackbar-error {
  background: #b91c1c;
}

.snackbar.snackbar-warning {
  background: var(--cod-gold-dark);
}

@keyframes snackbar-in {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes snackbar-out {
  to { opacity: 0; transform: translateY(-6px); }
}

/* ─────────────────────────────────────────────────────────
   Dashboard
   ───────────────────────────────────────────────────────── */
.page-content {
  padding: 2rem 2.5rem;
}

.study-table td {
  vertical-align: middle;
}

.completion-cell {
  min-width: 160px;
}

.completion-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.completion-bar-wrap .progress {
  flex: 1;
  height: 6px;
  border-radius: 4px;
  background: #e5e7eb;
}

.completion-bar-wrap .progress-bar {
  background: var(--cod-gold);
  border-radius: 4px;
}

.completion-bar-wrap .pct-text {
  font-size: 0.78rem;
  color: var(--cod-gray);
  white-space: nowrap;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: #9ca3af;
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state h5 {
  font-family: var(--cod-font-heading);
  color: var(--cod-blue);
  margin-bottom: 0.5rem;
}

/* ─────────────────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .study-sidebar {
    position: relative;
    width: 100%;
    min-width: unset;
    min-height: unset;
  }

  .study-content {
    margin-left: 0;
  }

  .editor-layout {
    flex-direction: column;
  }

  .page-content {
    padding: 1.25rem 1rem;
  }

  .content-scroll {
    padding: 1.25rem 1rem;
  }
}

/* ── Save Failure Banner ───────────────────────────────────────────────────── */
.save-failure-banner {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border-radius: var(--cod-border-radius);
  margin-bottom: 1rem;
  display: none;
}

.save-failure-banner.visible {
  display: block;
}
