/* Copyright (c) 2026 Maxx Gamble. All rights reserved.
 * Part of CommandCentre. Unauthorized copying, modification, or distribution is prohibited. */
/* ═══ LAYOUT ═══ */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--bd);
  background: var(--s1); position: sticky; top: 0; z-index: 60;
}
.logo { display: flex; align-items: center; gap: 9px; }
.logo-mark {
  width: 32px; height: 32px; background: var(--purple); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-text {
  font-family: 'Space Grotesk', sans-serif; font-size: 17px; font-weight: 700; letter-spacing: -.3px;
}
.logo-text em { font-style: normal; color: var(--purple); }
.hdr-r { display: flex; align-items: center; gap: 12px; }
.date-badge {
  font-size: 12px; color: var(--m1); background: var(--s2);
  border: 1px solid var(--bd); padding: 5px 10px; border-radius: 20px;
}
.back-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--bd); border-radius: 8px;
  padding: 6px 12px; color: var(--m1); font-family: inherit; font-size: 12px;
  cursor: pointer; transition: all .2s; text-decoration: none;
}
.back-btn:hover { border-color: var(--gold-border); color: var(--gold); text-decoration: none; }

.content { flex: 1; padding: 20px; max-width: 1100px; width: 100%; margin: 0 auto; }

/* ═══ VIEW TABS ═══ */
.view-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--bd); margin-bottom: 20px;
}
.view-tab {
  background: none; border: none; color: var(--m2);
  font-family: 'DM Sans', sans-serif; font-size: 14px; font-weight: 500;
  padding: 12px 20px; cursor: pointer; border-bottom: 2px solid transparent;
  transition: all .2s;
}
.view-tab.active { color: var(--purple); border-bottom-color: var(--purple); }
.view-tab:hover:not(.active) { color: var(--txt); }

.view { display: none; }
.view.active { display: block; }

/* ═══ FORM SECTIONS ═══ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.form-section {
  background: var(--s1); border: 1px solid var(--bd); border-radius: var(--rl);
  padding: 20px;
}
.form-section.full { grid-column: 1 / -1; }
.form-section h3 { margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.form-section h3::before {
  content: ''; display: inline-block; width: 3px; height: 16px;
  background: var(--purple); border-radius: 2px;
}

.field-label {
  display: block; font-size: 12px; color: var(--m1); font-weight: 500;
  margin-bottom: 5px; margin-top: 12px;
}
.field-label:first-child { margin-top: 0; }
.field-input, .field-select {
  width: 100%; background: var(--s2); border: 1px solid var(--bd); border-radius: 8px;
  padding: 9px 12px; color: var(--txt); font-size: 13px; font-family: inherit; outline: none;
  transition: border-color .2s;
}
.field-input:focus, .field-select:focus { border-color: var(--purple); }
.field-input::placeholder { color: var(--m2); }
.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1; }
textarea.field-input { resize: vertical; }

/* ═══ LINE ITEMS ═══ */
.line-items-table {
  width: 100%; border-collapse: collapse; margin-top: 10px;
}
.line-items-table th {
  font-size: 11px; color: var(--m2); font-weight: 500; text-transform: uppercase;
  letter-spacing: .5px; text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--bd);
}
.line-items-table td { padding: 6px 8px; vertical-align: middle; }
.line-items-table .field-input { padding: 7px 10px; font-size: 12px; }
.line-items-table .field-input.num { text-align: right; }
.line-item-total { font-family: 'Space Grotesk', sans-serif; font-size: 13px; font-weight: 600; text-align: right; min-width: 90px; color: var(--m1); }
.remove-row {
  background: none; border: none; color: var(--m2); cursor: pointer; font-size: 16px;
  padding: 4px 8px; border-radius: 4px; transition: all .15s;
}
.remove-row:hover { color: var(--red); background: var(--red-dim); }
.add-row-btn {
  background: none; border: 1px dashed var(--bd2); border-radius: 8px;
  color: var(--m1); font-family: inherit; font-size: 12px;
  padding: 8px 16px; cursor: pointer; transition: all .2s; margin-top: 10px; width: 100%;
}
.add-row-btn:hover { border-color: var(--purple); color: var(--purple); }

