/* ==========================================================================
   ePCR ZZS — custom styles, dark theme, compact layout
   ========================================================================== */

body {
  background: #0d1117;
  color: #c9d1d9;
  font-size: .85rem;
}

/* Compact cards */
.card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
}
.card-header {
  background: #21262d;
  border-bottom: 1px solid #30363d;
  font-size: .82rem;
}
.card-body {
  font-size: .82rem;
}

/* Compact form controls */
.form-control, .form-select {
  background: #0d1117;
  border: 1px solid #30363d;
  color: #c9d1d9;
  font-size: .82rem;
  padding: .2rem .4rem;
}
.form-control:focus, .form-select:focus {
  border-color: #58a6ff;
  box-shadow: 0 0 0 2px rgba(88,166,255,.15);
}
.input-group-text {
  background: #21262d;
  border: 1px solid #30363d;
  color: #8b949e;
  font-size: .75rem;
  padding: .2rem .4rem;
}
.form-label {
  font-size: .78rem;
  color: #8b949e;
}

/* Buttons */
.btn-sm {
  font-size: .78rem;
  padding: .15rem .5rem;
}
.btn-primary {
  background: #238636;
  border-color: #2ea043;
}
.btn-primary:hover {
  background: #2ea043;
}
.btn-outline-light {
  border-color: #30363d;
  color: #c9d1d9;
}
.btn-outline-light:hover {
  background: #30363d;
  color: #f0f6fc;
}
.btn-outline-info {
  border-color: #58a6ff;
  color: #58a6ff;
}

/* Preview pane — sticky on desktop, clean for copy */
.preview-text {
  background: #0d1117;
  border: none;
  color: #e6edf3;
  font-family: 'Cascadia Code', 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: .78rem;
  line-height: 1.45;
  padding: .75rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  user-select: all;
}

#preview-column {
  position: sticky;
  top: .5rem;
  align-self: flex-start;
}

/* Repeat sections */
.repeat-item {
  border-bottom: 1px solid #21262d;
}
.repeat-item:last-child {
  border-bottom: none;
}

/* Multi select */
.multi-select .form-check-inline {
  margin-right: .3rem;
  margin-bottom: .1rem;
}
.multi-select .form-check-input {
  margin-top: .1rem;
}
.multi-select .form-check-label {
  font-size: .75rem;
}

/* Table */
.table {
  font-size: .82rem;
  color: #c9d1d9;
}
.table > :not(caption) > * > * {
  border-color: #21262d;
  padding: .3rem .5rem;
}
.table-hover > tbody > tr:hover {
  background: #1c2128;
}

/* Nested sections (A, B, C, D, E inside ABCDE) */
.nested-section {
  border-left: 2px solid #30363d;
  padding-left: .4rem;
}

/* Mobile: hide preview by default, show full-width form */
@media (max-width: 991.98px) {
  #preview-column {
    display: none !important;
  }
  #form-column {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #0d1117;
}
::-webkit-scrollbar-thumb {
  background: #30363d;
  border-radius: 3px;
}

/* Field row compact */
.field-row {
  margin-bottom: .3rem !important;
}

/* SOAP textareas */
.soap-textarea {
  font-size: .82rem;
  line-height: 1.3;
  background: #0d1117;
  color: #c9d1d9;
  border: 1px solid #30363d;
}

/* GCS widget */
.gcs-widget {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: .3rem .4rem;
  margin-bottom: .2rem;
}
.gcs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .2rem;
}
.gcs-label {
  font-weight: 700;
  min-width: 1.5rem;
  color: #58a6ff;
}
.gcs-option {
  margin-right: 0 !important;
}
.gcs-option .form-check-input:checked ~ .form-check-label {
  color: #7ee787;
  font-weight: 600;
}
.gcs-total {
  border-top: 1px solid #21262d;
  padding-top: .2rem;
  margin-top: .2rem;
  text-align: right;
}
.gcs-score {
  color: #58a6ff;
  font-size: 1rem;
}

/* Radio group */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: .15rem;
}
.radio-group .form-check-inline {
  margin-right: 0;
}

/* ---------- Offline / sync notification ---------- */
#sync-status {
  font-size: .7rem;
  padding: .15rem .45rem;
  white-space: nowrap;
}

/* ---------- Print styles — clean A4, no graphics ---------- */
@media print {
  body { background: #fff; color: #000; }
  nav, .navbar, #sync-status, .btn, .alert, .d-flex.gap-2,
  .card:not(.card:has(.preview-text)) { display: none !important; }
  .card { border: none !important; box-shadow: none !important; background: #fff !important; }
  .card-header { display: none !important; }
  .preview-text {
    background: #fff !important;
    color: #000 !important;
    font-family: 'Courier New', 'Consolas', monospace !important;
    font-size: 9pt !important;
    line-height: 1.25 !important;
    white-space: pre-wrap !important;
    max-height: none !important;
    overflow: visible !important;
    user-select: text !important;
    padding: 0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .container-fluid { padding: 0 !important; max-width: 190mm !important; }
  .row { display: block !important; margin: 0 !important; }
  .col-md-6, .col-lg-6 { width: 100% !important; max-width: 100% !important; flex: 0 0 100% !important; padding: 0 !important; }
  #form-column, #json-data, .card:has(#json-data) { display: none !important; }
  #preview-column { display: block !important; }
  @page { margin: 12mm 15mm; size: A4; }
}

.sync-toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: .75rem 1.25rem;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
  animation: fadeInUp .3s ease-out;
}

.sync-toast .toast-title {
  font-weight: 700;
  font-size: .9rem;
  color: #e6edf3;
}

.sync-toast .toast-sub {
  font-size: .78rem;
  color: #8b949e;
  margin-top: .15rem;
}

.sync-toast.toast-success { border-color: #2ea043; }
.sync-toast.toast-info    { border-color: #58a6ff; }
.sync-toast.toast-warning { border-color: #d29922; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Pending count badge inside form button area */
.pending-badge {
  font-size: .72rem;
  padding: .1rem .4rem;
  border-radius: 10px;
  background: #d29922;
  color: #0d1117;
  font-weight: 600;
}