/* ================================================================
   Simple Invoice Generator — Styles
   NovaFox Labs · /tools/invoice/
================================================================ */

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

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --bg:       #0a0a0f;
  --surface:  rgba(255,255,255,0.025);
  --border:   rgba(255,255,255,0.08);
  --accent:   #00ffaa;
  --text:     #e4e4e7;
  --muted:    #71717a;
  --subtle:   #a1a1aa;
  --error:    #f472b6;
  --radius:   12px;
  --font-ui:  'DM Sans', sans-serif;
  --font-mono:'Space Mono', monospace;
  --font-head:'Syne', sans-serif;
}

/* ── Layout ─────────────────────────────────────────────────── */
.invoice-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
  padding: 0 0 60px;
}

@media (max-width: 1024px) {
  .invoice-layout { grid-template-columns: 1fr; }
}

/* ── Form Panel ─────────────────────────────────────────────── */
.form-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
}

.form-section {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.form-section:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.form-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
  margin: 0 0 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-1 { grid-template-columns: 1fr; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
}

.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.span-2 { grid-column: span 2; }

@media (max-width: 640px) {
  .form-field.span-2 { grid-column: span 1; }
}

.form-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.form-input,
.form-select,
.form-textarea {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 13px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: rgba(0,255,170,0.4); }

.form-input.error,
.form-select.error { border-color: var(--error); }

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

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2371717a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-color: rgba(255,255,255,0.04);
  padding-right: 32px;
  cursor: pointer;
}

.form-select option { background: #1a1a24; color: var(--text); }

/* ── Line Items ─────────────────────────────────────────────── */
.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}
.items-table th {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 0 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.items-table th:last-child { text-align: center; width: 32px; }
.items-table td { padding: 6px 8px; vertical-align: middle; }
.items-table td:last-child { text-align: center; }

.item-input {
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s, background 0.15s;
}
.item-input:focus { border-color: rgba(0,255,170,0.3); background: rgba(0,255,170,0.03); }
.item-input[type="number"] { text-align: right; }

.item-subtotal {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  white-space: nowrap;
  text-align: right;
  padding: 7px 10px;
  min-width: 80px;
  display: block;
}

.btn-remove-item {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}
.btn-remove-item:hover { color: var(--error); background: rgba(244,114,182,0.1); }

.empty-items {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ── Totals ─────────────────────────────────────────────────── */
.totals-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  align-items: center;
  margin-top: 12px;
}
.totals-label {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--subtle);
  text-align: right;
}
.totals-value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
  min-width: 90px;
}
.totals-value.grand {
  font-size: 18px;
  color: var(--accent);
  font-weight: 700;
}
.totals-sep {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.totals-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.totals-input-small {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 9px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  width: 64px;
  text-align: right;
  outline: none;
  transition: border-color 0.2s;
}
.totals-input-small:focus { border-color: rgba(0,255,170,0.35); }

/* ── Action Buttons ─────────────────────────────────────────── */
.actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--accent); color: #0a0a0f; }
.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--subtle);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }
.btn-danger { background: rgba(244,114,182,0.12); color: var(--error); border: 1px solid rgba(244,114,182,0.2); }
.btn-danger:hover { background: rgba(244,114,182,0.2); }

/* ── Preview Panel ──────────────────────────────────────────── */
.preview-panel {
  position: sticky;
  top: 96px;
}

.preview-container {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 40px rgba(0,0,0,0.6);
}

/* ── Invoice Document Styles ─────────────────────────────────── */
.invoice-doc {
  background: #fff;
  color: #1a1a2e;
  font-family: 'DM Sans', 'Segoe UI', Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  padding: 40px;
  min-height: 600px;
}

.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 36px;
  gap: 20px;
}
.inv-brand {
  font-size: 22px;
  font-weight: 700;
  color: #0a0a0f;
  margin: 0;
}
.inv-brand-sub {
  font-size: 12px;
  color: #71717a;
  margin: 2px 0 0;
}
.inv-badge {
  text-align: right;
}
.inv-title {
  font-size: 28px;
  font-weight: 800;
  color: #0a0a0f;
  letter-spacing: -0.02em;
  margin: 0;
  text-transform: uppercase;
}
.inv-number {
  font-size: 13px;
  color: #71717a;
  margin: 4px 0 0;
  font-family: 'Space Mono', monospace;
}

