/* =============================================================================
   Helcim Invoice System — Shared Styles
   ============================================================================= */

:root {
  --color-bg: #f7f7f5;
  --color-surface: #ffffff;
  --color-surface-alt: #f1f1ef;
  --color-border: #e3e3df;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6b6b;
  --color-primary: #1f4d3a;       /* deep green — payments/money */
  --color-primary-hover: #173a2b;
  --color-accent: #2563eb;        /* blue for card path */
  --color-zelle: #6d1ed4;         /* Zelle purple */
  --color-venmo: #008cff;         /* Venmo blue */
  --color-success: #15803d;
  --color-warn: #b45309;
  --color-danger: #b91c1c;
  --color-info: #1d4ed8;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); }
a:hover { color: var(--color-primary-hover); }

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px;
}

.container-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px;
}

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 16px; }

/* Header */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 0;
}

.site-header .container {
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header .logo {
  font-weight: 700;
  font-size: 18px;
  color: var(--color-text);
  text-decoration: none;
}

.site-header nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  margin-left: 16px;
  font-size: 14px;
}
.site-header nav a:hover { color: var(--color-text); }

/* Typography */
h1 { font-size: 28px; margin: 0 0 16px; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--color-text-muted); }
.small { font-size: 13px; }

/* Forms */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0 4px;
  color: var(--color-text);
}

input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="date"], input[type="password"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  font: inherit;
  color: inherit;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
  border-color: var(--color-primary);
}

textarea { min-height: 80px; resize: vertical; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .field-row { grid-template-columns: 1fr; }
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--color-primary);
  color: white;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s, transform 0.05s;
}

.btn:hover { background: var(--color-primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover { background: var(--color-surface-alt); }

.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: #991b1b; }

.btn-large {
  padding: 16px 24px;
  font-size: 16px;
  width: 100%;
}

.btn-icon { display: inline-flex; align-items: center; gap: 8px; }

/* Payment buttons (customer-facing) */
.pay-options { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

.pay-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.05s;
  width: 100%;
}

.pay-btn:hover { border-color: var(--color-text); }
.pay-btn:active { transform: translateY(1px); }

.pay-btn.zelle:hover { border-color: var(--color-zelle); }
.pay-btn.venmo:hover { border-color: var(--color-venmo); }
.pay-btn.card  :hover { border-color: var(--color-accent); }

.pay-btn .label-group { display: flex; flex-direction: column; gap: 2px; }
.pay-btn .label { font-size: 16px; }
.pay-btn .sublabel { font-size: 13px; color: var(--color-text-muted); font-weight: 400; }
.pay-btn .amount { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-recommended {
  background: #dcfce7;
  color: #166534;
  margin-left: 8px;
}

.badge-fee {
  background: #fef3c7;
  color: #92400e;
  margin-left: 8px;
}

/* Status pills */
.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}
.status-draft           { background: #e5e7eb; color: #374151; }
.status-sent            { background: #dbeafe; color: #1e40af; }
.status-viewed          { background: #e0e7ff; color: #3730a3; }
.status-zelle_initiated { background: #ede9fe; color: #5b21b6; }
.status-venmo_initiated { background: #dbeafe; color: #1e3a8a; }
.status-card_processing { background: #fef3c7; color: #92400e; }
.status-paid            { background: #dcfce7; color: #166534; }
.status-overdue         { background: #fee2e2; color: #991b1b; }
.status-cancelled       { background: #f3f4f6; color: #6b7280; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--color-border); }
table.data th { background: var(--color-surface-alt); font-weight: 600; color: var(--color-text-muted); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--color-surface-alt); cursor: pointer; }
table.data td.right { text-align: right; font-variant-numeric: tabular-nums; }

/* Invoice display */
.invoice-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.invoice-header .biz { font-size: 14px; color: var(--color-text-muted); }
.invoice-header .biz strong { color: var(--color-text); font-size: 16px; display: block; margin-bottom: 4px; }
.invoice-header .meta { text-align: right; font-size: 14px; }
.invoice-header .meta .invoice-id { font-family: var(--font-mono); font-size: 13px; color: var(--color-text-muted); }
.invoice-header .meta .invoice-total { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; }

.line-items { width: 100%; border-collapse: collapse; margin-top: 24px; font-size: 14px; }
.line-items th, .line-items td { padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.line-items th { font-weight: 600; color: var(--color-text-muted); text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.line-items td.right, .line-items th.right { text-align: right; font-variant-numeric: tabular-nums; }
.line-items tr.total td { font-weight: 700; font-size: 16px; border-bottom: none; padding-top: 16px; }
.line-items tr.subtotal td { color: var(--color-text-muted); border-bottom: none; padding-top: 12px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-md);
}
.modal h2 { margin-top: 0; }
.modal .copy-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--color-surface-alt);
  padding: 12px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 14px;
  margin: 8px 0 16px;
}
.modal .copy-row .value { flex: 1; word-break: break-all; }
.modal .copy-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.modal .copy-btn.copied { background: #dcfce7; color: #166534; border-color: #86efac; }

.modal-actions { display: flex; gap: 8px; margin-top: 16px; }

/* Line item editor */
.line-item-row {
  display: grid;
  grid-template-columns: 1fr 70px 100px 70px 100px 32px;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.line-item-row .li-taxable-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 10px;
}

.line-item-row .li-taxable-cell input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}

.line-item-row.header {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 4px;
  margin-bottom: 12px;
}

.line-item-row .remove-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 8px;
  font-size: 18px;
}
.line-item-row .remove-btn:hover { color: var(--color-danger); }

@media (max-width: 600px) {
  .line-item-row { grid-template-columns: 1fr 1fr; }
  .line-item-row.header { display: none; }
}

/* Partial-payment chip selector */
.partial-opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--color-border);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  background: var(--color-surface);
}
.partial-opt input { margin: 0; width: 16px; height: 16px; }
.partial-opt:has(input:checked) {
  border-color: var(--color-primary);
  background: #f0f9f5;
}
.partial-amount { color: var(--color-text-muted); font-weight: 400; margin-left: 4px; }

/* Tabs */
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font: inherit;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  margin-bottom: -1px;
}
.tab-btn.active {
  color: var(--color-text);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}
.tab-btn:hover:not(.active) { color: var(--color-text); }

/* Toolbar / filters */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.toolbar input[type="search"] { max-width: 260px; }

/* Toast / banner */
.banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.banner-info  { background: #dbeafe; color: #1e40af; }
.banner-warn  { background: #fef3c7; color: #92400e; }
.banner-error { background: #fee2e2; color: #991b1b; }
.banner-ok    { background: #dcfce7; color: #166534; }

/* Footer */
.footer {
  text-align: center;
  padding: 32px 20px;



/* Mobile overflow fix - allow long unbreakable strings (emails, urls) to wrap */
.card { overflow-wrap: anywhere; word-break: break-word; box-sizing: border-box; }
.card * { max-width: 100%; box-sizing: border-box; }
.card table { width: 100%; table-layout: fixed; word-break: break-word; }
.card table td:first-child { word-break: break-word; }
.modal-content { overflow-wrap: anywhere; word-break: break-word; }

@media (max-width: 640px) {
  .container { padding: 12px !important; }
  .card { padding: 16px !important; }
  body { overflow-x: hidden; }
}
