/* ═══════════════════════════════════════════════════════════════════════
   SORT A BRICK - Purchase Report Stylesheet
   Matches mockup_purchase_report.html design
   ═══════════════════════════════════════════════════════════════════════ */

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

body {
  background: #f5f5f0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #222;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* ─── Loading State ───────────────────────────────────────────────── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e0e0e0;
  border-top-color: #38A169;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Error State ─────────────────────────────────────────────────── */
.error-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.error-card {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.error-card h1 {
  color: #E53E3E;
  margin-bottom: 16px;
  font-size: 24px;
}

.error-card p {
  margin-bottom: 24px;
  color: #666;
}

.error-card button {
  background: #38A169;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.2s;
}

.error-card button:hover {
  background: #2F855A;
}

/* ─── Container ───────────────────────────────────────────────────── */
.container {
  max-width: 640px;
  margin: 0 auto;
  background: #fff;
  min-height: 100vh;
}

/* ─── Logo Bar ────────────────────────────────────────────────────── */
.logo-bar {
  background: #fff;
  padding: 24px 24px 20px;
  text-align: center;
}

.logo-img {
  height: 32px;
  width: auto;
}

/* ─── Header ──────────────────────────────────────────────────────── */
.header {
  background: linear-gradient(135deg, #2F855A 0%, #38A169 50%, #48BB78 100%);
  padding: 32px 24px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #E53E3E, #4299E1, #48BB78);
}

.header h1 {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.header .customer-name {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 6px;
}

.header .report-date {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
}

/* ─── Intro ───────────────────────────────────────────────────────── */
.intro {
  padding: 24px;
  padding-bottom: 0;
}

.intro p {
  font-size: 14px;
  line-height: 1.6;
  color: #555;
}

/* ─── Sections ────────────────────────────────────────────────────── */
.section {
  padding: 24px;
}

.section + .section {
  padding-top: 0;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: #333;
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}

/* ─── Stat Cards ──────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
}

.stat-card.full-width {
  grid-column: 1 / -1;
}

.stat-card .label {
  font-size: 11px;
  font-weight: 600;
  color: #4A5568;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 22px;
  font-weight: 900;
  color: #2C3E50;
}

.stat-card .value .unit {
  font-size: 14px;
  font-weight: 600;
  color: #666;
}

.stat-card.lego-weight {
  border: 2px solid #48BB78;
}

/* ─── Sets Table ─────────────────────────────────────────────────── */
.sets-table-wrapper {
  overflow-x: auto;
}

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

.sets-table thead th {
  background: #f8f9fa;
  font-size: 11px;
  font-weight: 700;
  color: #4A5568;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid #e2e8f0;
}

.sets-table thead th:last-child {
  text-align: center;
}

.sets-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  color: #333;
  vertical-align: middle;
}

.sets-table tbody tr:last-child td {
  border-bottom: none;
}

.sets-table tbody tr:hover {
  background: #f8f9fa;
}

.sets-table .completion-cell {
  text-align: center;
  font-weight: 700;
}

.sets-table tbody tr.collapsible {
  display: none;
}

.sets-table.expanded tbody tr.collapsible {
  display: table-row;
}

.toggle-sets-btn {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  color: #38A169;
  background: transparent;
  border: 1.5px solid #38A169;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.toggle-sets-btn:hover {
  background: #38A169;
  color: #fff;
}

/* ─── Unmatched Card ──────────────────────────────────────────────── */
.unmatched-card {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.unmatched-icon {
  width: 44px;
  height: 44px;
  background: #eee;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.unmatched-info {
  flex: 1;
}

.unmatched-info .unmatched-label {
  font-size: 12px;
  font-weight: 600;
  color: #4A5568;
  margin-bottom: 4px;
}

.unmatched-info .unmatched-value {
  font-size: 20px;
  font-weight: 900;
  color: #2C3E50;
}

.unmatched-info .unmatched-value .unit {
  font-size: 13px;
  font-weight: 600;
  color: #666;
}

.unmatched-info .unmatched-note {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
  line-height: 1.4;
}

/* ─── Payout ──────────────────────────────────────────────────────── */
.payout-card {
  background: linear-gradient(135deg, #fff8e1 0%, #fff3c4 100%);
  border: 2px solid #fdd835;
  border-radius: 12px;
  padding: 24px;
}

.payout-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  color: #555;
}

.payout-row .payout-label {
  font-weight: 500;
}

.payout-row .payout-value {
  font-weight: 600;
  color: #333;
}

.payout-divider {
  border: none;
  border-top: 1px dashed #ccc;
  margin: 10px 0;
}

.payout-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 0;
}

.payout-total .payout-label {
  font-size: 14px;
  font-weight: 700;
  color: #333;
}

.payout-total .payout-value {
  font-size: 28px;
  font-weight: 900;
  color: #2F855A;
}

/* ─── Form ────────────────────────────────────────────────────────── */
.form-card {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 24px;
}

.form-card .form-title {
  font-size: 16px;
  font-weight: 700;
  color: #333;
  margin-bottom: 6px;
}

.form-card .form-subtitle {
  font-size: 13px;
  color: #777;
  line-height: 1.5;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fff;
  color: #222;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #38A169;
}

.form-group input::placeholder {
  color: #bbb;
}

.form-group .hint {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 20px 0;
}

.consent-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: #38A169;
}

.consent-row label {
  font-size: 12px;
  line-height: 1.5;
  color: #666;
}

.consent-row a {
  color: #38A169;
  text-decoration: underline;
}

.form-error {
  background: #fee;
  border: 1px solid #E53E3E;
  color: #E53E3E;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}

.submit-btn {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  color: #fff;
  background: #38A169;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.submit-btn:hover {
  background: #2F855A;
}

.submit-btn:disabled {
  background: #999;
  cursor: not-allowed;
}

.privacy-note {
  font-size: 11px;
  color: #999;
  text-align: center;
  margin-top: 14px;
  line-height: 1.5;
}

/* ─── Submitted State ─────────────────────────────────────────────── */
.submitted-card {
  background: #f0fdf4;
  border: 2px solid #38A169;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
}

.success-icon {
  width: 64px;
  height: 64px;
  background: #38A169;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: bold;
  margin: 0 auto 16px;
}

.submitted-card h3 {
  color: #38A169;
  margin-bottom: 12px;
  font-size: 22px;
}

.submitted-card > p {
  color: #666;
  margin-bottom: 24px;
}

.submitted-details {
  background: white;
  border-radius: 8px;
  padding: 16px;
  text-align: left;
}

.submitted-details p {
  padding: 8px 0;
  font-size: 14px;
  color: #333;
}

.submitted-details strong {
  color: #666;
  font-weight: 600;
}

/* ─── Footer ──────────────────────────────────────────────────────── */
.footer {
  padding: 24px;
  border-top: 1px solid #eee;
  text-align: center;
}

.footer .company-name {
  font-size: 13px;
  font-weight: 700;
  color: #333;
  margin-bottom: 6px;
}

.footer .company-details {
  font-size: 11px;
  line-height: 1.6;
  color: #999;
}

.footer .company-details a {
  color: #38A169;
  text-decoration: none;
}

.footer .legal-text {
  font-size: 10px;
  color: #bbb;
  margin-top: 12px;
  line-height: 1.5;
}

/* ─── Responsive: Mobile ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .header { padding: 32px 20px 24px; }
  .header h1 { font-size: 20px; }
  .header .customer-name { font-size: 18px; }
  .section { padding: 20px; }
  .card-grid { gap: 8px; }
  .stat-card { padding: 16px 12px; }
  .stat-card .value { font-size: 18px; }
  .payout-total .payout-value { font-size: 24px; }
  .sets-table { font-size: 12px; }
  .sets-table thead th { padding: 8px 8px; }
  .sets-table tbody td { padding: 8px 8px; }
  .unmatched-info .unmatched-value { font-size: 18px; }
}
