/* Workhand public document viewer styles
 * Tuned for both screen and print. Customer can hit Cmd/Ctrl+P to save as PDF.
 */

* { box-sizing: border-box; }

:root {
  --primary: #0EA5A0;
  --primary-dark: #0B7F7B;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #111827;
  --text-muted: #6B7280;
  --text-faint: #9CA3AF;
  --border: #e5e7eb;
  --success: #10B981;
  --danger: #EF4444;
  --warn: #F59E0B;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.brand {
  text-align: center;
  margin-bottom: 24px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.brand a { color: var(--primary); text-decoration: none; }

.card {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 32px;
  margin-bottom: 16px;
}

.doc-header { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.doc-header h1 { margin: 0; font-size: 28px; font-weight: 700; }
.doc-header .label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.4px; font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }
.doc-header .meta-block { display: flex; flex-direction: column; gap: 12px; }
.doc-header .meta-row { display: flex; gap: 24px; flex-wrap: wrap; }
.doc-header .meta-cell { display: flex; flex-direction: column; }
.doc-header .meta-cell .v { font-size: 14px; color: var(--text); font-weight: 500; }

.status {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.status.draft { background: #f3f4f6; color: var(--text-muted); }
.status.sent { background: #dbeafe; color: #1d4ed8; }
.status.accepted { background: #d1fae5; color: #047857; }
.status.paid { background: #d1fae5; color: #047857; }

.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 32px; }
.party h3 { margin: 0 0 8px 0; font-size: 11px; color: var(--text-muted); letter-spacing: 0.4px; font-weight: 700; text-transform: uppercase; }
.party .name { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.party .line { font-size: 13px; color: var(--text-muted); white-space: pre-line; }

table.line-items {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}
table.line-items th, table.line-items td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
table.line-items th { font-size: 11px; color: var(--text-muted); letter-spacing: 0.4px; font-weight: 700; text-transform: uppercase; padding-bottom: 8px; border-bottom-width: 2px; }
table.line-items td.numeric, table.line-items th.numeric { text-align: right; white-space: nowrap; }
table.line-items td.qty, table.line-items th.qty { text-align: right; white-space: nowrap; width: 80px; }
table.line-items td.price, table.line-items th.price { text-align: right; white-space: nowrap; width: 110px; }
table.line-items td.total, table.line-items th.total { text-align: right; white-space: nowrap; width: 120px; font-weight: 600; }
table.line-items tr:last-child td { border-bottom: none; }

.totals { margin-top: 8px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.totals .row { display: flex; gap: 32px; min-width: 280px; justify-content: space-between; font-size: 14px; }
.totals .row.grand { font-size: 18px; font-weight: 700; padding-top: 12px; border-top: 2px solid var(--border); margin-top: 6px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
button.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
button.btn:hover:not(:disabled) { background: var(--primary-dark); }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
button.btn.secondary:hover:not(:disabled) { background: var(--bg); }

.banner {
  border-radius: 8px;
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.banner.success { background: #d1fae5; color: #065f46; }
.banner.error { background: #fee2e2; color: #991b1b; }
.banner.info { background: #dbeafe; color: #1e40af; }

.loading, .empty { text-align: center; padding: 64px 20px; color: var(--text-muted); }
.loading .spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

.footer-note { text-align: center; font-size: 12px; color: var(--text-faint); margin-top: 24px; }
.footer-note a { color: var(--text-muted); }

@media (max-width: 600px) {
  .shell { padding: 16px 12px 80px; }
  .card { padding: 20px; }
  .doc-header h1 { font-size: 22px; }
  .parties { grid-template-columns: 1fr; gap: 16px; }
  table.line-items th.qty, table.line-items td.qty { width: 50px; }
  table.line-items th.price, table.line-items td.price { width: 80px; }
  .totals .row { min-width: 220px; }
}

@media print {
  body { background: #fff; }
  .shell { max-width: 100%; padding: 0; }
  .card { border: none; padding: 0; }
  .actions, .footer-note, .brand { display: none !important; }
  .banner { display: none; }
}
