/*
 * stockbook.css — Stockbook plugin styles
 *
 * Strategy: minimal custom CSS alongside PatternSkin.
 * Foswiki's .foswikiTable, .foswikiButton, .foswikiInputField used throughout.
 * We only add what PatternSkin doesn't already provide.
 */

/* ── Tables ──────────────────────────────────────────────────────────────── */
.stockbook-table { width: 100%; border-collapse: collapse; }
.stockbook-table th, .stockbook-table td {
  padding: 0.4em 0.7em; text-align: left;
  border: 1px solid #d0d0d0; vertical-align: top;
}
.stockbook-table th { background: #f0f0f0; font-weight: bold; }
.stockbook-table tr:nth-child(even) td { background: #fafafa; }
.stockbook-num { text-align: right; font-variant-numeric: tabular-nums; }
.stockbook-founding-row td { background: #f5f5e8 !important; font-style: italic; }

/* ── Status badges ───────────────────────────────────────────────────────── */
.stockbook-badge {
  display: inline-block; padding: 0.1em 0.5em;
  border-radius: 3px; font-size: 0.85em; font-weight: bold; white-space: nowrap;
}
.stockbook-badge-active    { background:#d4edda; color:#155724; }
.stockbook-badge-canceled  { background:#f8d7da; color:#721c24; }
.stockbook-badge-draft     { background:#e2e3e5; color:#383d41; }
.stockbook-badge-pending   { background:#fff3cd; color:#856404; }
.stockbook-badge-approved  { background:#cce5ff; color:#004085; }
.stockbook-badge-posted    { background:#d4edda; color:#155724; }
.stockbook-badge-rejected  { background:#f8d7da; color:#721c24; }
.stockbook-ok   { color:#155724; }
.stockbook-warn { color:#856404; font-weight:bold; }

/* ── Transaction queue cards ─────────────────────────────────────────────── */
.stockbook-txn-card {
  border: 1px solid #ddd; border-left: 4px solid #aaa;
  border-radius: 3px; margin-bottom: 0.8em; padding: 0.7em 1em; background: #fff;
}
.stockbook-status-draft    { border-left-color: #6c757d; }
.stockbook-status-pending  { border-left-color: #ffc107; }
.stockbook-status-approved { border-left-color: #17a2b8; }
.stockbook-status-posted   { border-left-color: #28a745; }
.stockbook-status-rejected { border-left-color: #dc3545; }
.stockbook-txn-card-header {
  display: flex; align-items: center; gap: 0.7em; margin-bottom: 0.3em;
}
.stockbook-txn-type { font-weight: bold; }
.stockbook-txn-date { color: #666; font-size: 0.9em; }
.stockbook-txn-notes { color: #555; margin: 0.3em 0; font-size: 0.95em; }
.stockbook-approval-progress { font-size: 0.9em; color: #555; margin: 0.3em 0; }
.stockbook-signer {
  display: inline-block; padding: 0.1em 0.4em;
  border-radius: 2px; font-size: 0.85em;
}
.stockbook-action-approve { background:#d4edda; color:#155724; }
.stockbook-action-reject  { background:#f8d7da; color:#721c24; }
.stockbook-txn-actions {
  margin-top: 0.6em; display: flex; gap: 0.5em; flex-wrap: wrap; align-items: center;
}
.stockbook-hint { color: #666; font-size: 0.88em; font-style: italic; }
.stockbook-btn-approve { background:#28a745 !important; color:#fff !important; }
.stockbook-btn-post    { background:#17a2b8 !important; color:#fff !important; }
.stockbook-btn-submit  { background:#007bff !important; color:#fff !important; }
.stockbook-btn-new     { margin-bottom: 0.6em; }

/* ── Modal overlay ───────────────────────────────────────────────────────── */
.stockbook-modal-overlay {
  position: fixed;
  inset: 0;                          /* top/right/bottom/left all 0 */
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1em;
}
.stockbook-modal-overlay.stockbook-hidden { display: none; }

.stockbook-modal-dialog {
  background: #fff;
  border-radius: 5px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 42em;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stockbook-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8em 1.2em;
  border-bottom: 1px solid #dee2e6;
  background: #f8f9fa;
  flex-shrink: 0;
}

.stockbook-modal-title {
  font-weight: bold;
  font-size: 1.05em;
}

.stockbook-modal-body {
  padding: 1.2em;
  overflow-y: auto;
  flex: 1;
}
.stockbook-btn-close {
  background: none; border: none; font-size: 1.3em;
  cursor: pointer; color: #666; line-height: 1; padding: 0 0.2em;
}
.stockbook-btn-close:hover { color: #333; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.stockbook-form .stockbook-form-row {
  display: flex; align-items: baseline;
  gap: 0.7em; margin-bottom: 0.7em; flex-wrap: wrap;
}
.stockbook-form .stockbook-form-row label {
  min-width: 14em; font-weight: bold; font-size: 0.95em;
}
.stockbook-form .foswikiInputField,
.stockbook-form select,
.stockbook-form textarea { flex: 1; min-width: 12em; }
.stockbook-form-actions { margin-top: 1em; display: flex; gap: 0.5em; }
.stockbook-post-form h4 { margin-top: 0; margin-bottom: 0.8em; color: #17a2b8; }

/* ── Search ──────────────────────────────────────────────────────────────── */
.stockbook-search-form { display: flex; gap: 0.5em; margin-bottom: 0.8em; }
.stockbook-search-input { flex: 1; min-width: 20em; }
.stockbook-results-heading {
  margin: 1em 0 0.4em; font-size: 1em; color: #444;
  border-bottom: 1px solid #ddd; padding-bottom: 0.2em;
}
.stockbook-owner-card { padding: 0.4em 0; border-bottom: 1px solid #f0f0f0; }
.stockbook-loading { color: #888; font-style: italic; }
.stockbook-empty   { color: #888; font-style: italic; }

/* ── Cert chain ──────────────────────────────────────────────────────────── */
.stockbook-chain-ancestor td { opacity: 0.7; }
.stockbook-chain-self td     { font-weight: bold; background: #fffde7 !important; }
.stockbook-chain-descendant td { opacity: 0.85; }

/* ── Integrity report ────────────────────────────────────────────────────── */
.stockbook-integrity-pass {
  padding: 0.6em 1em; background: #d4edda; color: #155724;
  border-radius: 3px; margin-bottom: 0.8em; font-weight: bold;
}
.stockbook-integrity-fail {
  padding: 0.6em 1em; background: #f8d7da; color: #721c24;
  border-radius: 3px; margin-bottom: 0.8em; font-weight: bold;
}

/* ── Test mode banner ────────────────────────────────────────────────────── */
.stockbook-testmode-banner, .stockbook-testmode {
  background: #fff3cd; color: #856404;
  border: 1px solid #ffc107; border-radius: 3px;
  padding: 0.4em 0.8em; margin-bottom: 0.6em;
  font-size: 0.9em; font-weight: bold;
}

/* ── Toast notification ──────────────────────────────────────────────────── */
#stockbook-toast {
  display: none; position: fixed; bottom: 1.5em; right: 1.5em;
  padding: 0.7em 1.2em; border-radius: 4px; font-size: 0.95em;
  font-weight: bold; z-index: 9999; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  max-width: 28em;
}
.stockbook-toast-ok    { background:#d4edda; color:#155724; border:1px solid #c3e6cb; }
.stockbook-toast-error { background:#f8d7da; color:#721c24; border:1px solid #f5c6cb; }

/* ── Ledger summary bar ──────────────────────────────────────────────────── */
.stockbook-ledger-summary {
  margin-top: 0.7em; padding: 0.5em 0.8em;
  background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 3px; font-size: 0.95em;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .stockbook-form .stockbook-form-row { flex-direction: column; gap: 0.3em; }
  .stockbook-form .stockbook-form-row label { min-width: unset; }
  .stockbook-search-form { flex-direction: column; }
  .stockbook-txn-card-header { flex-wrap: wrap; }
}
