/* =====================================================
   CALIBRADOC — Sistema de Certificados de Calibração
   ===================================================== */

:root {
  --bg: #0e1117;
  --surface: #161b27;
  --surface2: #1e2535;
  --surface3: #252d40;
  --border: #2a3349;
  --border2: #3a4560;
  --accent: #3b82f6;
  --accent2: #60a5fa;
  --accent-glow: rgba(59,130,246,0.18);
  --success: #22c55e;
  --danger: #ef4444;
  --text: #e8ecf4;
  --text2: #94a3b8;
  --text3: #64748b;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans', sans-serif;
}

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

/* ===== PAGES ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== APP HEADER ===== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 38px; height: 38px;
  background: var(--accent);
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 20px; color: #fff;
  box-shadow: 0 0 18px var(--accent-glow);
}
.brand-name { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { font-size: 0.72rem; color: var(--text3); letter-spacing: 0.04em; }
.header-badge {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--accent2);
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
}

/* ===== LAYOUT ===== */
.form-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 2rem;
  min-height: calc(100vh - 64px);
}

/* ===== SIDEBAR ===== */
.form-sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
}
.sidebar-steps { display: flex; flex-direction: column; gap: 4px; }
.step {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text3);
}
.step:hover { background: var(--surface2); color: var(--text2); }
.step.active { background: var(--accent-glow); color: var(--accent2); border-left: 3px solid var(--accent); }
.step.done { color: var(--success); }
.step-num { font-family: var(--mono); font-size: 0.72rem; font-weight: 500; }
.step-label { font-size: 0.82rem; font-weight: 500; }

/* ===== FORM SECTIONS ===== */
.form-content { min-width: 0; }
.form-section { display: none; animation: fadeIn 0.3s ease; }
.form-section.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}
.section-title span {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ===== GRID ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.75rem; }
.field.full { grid-column: 1 / -1; }

/* ===== FIELDS ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.field input,
.field select,
.field textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  font-family: var(--sans);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field select { cursor: pointer; }

/* ===== STANDARDS ===== */
.standard-row {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

/* ===== RESULTS TABLE ===== */
.table-wrapper { overflow-x: auto; }
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.results-table th {
  background: var(--surface3);
  color: var(--text2);
  padding: 8px 6px;
  text-align: center;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border: 1px solid var(--border);
}
.results-table td {
  border: 1px solid var(--border);
  padding: 4px 4px;
}
.results-table input,
.results-table select {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
  width: 100%;
  padding: 4px 6px;
  text-align: center;
  outline: none;
}
.results-table input:focus { background: var(--accent-glow); border-radius: 4px; }

/* ===== SIGNATURE ===== */
.signature-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0;
}
.sig-block { display: flex; flex-direction: column; gap: 8px; }
.sig-block label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.sig-block canvas {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: crosshair;
  display: block;
  width: 100%;
  touch-action: none;
}
.sig-controls { display: flex; gap: 8px; }
.sig-controls button {
  background: var(--surface3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
}
.sig-controls button:hover { border-color: var(--danger); color: var(--danger); }

/* ===== BUTTONS ===== */
.btn-next, .btn-back, .btn-primary, .btn-add, .btn-del {
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  padding: 10px 22px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}
.btn-next {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-next:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-back {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
}
.btn-back:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  padding: 12px 28px;
  font-size: 0.95rem;
  box-shadow: 0 4px 18px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-2px); }
.btn-add {
  background: transparent;
  border: 1px dashed var(--border2);
  color: var(--text3);
  padding: 8px 18px;
  border-radius: 8px;
  margin-top: 4px;
}
.btn-add:hover { border-color: var(--accent); color: var(--accent); }
.btn-del {
  background: transparent;
  border: none;
  color: var(--text3);
  padding: 4px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}
.btn-del:hover { color: var(--danger); }

.step-nav {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* =====================================================
   CERTIFICATE STYLES (for screen preview + print)
   ===================================================== */
.cert-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.toolbar-title { font-weight: 600; font-size: 0.95rem; color: var(--text2); }
.toolbar-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--sans);
  font-weight: 500;
  transition: all 0.2s;
}
.toolbar-btn:hover { border-color: var(--accent); color: var(--accent); }
.toolbar-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.toolbar-btn.primary:hover { background: var(--accent2); }

.cert-wrapper {
  background: #f0f2f5;
  min-height: calc(100vh - 56px);
  padding: 2rem;
  display: flex;
  justify-content: center;
}

/* The actual certificate (white document) */
.cert-doc {
  background: #fff;
  width: 210mm;
  min-height: 297mm;
  padding: 14mm 14mm 10mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10pt;
  color: #111;
  box-shadow: 0 4px 40px rgba(0,0,0,0.18);
  position: relative;
}