/* ═══ TOTALS ═══ */
.totals-row {
  display: flex; justify-content: flex-end; align-items: center; gap: 16px;
  padding: 8px 8px; font-size: 13px;
}
.totals-row.grand { border-top: 2px solid var(--bd2); padding-top: 12px; margin-top: 4px; }
.totals-label { color: var(--m1); font-weight: 500; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
.totals-val {
  font-family: 'Space Grotesk', sans-serif; font-weight: 700; min-width: 110px; text-align: right;
}
.totals-val.grand { font-size: 16px; color: var(--purple); }

/* ═══ BUTTONS ═══ */
.btn {
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 600;
  border: none; border-radius: 8px; padding: 9px 18px; cursor: pointer; transition: all .2s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-purple { background: var(--purple); color: var(--bk); }
.btn-purple:hover { background: #a855f7; }
.btn-gold { background: var(--gold); color: var(--bk); }
.btn-gold:hover { background: #e6a200; }
.btn-outline { background: none; border: 1px solid var(--bd2); color: var(--txt); }
.btn-outline:hover { border-color: var(--purple); color: var(--purple); }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255,82,82,.3); }
.btn-danger:hover { background: rgba(255,82,82,.2); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

.form-actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 20px;
  border-top: 1px solid var(--bd);
}

/* ═══ HISTORY TABLE ═══ */
.history-table {
  background: var(--s3); border: 1px solid var(--bd); border-radius: var(--rl); overflow: hidden;
}
.ht-head {
  display: grid; grid-template-columns: 140px 1fr 1fr 100px 100px 120px;
  padding: 10px 16px; background: var(--s1); border-bottom: 1px solid var(--bd); gap: 8px;
}
.ht-row {
  display: grid; grid-template-columns: 140px 1fr 1fr 100px 100px 120px;
  padding: 12px 16px; border-bottom: 1px solid rgba(30,30,30,.5); gap: 8px; align-items: center;
  transition: background .15s;
}
.ht-row:last-child { border-bottom: none; }
.ht-row:hover { background: var(--s1); }
.col-lbl {
  font-size: 11px; color: var(--m2); font-weight: 500; text-transform: uppercase; letter-spacing: .5px;
}
.col-val { font-size: 13px; }
.col-val.muted { color: var(--m2); }
.col-val.mono { font-family: 'Space Grotesk', monospace; font-size: 12px; font-weight: 600; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--m2); font-size: 14px; }

/* ═══ TOAST ═══ */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 600; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--s1); border: 1px solid var(--bd); border-radius: var(--r);
  padding: 12px 18px; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.4);
  display: flex; align-items: center; gap: 10px; animation: toastIn .25s ease; max-width: 360px;
}
.toast.success { border-color: rgba(76,175,80,.4); }
.toast.success::before { content: '\2713'; color: var(--green); font-weight: 700; }
.toast.error { border-color: rgba(255,82,82,.4); }
.toast.error::before { content: '\2717'; color: var(--red); font-weight: 700; }
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }

/* ═══ PRINT INVOICE ═══ */
.invoice-preview {
  background: #fff; color: #111; padding: 48px; border-radius: var(--rl);
  font-family: 'DM Sans', system-ui, sans-serif; font-size: 13px; line-height: 1.5;
  max-width: 820px; margin: 0 auto;
}
.inv-header { display: flex; justify-content: space-between; margin-bottom: 32px; }
.inv-title { font-family: 'Space Grotesk', sans-serif; font-size: 32px; font-weight: 700; color: #111; line-height: 1.1; }
.inv-meta { text-align: right; }
.inv-meta-row { display: flex; justify-content: flex-end; gap: 16px; margin-bottom: 4px; font-size: 13px; }
.inv-meta-label { color: #666; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; min-width: 90px; }
.inv-meta-val { font-weight: 600; min-width: 160px; }

.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-bottom: 32px; padding: 20px 0; border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }
.inv-party-label { font-size: 11px; font-weight: 600; color: #666; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.inv-party-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.inv-party-line { color: #444; font-size: 13px; }

.inv-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.inv-table thead { background: #111; color: #fff; }
.inv-table th { padding: 10px 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; text-align: left; }
.inv-table th:nth-child(n+4) { text-align: right; }
.inv-table td { padding: 10px 12px; border-bottom: 1px solid #eee; font-size: 13px; }
.inv-table td:nth-child(n+4) { text-align: right; }
.inv-totals-row td { border-bottom: none; }
.inv-totals-row td:nth-child(1) { border-bottom: none; }
.inv-totals-label { text-align: right !important; font-weight: 600; font-size: 12px; color: #666; text-transform: uppercase; letter-spacing: .3px; }
.inv-totals-val { text-align: right !important; font-weight: 700; }
.inv-grand td { border-top: 2px solid #111; }

.inv-details { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 32px; padding-top: 16px; border-top: 1px solid #ddd; }
.inv-detail-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #111; margin-bottom: 4px; }
.inv-detail-val { color: #444; font-size: 13px; }
.inv-detail-val em { font-style: italic; color: #666; }

.inv-sig { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; padding-top: 20px; border-top: 1px solid #ddd; margin-top: 32px; }
.inv-sig-left {}
.inv-sig-line { border-bottom: 1px solid #999; margin-bottom: 6px; min-height: 32px; }
.inv-sig-label { font-size: 11px; color: #888; margin-bottom: 16px; }
.inv-sig-declaration { font-size: 12px; color: #666; font-style: italic; line-height: 1.5; }

.inv-footer { text-align: center; font-size: 11px; color: #999; margin-top: 32px; padding-top: 16px; border-top: 1px solid #ddd; }

/* ═══ PRINT ═══ */
@media print {
  body { background: #fff !important; }
  .app-shell > .hdr, .content > .view-tabs, .form-actions, .no-print { display: none !important; }
  .view { display: none !important; }
  .view.print-active { display: block !important; }
  .content { max-width: 100%; padding: 0; }
  .invoice-preview { padding: 24px; box-shadow: none; border: none; }
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
  .content { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid input, .form-grid select, .form-grid textarea { font-size: 16px; min-height: 44px; }
  .inv-header { flex-direction: column; gap: 16px; }
  .inv-meta { text-align: left; }
  .inv-meta-row { justify-content: flex-start; }
  .inv-parties { grid-template-columns: 1fr; }
  .inv-details { grid-template-columns: 1fr; }
  .inv-sig { grid-template-columns: 1fr; }
  .invoice-preview { padding: 16px; font-size: 12px; }
  .ht-head, .ht-row { grid-template-columns: 1fr 80px 80px; }
  .ht-head > :nth-child(3), .ht-row > :nth-child(3) { display: none; }
  .ht-head > :nth-child(2), .ht-row > :nth-child(2) { display: none; }
  .hdr { padding: 10px 12px; }
  .btn { min-height: 40px; }
  .view-tabs { gap: 0; }
  .view-tab { padding: 10px 14px; font-size: 13px; min-height: 40px; }
}
@media (max-width: 480px) {
  .content { padding: 8px; }
  .invoice-preview { padding: 12px; }
}
