/* ==========================================================================
   BCA Sandbox Lab — shared UI styles (light, compact, Odoo-inspired)
   ========================================================================== */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #1f2937;
  --text-muted: #667085;
  --primary: #2f6fed;
  --primary-dark: #1f57c9;
  --success: #10804a;
  --success-bg: #e9f7ef;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --warning: #92610a;
  --warning-bg: #fdf5e6;
  --info-bg: #eef4ff;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --z-topbar: 100;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}

.brand:hover { text-decoration: none; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .03em;
}

.brand-text { font-size: 14px; }

.mainnav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.mainnav-link {
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.mainnav-link:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.mainnav-link.is-active {
  background: var(--info-bg);
  color: var(--primary-dark);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Workspace + page header
   -------------------------------------------------------------------------- */

.workspace {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.page-title {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
}

.page-desc {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  max-width: 720px;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.card-body { padding: 16px; }
.card-body.is-flush { padding: 0; }

.card-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 12.5px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: var(--bg); text-decoration: none; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-danger {
  background: var(--surface);
  border-color: #f0b5b0;
  color: var(--danger);
}

.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { min-height: 26px; padding: 3px 8px; font-size: 12px; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.is-wide { grid-column: 1 / -1; }

.label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.textarea { min-height: 64px; resize: vertical; }

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .12);
}

.input.has-error,
.select.has-error,
.textarea.has-error { border-color: var(--danger); }

.help {
  font-size: 12px;
  color: var(--text-muted);
}

.error-text {
  font-size: 12px;
  color: var(--danger);
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.field-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.table thead th {
  background: #fbfbfc;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fcfcfd; }

.table .text-right { text-align: right; }
.table td.text-right,
.table th.text-right { text-align: right; }

.table-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Badges + flash
   -------------------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 650;
  line-height: 18px;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); border-color: #c7ecd7; }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: #f6cfcb; }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: #f3e2b7; }
.badge-neutral { background: var(--bg);         color: var(--text-muted); border-color: var(--border); }
.badge-info    { background: var(--info-bg);    color: var(--primary-dark); border-color: #d5e2ff; }

.flash {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 14px;
  font-size: 13px;
}

.flash-success { background: var(--success-bg); border-color: #c7ecd7; color: var(--success); }
.flash-error   { background: var(--danger-bg);  border-color: #f6cfcb; color: var(--danger); }
.flash-info    { background: var(--info-bg);    border-color: #d5e2ff; color: var(--primary-dark); }

/* --------------------------------------------------------------------------
   Status grid (dashboard)
   -------------------------------------------------------------------------- */

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.status-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
  min-width: 0;
}

.status-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.status-value {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

.status-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-word;
}

/* --------------------------------------------------------------------------
   Spec list (key/value detail block)
   -------------------------------------------------------------------------- */

.spec {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.spec-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.spec-row:nth-child(odd) { background: #fbfbfc; }
.spec-row:nth-last-child(-n+2) { border-bottom: none; }

.spec-label { color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }
.spec-value { font-weight: 600; text-align: right; word-break: break-word; }

/* --------------------------------------------------------------------------
   Raw payload blocks
   -------------------------------------------------------------------------- */

details.raw { margin-top: 12px; }

details.raw > summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-muted);
  user-select: none;
}

pre.raw-body {
  margin: 8px 0 0;
  padding: 12px;
  background: #fbfbfc;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
  max-height: 420px;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.appfooter {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.appfooter-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .status-grid { grid-template-columns: minmax(0, 1fr); }
  .spec { grid-template-columns: minmax(0, 1fr); }
  .spec-row { background: var(--surface) !important; }
  .spec-row:nth-last-child(-n+2) { border-bottom: 1px solid var(--border); }
  .spec-row:last-child { border-bottom: none; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions .btn { flex: 1 1 auto; }
}

@media (max-width: 480px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; padding: 10px 16px; gap: 8px; }
  .mainnav { width: 100%; padding-bottom: 2px; }
  .workspace { padding: 16px 16px 32px; }
  .brand-text { font-size: 13px; }
}