.cert-header {
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 2px solid #1a1a2e;
  padding-bottom: 10px;
  margin-bottom: 8px;
}
.cert-logo-box {
  border: 2px solid #1a1a2e;
  padding: 6px 10px;
  min-width: 90px;
  text-align: center;
}
.logo-text {
  font-size: 18pt;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: #1a1a2e;
  line-height: 1;
}
.logo-sub {
  font-size: 5.5pt;
  color: #333;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}
.cert-title-area { flex: 1; text-align: center; }
.cert-main-title { font-size: 16pt; font-weight: 900; color: #1a1a2e; line-height: 1.1; }
.cert-lab-name { font-size: 11pt; font-weight: 600; color: #333; }

.cert-meta-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  background: #f7f7f9;
  border: 1px solid #ccc;
  padding: 5px 10px;
  font-size: 9pt;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.meta-item { display: flex; gap: 5px; }
.meta-item span { color: #555; }
.meta-item strong { color: #111; }
.page-count { margin-left: auto; color: #888; font-size: 8.5pt; }

.cert-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2px;
  font-size: 9.5pt;
}
.cert-table tr td {
  border: 1px solid #bbb;
  padding: 4px 7px;
  vertical-align: top;
}
.cert-label { font-weight: 700; color: #222; white-space: nowrap; }
.cert-small { font-size: 8pt; color: #555; }

.cert-section-title {
  font-weight: 800;
  font-size: 9.5pt;
  background: #e8eaf0;
  border: 1px solid #bbb;
  padding: 3px 8px;
  margin: 6px 0 2px;
  color: #1a1a2e;
  letter-spacing: 0.02em;
}

.cert-range-info {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  background: #f7f7f9;
  border: 1px solid #ccc;
  border-bottom: none;
  padding: 4px 8px;
  font-size: 9pt;
}
.cert-range-info strong { color: #111; }

.cert-instrument-name {
  font-weight: 800;
  font-size: 10pt;
  background: #1a1a2e;
  color: #fff;
  padding: 3px 8px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.cert-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9pt;
  margin-bottom: 6px;
}
.cert-results-table th {
  background: #e8eaf0;
  border: 1px solid #bbb;
  padding: 4px 5px;
  text-align: center;
  font-weight: 700;
  font-size: 8.5pt;
  line-height: 1.3;
}
.cert-results-table td {
  border: 1px solid #ccc;
  padding: 3px 5px;
  text-align: center;
  font-size: 9pt;
}
.cert-results-table td.status-ap { color: #166534; font-weight: 700; }
.cert-results-table td.status-rep { color: #991b1b; font-weight: 700; }

.standards-tbl { margin-bottom: 2px; font-size: 9pt; }
.standards-tbl th {
  background: #e8eaf0;
  border: 1px solid #bbb;
  padding: 4px 7px;
  font-weight: 700;
  text-align: left;
  font-size: 8.5pt;
}
.standards-tbl td {
  border: 1px solid #ccc;
  padding: 3px 7px;
}

.cert-footer-note {
  border-top: 1px solid #ddd;
  padding-top: 6px;
  margin-top: 12px;
  font-size: 7.5pt;
  color: #777;
  text-align: center;
  line-height: 1.5;
}

.page-break { page-break-before: always; height: 1px; }

.cert-final-verdict {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  font-size: 9pt;
  border: 1px solid #bbb;
  padding: 5px 10px;
  margin-bottom: 4px;
  background: #f7f7f9;
}
.cert-final-verdict strong {
  color: #166534;
  font-size: 11pt;
  font-weight: 800;
}

.cert-observations {
  border: 1px solid #ccc;
  padding: 5px 8px;
  font-size: 9.5pt;
  margin-bottom: 6px;
  font-weight: 600;
  color: #1a1a2e;
  min-height: 30px;
}

.cert-legend {
  border: 1px solid #ccc;
  padding: 6px 8px;
  font-size: 8pt;
  color: #444;
  line-height: 1.7;
  margin-bottom: 8px;
}
.cert-legend p::before { content: ''; }

.cert-lab-addr {
  font-size: 8pt;
  color: #555;
  margin-bottom: 2px;
}
.cert-emission-date {
  font-size: 9pt;
  color: #333;
  margin-bottom: 18px;
}

.cert-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 16px;
  margin-top: 10px;
}
.sig-col { text-align: center; }
.sig-img-wrap {
  height: 60px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 4px;
}
.sig-img-wrap img {
  max-height: 58px;
  max-width: 100%;
  object-fit: contain;
}
.sig-line {
  border-bottom: 1px solid #333;
  margin: 4px 16px;
}
.sig-name {
  font-weight: 700;
  font-size: 9.5pt;
  margin-top: 4px;
  color: #1a1a2e;
}
.sig-role { font-size: 8.5pt; color: #555; font-weight: 600; }

/* =====================================================
   PRINT STYLES
   ===================================================== */
@media print {
  body { background: #fff !important; }
  .cert-toolbar { display: none !important; }
  .cert-wrapper { background: #fff !important; padding: 0 !important; }
  .cert-doc { box-shadow: none !important; padding: 10mm 12mm 8mm !important; width: 100% !important; }
  .page-break { page-break-before: always; }
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 900px) {
  .form-layout { grid-template-columns: 1fr; }
  .form-sidebar { position: static; }
  .sidebar-steps { flex-direction: row; flex-wrap: wrap; }
  .grid-5 { grid-template-columns: 1fr 1fr; }
  .signature-area { grid-template-columns: 1fr; }
  .cert-wrapper { padding: 0; }
  .cert-doc { width: 100%; padding: 8mm; }
}
@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
  .cert-signatures { grid-template-columns: 1fr; }
}
