* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --green-primary: #2db942;
  --green-dark: #003020;
  --green-darker: #00422b;
  --green-summary-bg: #edfff1;
  --gray-light: #aaaaaa;
  --gray-border: #dfdfdf;
  --gray-bg: #f7f7f8;
  --text-primary: #181818;
  --white: #ffffff;
}

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(180deg, #1a3a2a 0%, #2d5a45 30%, #3d7a5a 60%, #4a8a65 100%);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.5;
}

/* Loading state */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.spinner {
  border: 4px solid rgba(255,255,255,0.2);
  border-top: 4px solid var(--white);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-container p {
  color: var(--white);
  font-size: 16px;
  font-weight: 500;
}

/* Error state */
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  text-align: center;
}

.error-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.error-container h2 {
  color: var(--white);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.error-container p {
  color: rgba(255,255,255,0.7);
  font-size: 16px;
}

/* Main content */
#bill-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 100px; /* Space for fixed button */
}

/* Page title */
.page-title {
  text-align: center;
  padding: 20px 16px 24px;
  color: var(--white);
  font-size: 20px;
  font-weight: 700;
}

/* Receipt card */
.receipt-wrapper {
  display: flex;
  justify-content: center;
  padding: 0 16px;
}

.receipt-card {
  background: var(--white);
  width: 100%;
  max-width: 308px;
  border-radius: 12px;
  position: relative;
  padding: 28px 20px;
  /* Zigzag top edge */
  --zigzag-size: 10px;
}

/* Zigzag edges using pseudo-elements */
.receipt-card::before,
.receipt-card::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: var(--zigzag-size);
  background: linear-gradient(135deg, var(--white) 25%, transparent 25%) -10px 0,
              linear-gradient(225deg, var(--white) 25%, transparent 25%) -10px 0,
              linear-gradient(315deg, var(--white) 25%, transparent 25%),
              linear-gradient(45deg, var(--white) 25%, transparent 25%);
  background-size: 20px 20px;
}

.receipt-card::before {
  top: calc(-1 * var(--zigzag-size));
  transform: rotate(180deg);
}

.receipt-card::after {
  bottom: calc(-1 * var(--zigzag-size));
}

/* Business header */
.business-name {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 12px;
}

/* Invoice info */
.invoice-info {
  text-align: center;
  margin-bottom: 14px;
}

.invoice-number {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 14px;
  margin-bottom: 4px;
}

.invoice-number .label {
  color: var(--green-dark);
  font-weight: 400;
}

.invoice-number .value {
  color: var(--green-darker);
  font-weight: 700;
}

.invoice-datetime {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-size: 12px;
  color: var(--gray-light);
}

/* Divider */
.divider {
  border: none;
  border-top: 1px dashed var(--gray-border);
  margin: 14px 0;
}

/* Payment mode */
.payment-mode {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #111827;
  margin-bottom: 12px;
}

.payment-mode .label {
  font-weight: 700;
}

.payment-mode .value {
  font-weight: 500;
}

/* Items list */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 12px;
}

.item-row {
  display: flex;
  gap: 16px;
  align-items: center;
}

.item-image {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: var(--gray-bg);
  border: 0.833px solid #eeeded;
  border-radius: 3.333px;
  padding: 3.333px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 2px;
}

.item-image .placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.item-details {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.item-unit-price {
  font-weight: 700;
  color: var(--text-primary);
}

.item-total {
  color: #6B7280;
  font-weight: 500;
}

.item-total span {
  color: #111827;
  font-weight: 700;
}

/* Bill summary */
.bill-summary {
  background: var(--green-summary-bg);
  border-radius: 8px;
  padding: 8px;
  margin-top: 12px;
}

.summary-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.summary-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-border);
  margin-bottom: 8px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.summary-row .label {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-primary);
}

.summary-row .value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: right;
}

.summary-row.discount .value {
  color: #d32f2f;
}

.summary-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.summary-total .label {
  font-size: 16px;
  font-weight: 700;
  color: #070a03;
}

.summary-total .value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  text-align: right;
}

/* Fixed bottom button */
.bottom-button {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  padding: 16px;
  padding-bottom: 28px;
  box-shadow: 0 -6px 4px rgba(0,0,0,0.12);
}

.whatsapp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 343px;
  margin: 0 auto;
  height: 52px;
  background: var(--green-primary);
  border: none;
  border-radius: 8px;
  color: var(--white);
  font-family: 'Manrope', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.whatsapp-btn:hover {
  background: #25a036;
}

.whatsapp-btn:active {
  background: #1f8a2e;
}

.whatsapp-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Responsive */
@media (max-width: 360px) {
  .receipt-card {
    padding: 20px 16px;
  }
  
  .business-name {
    font-size: 20px;
  }
  
  .invoice-datetime {
    flex-direction: column;
    gap: 4px;
  }
}

@media (min-width: 600px) {
  .receipt-wrapper {
    padding-top: 20px;
  }
}
