/* Invoice Generator Tool Styles */

/* Invoice Layout */
.invoice-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.invoice-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.invoice-form::-webkit-scrollbar { width: 6px; }
.invoice-form::-webkit-scrollbar-track { background: transparent; }
.invoice-form::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.invoice-form::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

.invoice-preview-wrap {
  position: sticky;
  top: 80px;
}

/* Paper */
.invoice-paper {
  background: #fff;
  color: #333;
  box-shadow: 0 4px 24px rgba(0,0,0,.15);
  border-radius: 4px;
  padding: 36px;
  min-height: 500px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

.invoice-paper::-webkit-scrollbar { width: 6px; }
.invoice-paper::-webkit-scrollbar-track { background: transparent; }
.invoice-paper::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* Logo Upload */
.logo-upload {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s;
}

.logo-upload:hover {
  border-color: var(--primary);
}

.logo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  font-size: .85rem;
}

.logo-icon {
  font-size: 1.5rem;
}

#inv-logo-preview {
  max-width: 200px;
  max-height: 80px;
  margin: 0 auto;
  object-fit: contain;
}

.logo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: .75rem;
  padding: 3px 8px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.logo-remove:hover {
  opacity: .85;
}

/* Line Items Form */
.line-items-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.line-item-row {
  display: grid;
  grid-template-columns: 1fr 70px 90px 90px 32px;
  gap: 6px;
  align-items: end;
}

.line-item-row.line-item-header {
  align-items: end;
}

.line-item-row label {
  font-size: .78rem;
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: 2px;
}

.line-item-row input {
  width: 100%;
}

.line-item-amount {
  font-size: .88rem;
  font-weight: 600;
  padding: 9px 4px;
  text-align: right;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.line-item-remove {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 8px 4px;
  border-radius: 4px;
  align-self: end;
}

.line-item-remove:hover {
  background: rgba(239,68,68,.1);
}

/* Totals Form */
.totals-form {
  display: flex;
  flex-direction: column;
}

.totals-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.totals-label {
  font-size: .88rem;
  color: var(--text-dim);
}

.totals-value {
  font-size: .88rem;
  font-weight: 500;
  text-align: right;
  min-width: 80px;
}

.totals-total {
  padding-top: 8px;
  border-top: 2px solid var(--border);
}

.totals-total .totals-value {
  font-size: 1.05rem;
  color: var(--primary);
}

.discount-input {
  display: flex;
  gap: 4px;
  align-items: center;
}

.discount-input select,
.discount-input input {
  font-size: .85rem;
}

/* ===== Invoice Preview Styles ===== */

.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
  padding-bottom: 16px;
}

.inv-header-left {
  flex: 1;
  min-width: 0;
}

.inv-header-right {
  text-align: right;
  flex-shrink: 0;
}

.inv-logo-img {
  display: block;
  max-width: 120px;
  max-height: 50px;
  object-fit: contain;
  margin-bottom: 12px;
}

.inv-company-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.inv-company-details {
  font-size: .8rem;
  color: #666;
  white-space: pre-line;
  line-height: 1.4;
}

.inv-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.inv-meta {
  font-size: .82rem;
  color: #555;
  margin-top: 4px;
  line-height: 1.6;
}

.inv-meta strong {
  color: #333;
}

.inv-parties {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.inv-party {
  flex: 1;
}

.inv-party-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #999;
  font-weight: 600;
  margin-bottom: 4px;
}

.inv-party-name {
  font-size: .95rem;
  font-weight: 600;
  color: #1a1a1a;
}

.inv-party-details {
  font-size: .8rem;
  color: #555;
  white-space: pre-line;
  line-height: 1.4;
}

/* Line Items Table (Preview) */
.inv-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: .82rem;
}

.inv-items-table thead th {
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.inv-items-table thead th:last-child,
.inv-items-table thead th:nth-child(3),
.inv-items-table thead th:nth-child(4) {
  text-align: right;
}

.inv-items-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.inv-items-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
}

.inv-items-table tbody td:last-child,
.inv-items-table tbody td:nth-child(3),
.inv-items-table tbody td:nth-child(4) {
  text-align: right;
  white-space: nowrap;
}

.inv-items-table tbody td:nth-child(2) {
  text-align: center;
}

.inv-items-table thead th:nth-child(2) {
  text-align: center;
}

/* Totals (Preview) */
.inv-totals {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 24px;
}

.inv-totals-table {
  width: 250px;
}

.inv-totals-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: .85rem;
}

.inv-totals-row.inv-total-final {
  border-top: 2px solid #1a1a1a;
  margin-top: 4px;
  padding-top: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: #1a1a1a;
}

.inv-totals-row .inv-totals-label {
  color: #666;
}

.inv-totals-row .inv-totals-amount {
  font-weight: 600;
  text-align: right;
}

/* Notes (Preview) */
.inv-notes-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.inv-notes-title {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #999;
  font-weight: 600;
  margin-bottom: 4px;
}

.inv-notes-text {
  font-size: .82rem;
  color: #555;
  white-space: pre-line;
  line-height: 1.5;
}

/* Mobile toggle */
.mobile-toggle {
  display: none;
  gap: 8px;
  margin-bottom: 16px;
}

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

  .invoice-preview-wrap {
    position: static;
  }

  .invoice-form {
    max-height: none;
    padding-right: 0;
  }

  .invoice-paper {
    max-height: none;
  }

  .mobile-toggle {
    display: flex !important;
  }

  .line-item-row {
    grid-template-columns: 1fr 50px 70px 70px 28px;
    gap: 4px;
  }

  .inv-header {
    flex-direction: column;
    gap: 12px;
  }

  .inv-header-right {
    text-align: left;
  }

  .inv-parties {
    flex-direction: column;
    gap: 12px;
  }
}