.inv-meta {
  display: flex;
  gap: 24px;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e5e5ea;
  flex-wrap: wrap;
}
.inv-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.inv-meta-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #a1a1aa;
  text-transform: uppercase;
}
.inv-meta-value {
  font-size: 13px;
  font-weight: 500;
  color: #1a1a2e;
}

.inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}
.inv-party-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #a1a1aa;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.inv-party-name {
  font-size: 15px;
  font-weight: 600;
  color: #0a0a0f;
  margin-bottom: 3px;
}
.inv-party-detail {
  font-size: 12px;
  color: #52525b;
  line-height: 1.6;
  white-space: pre-line;
}

.inv-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}
.inv-items-table thead tr {
  background: #f4f4f5;
}
.inv-items-table th {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #71717a;
  text-transform: uppercase;
  padding: 10px 12px;
  text-align: left;
}
.inv-items-table th:not(:first-child) { text-align: right; }
.inv-items-table td {
  padding: 11px 12px;
  font-size: 13px;
  color: #1a1a2e;
  border-bottom: 1px solid #f0f0f5;
  vertical-align: top;
}
.inv-items-table td:not(:first-child) { text-align: right; }
.inv-items-table tbody tr:last-child td { border-bottom: none; }

.inv-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin-bottom: 32px;
  padding-top: 12px;
  border-top: 1px solid #e5e5ea;
}
.inv-total-row {
  display: flex;
  gap: 32px;
  font-size: 13px;
  color: #52525b;
  width: 260px;
  justify-content: space-between;
}
.inv-total-row.grand {
  font-size: 16px;
  font-weight: 700;
  color: #0a0a0f;
  padding-top: 6px;
  border-top: 2px solid #0a0a0f;
}
.inv-total-row.discount { color: #16a34a; }

.inv-footer {
  border-top: 1px solid #e5e5ea;
  padding-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.inv-footer-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #a1a1aa;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.inv-footer-text { font-size: 12px; color: #52525b; white-space: pre-line; }

/* ── Feedback toast ─────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: #1a1a24;
  border: 1px solid rgba(0,255,170,0.3);
  border-radius: 12px;
  padding: 12px 20px;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(244,114,182,0.3); color: var(--error); }

/* ── Responsive preview ─────────────────────────────────────── */
.preview-scaler {
  overflow: hidden;
}
.preview-scaler .invoice-doc {
  transform-origin: top left;
}

/* ── Nav styles (shared from styles.css) ────────────────────── */
.nav-link {
  position: relative; opacity: 0.6; transition: opacity 0.25s;
  text-decoration: none; color: #e4e4e7;
}
.nav-link::after {
  content: ''; position: absolute; bottom: -3px; left: 0;
  width: 0; height: 1px; background: #00ffaa; transition: width 0.3s ease;
}
.nav-link:hover, .nav-link.active { opacity: 1; }
.nav-link.active::after, .nav-link:hover::after { width: 100%; }

.ham-line {
  display: block; width: 22px; height: 2px;
  background: #e4e4e7; transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
}
#nav-toggle[aria-expanded="true"] .ham-line:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#nav-toggle[aria-expanded="true"] .ham-line:nth-child(2) { opacity: 0; transform: scaleX(0); }
#nav-toggle[aria-expanded="true"] .ham-line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

#mobile-menu { max-height: 0; overflow: hidden; transition: max-height 0.4s ease; }
#mobile-menu.open { max-height: 520px; }

.grid-bg {
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg,rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* ── Print styles ───────────────────────────────────────────── */
@media print {
  body { background: #fff !important; }
  .no-print,
  #navbar,
  .page-header,
  .form-panel,
  .actions-bar,
  .preview-panel > *:not(.preview-container),
  .preview-panel-header,
  .toast { display: none !important; }

  .invoice-layout { grid-template-columns: 1fr !important; }

  .preview-panel {
    position: static !important;
    grid-column: 1;
  }
  .preview-container {
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  .invoice-doc {
    padding: 0 !important;
    box-shadow: none !important;
  }
  .preview-scaler .invoice-doc {
    transform: none !important;
    width: 100% !important;
  }
}
