/* =====================================================================
   Administrative Orders — Global Stylesheet
   No frameworks, no external dependencies
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f5f5f5;
  line-height: 1.5;
}

/* ── Layout ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2em 1.5em;
  background: #fff;
  min-height: 100vh;
}

h1 { font-size: 1.7em; margin-bottom: .2em; }
h2 { font-size: 1.2em; margin: 1.5em 0 .5em; color: #222; }
h3 { font-size: 1em; margin: 1.2em 0 .3em; color: #444; }
.order-title { font-size: 1.1em; font-weight: normal; color: #444; margin-bottom: 1em; }
p { margin: .5em 0; }
a { color: #0056b3; text-decoration: none; }
a:hover { text-decoration: underline; }

.subtitle { color: #666; font-size: .9em; margin-bottom: 1em; }

/* ── Banners ── */
.banner {
  border-radius: 4px;
  padding: .75em 1em;
  margin: .8em 0;
  font-size: .95em;
}
.banner-warn {
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #664d03;
}

/* ── Search form ── */
.search-section { margin: 1.5em 0 2em; }

.search-row {
  display: flex;
  gap: .5em;
  margin-bottom: .6em;
}
.search-row input[type="text"] {
  flex: 1;
  padding: .55em .8em;
  font-size: 1em;
  border: 1px solid #bbb;
  border-radius: 4px;
  outline: none;
}
.search-row input[type="text"]:focus { border-color: #0056b3; box-shadow: 0 0 0 2px #cce0ff; }

.filter-row {
  display: flex;
  gap: .8em;
  align-items: center;
  flex-wrap: wrap;
}
.filter-row select, .filter-row label { font-size: .9em; }
.filter-row select {
  padding: .35em .6em;
  border: 1px solid #bbb;
  border-radius: 3px;
  background: #fff;
}

button[type="submit"] {
  padding: .55em 1.2em;
  background: #0056b3;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1em;
  cursor: pointer;
}
button[type="submit"]:hover { background: #004494; }

/* ── Search results ── */
#search-results { margin-top: 1.2em; }

.result-card {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: .8em 1em;
  margin-bottom: .7em;
  background: #fafafa;
}
.result-card:hover { border-color: #0056b3; }
.result-card h3 { margin: 0 0 .2em; }
.result-card .snippet { color: #444; font-size: .9em; margin: .3em 0; }
.result-card .result-meta { font-size: .82em; color: #666; }
.result-loading, .result-empty, .result-error {
  padding: .6em;
  color: #555;
  font-style: italic;
}
.result-error { color: #a00; }
.score { float: right; font-size: .8em; color: #888; font-family: monospace; }

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: .8em 0;
  font-size: .9em;
}
th {
  background: #2c3e50;
  color: #fff;
  text-align: left;
  padding: 7px 10px;
  font-weight: 600;
}
td { padding: 6px 10px; border-bottom: 1px solid #eee; vertical-align: top; }
tr:nth-child(even) td { background: #f8f8f8; }

/* Non-active rows get a tinted background */
tr.status-superseded td { background: #fff0f0; }
tr.status-rescinded  td { background: #fff0f0; }
tr.status-amended    td { background: #fffbe0; }
tr.status-flagged    td { background: #f3eff9; }
tr.status-failed     td { background: #fee; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: .78em;
  font-weight: 600;
  font-family: monospace;
  letter-spacing: .03em;
}
.badge-active          { background: #d4edda; color: #155724; }
.badge-superseded      { background: #f8d7da; color: #721c24; }
.badge-rescinded       { background: #f8d7da; color: #721c24; }
.badge-amended         { background: #fff3cd; color: #856404; }
.badge-flagged         { background: #e2d9f3; color: #432874; }
.badge-analysis_failed { background: #f5c2c7; color: #842029; }
.badge-pending         { background: #e9ecef; color: #495057; }
.badge-unknown         { background: #e9ecef; color: #495057; }
.badge-selected        { outline: 2px solid #0056b3; }

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: .5em;
  align-items: center;
  margin: .8em 0 1em;
  flex-wrap: wrap;
}
.filter-bar span { color: #666; font-size: .9em; }
.filter-bar .badge {
  cursor: pointer;
  padding: 4px 12px;
  font-size: .85em;
  text-decoration: none;
  color: #333;
  background: #e9ecef;
}
.filter-bar .badge:hover { background: #d0d9e6; }
.filter-bar .badge-selected { background: #0056b3; color: #fff; }

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: 1em;
  align-items: center;
  margin: 1em 0;
  font-size: .9em;
}
.pagination a {
  padding: .3em .8em;
  border: 1px solid #bbb;
  border-radius: 3px;
}
.pagination a:hover { background: #f0f0f0; }

/* ── Order detail ── */
.metadata-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .6em 2em;
  margin: 1em 0 1.5em;
  font-size: .9em;
}
.meta-item { display: flex; align-items: baseline; gap: .4em; }
.meta-label { font-weight: 600; color: #444; }

.chunk {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  margin: .6em 0;
  overflow: hidden;
}
.chunk pre {
  padding: 1em;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .82em;
  font-family: "Courier New", monospace;
  background: #fafafa;
  max-height: 400px;
  overflow-y: auto;
}

/* ── Nav section ── */
.nav-section { border-top: 1px solid #eee; padding-top: 1.5em; margin-top: 2em; }
.nav-section ul { margin: .5em 0 1em 1.5em; }
.nav-section li { margin: .25em 0; }

/* ── Orders table (orders list) ── */
.orders-table { table-layout: fixed; }
.orders-table th:nth-child(1) { width: 90px; }
.orders-table th:nth-child(3) { width: 200px; }
.orders-table th:nth-child(4) { width: 110px; }
.orders-table th:nth-child(5) { width: 110px; }

code { background: #f0f0f0; padding: 1px 4px; border-radius: 2px; font-family: monospace; }

/* ── Print ── */
@media print {
  body { background: #fff; font-size: 11px; }
  .container { padding: .5em; }
  .search-section, #search-form, .filter-bar, .pagination, button { display: none; }
  a { color: #000; text-decoration: none; }
  a[href]::after { content: " (" attr(href) ")"; font-size: .75em; color: #555; }
  .chunk pre { max-height: none; border: none; }
}
