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

body {
  font-family: 'Inter', sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── Layout ── */
.app {
  display: flex;
  gap: 40px;
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 24px;
  align-items: flex-start;
}

/* ── Form Panel ── */
.form-panel {
  flex: 1;
  max-width: 420px;
  position: sticky;
  top: 40px;
}

.form-title {
  font-size: 24px;
  font-weight: 800;
  color: #1a1a2e;
}

.form-subtitle {
  font-size: 14px;
  color: #6b7280;
  margin-top: 4px;
  margin-bottom: 28px;
}

.form-section {
  margin-bottom: 24px;
}

.form-section h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #4361ee;
  margin-bottom: 12px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 4px;
}

.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  color: #1a1a2e;
  transition: border-color 0.2s;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: #4361ee;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
}

/* Items */
.item-card {
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.item-row-top {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.item-row-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
}

.item-row-bottom label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
}

.item-row-bottom input {
  width: 90px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  color: #1a1a2e;
}

.item-row-bottom select {
  padding: 8px 10px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  background: #fff;
  color: #1a1a2e;
  cursor: pointer;
}

.item-row-bottom input:focus,
.item-row-bottom select:focus {
  outline: none;
  border-color: #4361ee;
}

.btn-remove-item {
  width: 36px;
  height: 36px;
  border: none;
  background: #fee2e2;
  color: #ef4444;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  margin-bottom: 12px;
  transition: background 0.2s;
}

.btn-remove-item:hover {
  background: #fca5a5;
}

.btn-add-item {
  width: 100%;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: #4361ee;
  background: #eef2ff;
  border: 1.5px dashed #4361ee;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-add-item:hover {
  background: #dbeafe;
}

.btn-print {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  color: #fff;
  background: #4361ee;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s, transform 0.1s;
}

.btn-print:hover {
  background: #3651d4;
}

.btn-print:active {
  transform: scale(0.98);
}

/* ── Preview Panel ── */
.preview-panel {
  flex: 1;
  max-width: 600px;
}

.preview-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #9ca3af;
  margin-bottom: 12px;
}

/* ── Receipt ── */
.receipt {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.06);
  padding: 48px 48px 0;
  position: relative;
  border: 1px solid #f0f0f0;
}

.receipt-header {
  margin-bottom: 36px;
}

.company-name {
  font-size: 22px;
  font-weight: 800;
  color: #1e3a8a;
  letter-spacing: 0.5px;
}

.company-email {
  font-size: 13px;
  color: #4b5563;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-mail {
  font-size: 14px;
  color: #6b7280;
}

/* Meta (Recipient + Receipt Info) */
.receipt-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 40px;
}

.meta-left { flex: 1; }
.meta-right { text-align: right; }

.meta-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}

.meta-value {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a2e;
  margin-top: 2px;
}

.receipt-title {
  font-size: 28px;
  font-weight: 800;
  color: #1a1a2e;
  margin-bottom: 12px;
}

/* Table */
.receipt-table {
  margin-bottom: 0;
}

.table-header {
  display: flex;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 2px solid #e5e7eb;
}

.table-header span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #4361ee;
}

.col-desc { flex: 2; }
.col-price { flex: 1; text-align: right; }
.col-discount { flex: 1.5; text-align: right; }
.col-final { flex: 1.2; text-align: right; }

.table-row {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 14px;
}

.table-row .col-desc {
  color: #374151;
}

.table-row .col-price {
  color: #6b7280;
  font-weight: 500;
}

.table-row .col-discount {
  color: #ef4444;
  font-weight: 500;
}

.table-row .col-final {
  color: #1a1a2e;
  font-weight: 600;
}



/* Total */
.receipt-total {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  padding: 16px 0;
  border-top: 2px solid #e5e7eb;
  margin-top: 0;
}

.total-label {
  font-size: 15px;
  font-weight: 800;
  color: #1a1a2e;
}

.total-value {
  font-size: 16px;
  font-weight: 800;
  color: #4361ee;
}

/* Footer */
.receipt-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 48px;
  padding-bottom: 24px;
}

.gstin-value {
  font-size: 14px;
  font-weight: 700;
  color: #1a1a2e;
  margin-top: 2px;
}

.thanks {
  font-size: 15px;
  font-style: italic;
  font-weight: 600;
  color: #1a1a2e;
}

.receipt-bar {
  background: #4361ee;
  color: #fff;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  padding: 12px;
  margin: 0 -48px;
  border-radius: 0 0 8px 8px;
}

/* PDF capture mode — clean rectangle, no shadows */
.receipt.pdf-mode {
  border-radius: 0;
  box-shadow: none;
  border: none;
}

.receipt.pdf-mode .receipt-bar {
  border-radius: 0;
}

/* ── Print Styles ── */
@page {
  margin: 0;
  size: auto;
}

@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: #fff;
    margin: 0;
    padding: 0;
  }

  .form-panel,
  .preview-label {
    display: none !important;
  }

  .app {
    margin: 0;
    padding: 0;
    display: block;
  }

  .preview-panel {
    max-width: 100%;
    width: 100%;
  }

  .receipt {
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 60px 60px 0;
    width: 100%;
    max-width: 100%;
  }

  .receipt-bar {
    margin: 0 -60px;
    border-radius: 0;
  }
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .app {
    flex-direction: column;
    align-items: center;
  }

  .form-panel {
    position: static;
    max-width: 100%;
    width: 100%;
  }

  .preview-panel {
    max-width: 100%;
    width: 100%;
  }
}
