/*
 * Invoice Template Styles
 * Created by lautandigital.id
 * https://lautandigital.id
 */

/* ─── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --accent:        #eff6ff;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --surface:       #ffffff;
  --bg:            #f1f5f9;
  --success:       #16a34a;
  --warning:       #d97706;
  --danger:        #dc2626;
  --radius:        10px;
  --shadow:        0 4px 24px rgba(0,0,0,.08);
  --font:          'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }


/* ─── Toolbar ────────────────────────────────────────────────────── */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.toolbar-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.toolbar-brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
}

.toolbar-credit {
  font-size: 12px;
  color: var(--text-muted);
}

.toolbar-right {
  display: flex;
  gap: 10px;
}

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e8eef5; }

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px dashed var(--primary);
  padding: 6px 16px;
  font-size: 13px;
}
.btn-ghost:hover { background: var(--accent); }

.btn-danger-icon {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color .15s, background .15s;
  font-size: 16px;
  line-height: 1;
}
.btn-danger-icon:hover { color: var(--danger); background: #fee2e2; }


/* ─── Page Wrapper ───────────────────────────────────────────────── */
.page-wrapper {
  min-height: 100vh;
  padding: 32px 16px 64px;
}


/* ─── Invoice Card ───────────────────────────────────────────────── */
.invoice {
  max-width: 860px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 48px 52px;
}


/* ─── Header ─────────────────────────────────────────────────────── */
.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.company-info {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

/* Logo */
.company-logo {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
}

#company-logo-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.logo-placeholder {
  width: 80px;
  height: 80px;
  border: 2px dashed #c7d2e0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  cursor: pointer;
  transition: border-color .15s;
}
.logo-placeholder:hover { border-color: var(--primary); }

.logo-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  text-align: center;
  padding: 8px;
}
.logo-upload-label:hover { color: var(--primary); }

/* Company details */
.company-details { display: flex; flex-direction: column; gap: 2px; }
.company-name { font-size: 17px; font-weight: 700; color: var(--text); }

/* Invoice meta */
.invoice-meta { text-align: right; }

.invoice-title {
  font-size: 36px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 4px;
  margin-bottom: 16px;
}

.meta-table { margin-left: auto; border-collapse: collapse; }
.meta-table td { padding: 2px 4px; font-size: 13px; }
.meta-label { color: var(--text-muted); white-space: nowrap; }
.meta-sep { color: var(--text-muted); padding: 0 6px; }


/* ─── Divider ────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 28px 0;
}


/* ─── Billing Section ────────────────────────────────────────────── */
.billing-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 32px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.client-name { font-size: 16px; font-weight: 700; }

.status-badge {
  padding: 6px 18px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
  transition: background .2s;
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid #fbbf24;
  white-space: nowrap;
}
.status-badge.paid     { background: #dcfce7; color: #14532d; border-color: #86efac; }
.status-badge.overdue  { background: #fee2e2; color: #7f1d1d; border-color: #fca5a5; }


/* ─── Items Table ────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.items-table thead tr {
  background: var(--primary);
  color: #fff;
}

.items-table th {
  padding: 11px 14px;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .4px;
  text-align: left;
  white-space: nowrap;
}

.col-no     { width: 44px; text-align: center; }
.col-desc   { min-width: 200px; }
.col-qty    { width: 64px; text-align: right; }
.col-unit   { width: 80px; }
.col-price  { width: 130px; text-align: right; }
.col-total  { width: 130px; text-align: right; }
.col-action { width: 40px; text-align: center; }

.items-table tbody tr { border-bottom: 1px solid var(--border); }
.items-table tbody tr:last-child { border-bottom: none; }
.items-table tbody tr:nth-child(even) { background: #f8fafc; }
.items-table tbody tr:hover { background: var(--accent); }

.items-table td {
  padding: 10px 14px;
  vertical-align: middle;
}

.items-table td:first-child { text-align: center; color: var(--text-muted); }
.items-table td.cell-qty    { text-align: right; }
.items-table td.cell-price  { text-align: right; }
.items-table td.cell-total  { text-align: right; font-weight: 600; }

/* Editable cells in table */
.items-table .editable {
  outline: none;
  min-width: 40px;
}

.table-actions {
  margin-top: 12px;
  display: flex;
}


/* ─── Totals ─────────────────────────────────────────────────────── */
.invoice-footer-totals {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.notes-section { flex: 1; min-width: 200px; }

.notes-box {
  min-height: 64px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}

.bank-info { font-size: 13px; }

.totals-box {
  min-width: 260px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.total-row span:last-child { font-weight: 600; color: var(--text); white-space: nowrap; }

.grand-total {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary) !important;
}
.grand-total span { color: var(--primary) !important; }

.discount-input,
.tax-input {
  display: inline-block;
  min-width: 20px;
  max-width: 40px;
  text-align: center;
  border-bottom: 1px dashed var(--primary);
  color: var(--primary);
  font-weight: 600;
}


/* ─── Signature ──────────────────────────────────────────────────── */
.signature-section {
  display: flex;
  gap: 48px;
  margin-top: 48px;
  flex-wrap: wrap;
}

.signature-box { flex: 1; min-width: 140px; }

.signature-space {
  height: 64px;
  border-bottom: 1.5px solid var(--border);
  margin: 16px 0 8px;
}

.sig-role { color: var(--text-muted); font-size: 12px; margin-top: 2px; }


/* ─── Invoice Bottom ─────────────────────────────────────────────── */
.invoice-bottom {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.thank-you { font-style: italic; color: var(--text-muted); font-size: 13px; }

.credit { font-size: 11px; color: #94a3b8; }
.credit a { color: #94a3b8; }
.credit a:hover { color: var(--primary); }


/* ─── Editable Elements ──────────────────────────────────────────── */
.editable {
  outline: none;
  border-radius: 4px;
  transition: background .15s, box-shadow .15s;
  cursor: text;
}

.editable:hover { background: var(--accent); }

.editable:focus {
  background: #dbeafe;
  box-shadow: 0 0 0 2px #bfdbfe;
  cursor: text;
}

.editable:empty::before {
  content: attr(data-placeholder);
  color: #cbd5e1;
  pointer-events: none;
}


/* ─── Print / PDF ────────────────────────────────────────────────── */
@media print {
  .no-print { display: none !important; }

  body { background: #fff; }

  .page-wrapper { padding: 0; }

  .invoice {
    box-shadow: none;
    border-radius: 0;
    max-width: 100%;
    padding: 24px 32px;
  }

  .editable:hover,
  .editable:focus {
    background: transparent;
    box-shadow: none;
  }

  .items-table tbody tr:hover { background: transparent; }

  a { color: inherit; }

  .invoice-title { color: #2563eb !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .items-table thead tr { background: #2563eb !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .status-badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}


/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .invoice { padding: 24px 20px; }
  .invoice-header { flex-direction: column; }
  .invoice-meta { text-align: left; }
  .invoice-title { font-size: 28px; letter-spacing: 2px; }
  .billing-section { flex-direction: column; }
  .invoice-footer-totals { flex-direction: column; }
  .totals-box { min-width: unset; width: 100%; }
  .toolbar { padding: 10px 16px; }
}
