/* ===================================================================
   First Principles Platform — Business Blue Theme
   =================================================================== */

/* --- Foundations --- */
:root {
  --fp-blue-900: #0a1628;
  --fp-blue-800: #0f2440;
  --fp-blue-700: #163560;
  --fp-blue-600: #1a4480;
  --fp-blue-500: #2563eb;
  --fp-blue-400: #4a8af5;
  --fp-blue-300: #93bbfd;
  --fp-blue-200: #bdd4fe;
  --fp-blue-100: #dbeafe;
  --fp-blue-50:  #eff6ff;
  --fp-slate-700: #334155;
  --fp-slate-500: #64748b;
  --fp-slate-300: #cbd5e1;
  --fp-slate-200: #e2e8f0;
  --fp-slate-100: #f1f5f9;
  --fp-slate-50:  #f8fafc;
  --fp-green:  #059669;
  --fp-red:    #dc2626;
  --fp-amber:  #d97706;
  --fp-purple: #7c3aed;
  --fp-radius: 0.5rem;
  --fp-shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --fp-shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1);
  --fp-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
}

html {
  font-size: 15px;
}

@media (min-width: 768px) {
  html { font-size: 16px; }
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--fp-slate-100);
  color: var(--fp-slate-700);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Navbar --- */
.fp-navbar {
  background: linear-gradient(135deg, var(--fp-blue-800) 0%, var(--fp-blue-600) 100%);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  box-shadow: var(--fp-shadow-md);
  padding: 0.5rem 0;
}

.fp-navbar .navbar-brand {
  color: #fff;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.fp-navbar .navbar-brand:hover {
  color: var(--fp-blue-200);
}

.fp-brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fp-blue-300);
}

.fp-nav-link {
  color: rgba(255,255,255,0.8) !important;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem !important;
  border-radius: var(--fp-radius);
  transition: all 0.15s ease;
}

.fp-nav-link:hover, .fp-nav-link:focus {
  color: #fff !important;
  background: rgba(255,255,255,0.1);
}

.fp-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--fp-blue-500);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
}

/* --- Footer --- */
.fp-footer {
  border-top: 1px solid var(--fp-slate-200);
  background: #fff;
}

/* --- Cards --- */
.card {
  border: 1px solid var(--fp-slate-200);
  border-radius: var(--fp-radius);
  box-shadow: var(--fp-shadow-sm);
  background: #fff;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--fp-shadow);
}

.card-header {
  background: var(--fp-slate-50);
  border-bottom: 1px solid var(--fp-slate-200);
  font-weight: 600;
  padding: 0.75rem 1rem;
}

/* --- Buttons --- */
.btn {
  font-weight: 500;
  border-radius: var(--fp-radius);
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--fp-blue-500);
  border-color: var(--fp-blue-500);
}

.btn-primary:hover {
  background: var(--fp-blue-600);
  border-color: var(--fp-blue-600);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-outline-primary {
  color: var(--fp-blue-500);
  border-color: var(--fp-blue-500);
}

.btn-outline-primary:hover {
  background: var(--fp-blue-500);
  border-color: var(--fp-blue-500);
}

/* --- Forms --- */
.form-control, .form-select {
  border-radius: var(--fp-radius);
  border-color: var(--fp-slate-300);
  padding: 0.5rem 0.75rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--fp-blue-400);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-label {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--fp-slate-700);
}

textarea.form-control {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.875rem;
}

/* --- Status Badges --- */
.badge {
  font-weight: 500;
  font-size: 0.75rem;
  padding: 0.35em 0.65em;
  border-radius: 9999px;
}

.badge-draft       { background: var(--fp-slate-500); color: #fff; }
.badge-review      { background: var(--fp-amber); color: #fff; }
.badge-published   { background: var(--fp-green); color: #fff; }
.badge-superseded  { background: var(--fp-blue-400); color: #fff; }
.badge-archived    { background: var(--fp-red); color: #fff; }

/* Discussion status */
.badge-open, .discussion-status-open       { background: var(--fp-blue-500); color: #fff; }
.badge-active, .discussion-status-active   { background: var(--fp-green); color: #fff; }
.badge-resolved, .discussion-status-resolved { background: var(--fp-purple); color: #fff; }
.discussion-status-archived                 { background: var(--fp-slate-500); color: #fff; }

/* Discussion mode */
.badge-threaded, .discussion-mode-threaded           { background: var(--fp-purple); color: #fff; }
.badge-structured, .discussion-mode-structureddebate { background: var(--fp-blue-600); color: #fff; }

/* --- Position Types --- */
.position-for      { border-left: 4px solid var(--fp-green); }
.position-against  { border-left: 4px solid var(--fp-red); }
.position-amendment { border-left: 4px solid var(--fp-blue-500); }

.position-for .card-header      { background: #ecfdf5; border-bottom-color: #a7f3d0; }
.position-against .card-header  { background: #fef2f2; border-bottom-color: #fecaca; }
.position-amendment .card-header { background: var(--fp-blue-50); border-bottom-color: var(--fp-blue-200); }

.position-for .badge      { background: var(--fp-green); }
.position-against .badge  { background: var(--fp-red); }
.position-amendment .badge { background: var(--fp-blue-500); }

.position-header {
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid var(--fp-slate-200);
}

/* --- Diff View --- */
.diff-view {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  border: 1px solid var(--fp-slate-200);
  border-radius: var(--fp-radius);
  overflow-x: auto;
  background: #fff;
}

.diff-line {
  display: flex;
  padding: 0 0.75rem;
  min-height: 1.6em;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-added {
  background: #dcfce7;
  border-left: 3px solid var(--fp-green);
}

.diff-removed {
  background: #fee2e2;
  border-left: 3px solid var(--fp-red);
}

.diff-modified {
  background: #fef3c7;
  border-left: 3px solid var(--fp-amber);
}

.diff-unchanged {
  background: transparent;
  border-left: 3px solid transparent;
}

.diff-marker {
  display: inline-block;
  width: 1.25rem;
  flex-shrink: 0;
  text-align: center;
  color: var(--fp-slate-500);
  user-select: none;
  font-weight: 600;
}

.diff-content {
  flex: 1;
  padding-left: 0.5rem;
}

/* --- Comment Threading --- */
.comments-section {
  max-width: 900px;
}

.comment-thread {
  border-left: 2px solid var(--fp-slate-200);
  padding-left: 1rem;
  margin-left: 0.5rem;
}

.comment-thread:first-child {
  border-left-color: transparent;
  margin-left: 0;
  padding-left: 0;
}

.comment-thread .comment-thread {
  border-left-color: var(--fp-slate-200);
}

.comment-item {
  border: 1px solid var(--fp-slate-200);
  border-radius: var(--fp-radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  background: #fff;
}

.comment-item:hover {
  border-color: var(--fp-blue-300);
}

.comment-content p:last-child {
  margin-bottom: 0;
}

/* --- Version Timeline --- */
.version-timeline {
  position: relative;
  padding-left: 2rem;
}

.version-timeline::before {
  content: '';
  position: absolute;
  left: 0.75rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--fp-blue-200);
}

.version-item {
  position: relative;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--fp-slate-200);
  border-radius: var(--fp-radius);
  background: #fff;
  transition: border-color 0.15s ease;
}

.version-item:hover {
  border-color: var(--fp-blue-400);
}

.version-item::before {
  content: '';
  position: absolute;
  left: -1.65rem;
  top: 1rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--fp-blue-500);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--fp-blue-200);
}

.version-item.current::before {
  background: var(--fp-green);
  box-shadow: 0 0 0 2px #a7f3d0;
}

/* --- Evidence --- */
.evidence-item {
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--fp-purple);
  margin-bottom: 0.5rem;
  background: var(--fp-slate-50);
  border-radius: 0 var(--fp-radius) var(--fp-radius) 0;
  font-size: 0.875rem;
}

/* --- Content Hash --- */
.content-hash {
  font-family: monospace;
  font-size: 0.7rem;
  color: var(--fp-slate-500);
  background: var(--fp-slate-100);
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
}

/* --- Section Cards --- */
.section-card {
  margin-bottom: 1.25rem;
}

.section-card .card-header {
  background: var(--fp-blue-50);
  color: var(--fp-blue-700);
  font-weight: 600;
  border-bottom: 1px solid var(--fp-blue-200);
}

/* --- Markdown Content --- */
.markdown-content h1 { font-size: 1.4rem; font-weight: 700; color: var(--fp-blue-800); }
.markdown-content h2 { font-size: 1.2rem; font-weight: 600; color: var(--fp-blue-700); margin-top: 1.5rem; }
.markdown-content h3 { font-size: 1.05rem; font-weight: 600; color: var(--fp-slate-700); }

.markdown-content blockquote {
  border-left: 4px solid var(--fp-blue-300);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--fp-slate-500);
  background: var(--fp-slate-50);
  border-radius: 0 var(--fp-radius) var(--fp-radius) 0;
}

.markdown-content table {
  width: 100%;
  margin-bottom: 1rem;
  border-collapse: collapse;
}

.markdown-content table th {
  background: var(--fp-slate-100);
  font-weight: 600;
}

.markdown-content table th,
.markdown-content table td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--fp-slate-200);
}

.markdown-content code {
  background: var(--fp-slate-100);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.85em;
  color: var(--fp-blue-700);
}

.markdown-content pre {
  background: var(--fp-blue-900);
  color: var(--fp-blue-200);
  padding: 1rem;
  border-radius: var(--fp-radius);
  overflow-x: auto;
}

.markdown-content pre code {
  background: none;
  color: inherit;
  padding: 0;
}

/* --- Discussion Card Listing --- */
.discussion-card {
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.discussion-card:hover {
  box-shadow: var(--fp-shadow-md);
  transform: translateY(-1px);
}

/* --- Accordion --- */
.accordion-button {
  font-weight: 600;
  color: var(--fp-slate-700);
}

.accordion-button:not(.collapsed) {
  background: var(--fp-blue-50);
  color: var(--fp-blue-700);
  box-shadow: none;
}

.accordion-button:focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* --- Alerts --- */
.alert-success {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.alert-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-info {
  background: var(--fp-blue-50);
  border-color: var(--fp-blue-200);
  color: var(--fp-blue-700);
}

.alert-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

/* --- Tables --- */
.table {
  --bs-table-bg: #fff;
}

.table thead th {
  background: var(--fp-slate-50);
  color: var(--fp-slate-700);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom-width: 2px;
  border-bottom-color: var(--fp-slate-200);
}

/* --- Nav Tabs --- */
.nav-tabs .nav-link {
  color: var(--fp-slate-500);
  font-weight: 500;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.75rem 1rem;
}

.nav-tabs .nav-link:hover {
  color: var(--fp-blue-500);
  border-bottom-color: var(--fp-blue-300);
}

.nav-tabs .nav-link.active {
  color: var(--fp-blue-600);
  border-bottom-color: var(--fp-blue-500);
  background: transparent;
}

/* --- Breadcrumb --- */
.breadcrumb {
  background: transparent;
  padding: 0;
  margin-bottom: 0;
  font-size: 0.875rem;
}

.breadcrumb-item a {
  color: var(--fp-blue-500);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  color: var(--fp-blue-700);
  text-decoration: underline;
}

/* --- Smooth Transitions --- */
a { transition: color 0.15s ease; }

/* --- Details / Summary --- */
details > summary {
  cursor: pointer;
  user-select: none;
}

details > summary:hover {
  color: var(--fp-blue-500);
}

/* --- Scrollbar (WebKit) --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--fp-slate-100);
}

::-webkit-scrollbar-thumb {
  background: var(--fp-slate-300);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--fp-slate-500);
}
