/* Global Theme Variables */
:root {
  --primary: #0d6efd;
  --secondary: #6c757d;
  --light: #f8f9fa;
  --dark: #212529;
  --success: #198754;
  --warning: #ffc107;
  --radius: 12px;
  --border-color: #e3e6ea;
  --gradient: linear-gradient(135deg, #0d6efd 0%, #0856d0 100%);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode overrides - Optimized for readability and contrast */
.dark-mode {
  --light: #1a1d23;
  --border-color: #2d3139;
  --primary: #66b3ff;
  --dark: #e8eaed;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #38bdf8;
  --muted: #9ca3af;
  background-color: #0f1117;
  color: var(--dark);
}

body {
  background: var(--light);
  font-family: 'Poppins', sans-serif;
  color: #2d3436;
  line-height: 1.6;
  font-size: 14px;
  transition: background-color 0.3s ease, color 0.3s ease;
  letter-spacing: 0.01em;
}
.dark-mode body { color: var(--dark); }

.logo { max-width: 100px; }

.theme-toggle {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 12px;
}

.receipt-container {
  background: #fff;
  border-radius: 16px;
  padding: 36px;
  box-shadow: var(--shadow-md);
  margin-bottom: 32px;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  transition: var(--transition);
}

.receipt-container:hover {
  box-shadow: var(--shadow-lg);
}

.dark-mode .receipt-container { 
  background: #1a1d23;
  border-color: #2d3139;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

#documentOutput {
  background: #fff;
  padding: 40px;
  margin-top: 32px;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.dark-mode #documentOutput { 
  background: #1a1d23;
  color: #e8eaed;
}

h1, h2, h3, h4, h5, h6 { 
  color: var(--primary); 
  font-weight: 600;
  letter-spacing: 0.01em;
}

.section-title {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 10px;
  margin-bottom: 18px;
  font-weight: 600;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
}
.section-title:before {
  content: none;
  display: none;
}

/* Remove square icon in generated document output */
#documentOutput .section-title:before { content: none; display: none; }

.service-card {
  border: 2px solid var(--border-color);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 18px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  background: linear-gradient(135deg, #fff 0%, #fafbfc 100%);
  box-shadow: var(--shadow-sm);
}

.dark-mode .service-card { 
  background: linear-gradient(135deg, #1f2937 0%, #1a1d23 100%);
  border-color: #374151;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.service-card:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 20px rgba(13, 110, 253, 0.2);
  transform: translateY(-3px);
}

.service-card.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.06) 0%, rgba(13, 110, 253, 0.02) 100%);
  box-shadow: 0 4px 16px rgba(13, 110, 253, 0.25);
}

.dark-mode .service-card.selected { 
  background: linear-gradient(135deg, rgba(102, 179, 255, 0.2) 0%, rgba(102, 179, 255, 0.08) 100%);
  border-color: #66b3ff;
  box-shadow: 0 0 0 1px #66b3ff, 0 4px 12px rgba(102, 179, 255, 0.25);
}

.price-option {
  margin-left: 28px;
  margin-top: 12px;
  padding: 14px;
  background-color: rgba(13, 110, 253, 0.05);
  border-radius: 10px;
  border: 1px solid rgba(13, 110, 253, 0.1);
  transition: var(--transition);
}

.price-option:hover {
  background-color: rgba(13, 110, 253, 0.08);
}

.dark-mode .price-option { 
  background-color: rgba(102, 179, 255, 0.12);
  border-color: #374151;
  color: #e8eaed;
}

.feature-list { list-style: none; padding-left:0; margin:0; columns:2; }
.feature-list li {
  padding: 2px 0;
  position: relative;
  padding-left: 18px;
  font-size: 11px;
  line-height: 1.3;
  break-inside: avoid;
}
.feature-list li:before {
  content: "✓";
  color: var(--success);
  font-weight: bold;
  position: absolute;
  left: 0;
  font-size: 10px;
}

/* Feature list in pricing table */
.pricing-table .feature-list {
  columns: 1;
  margin-top: 8px;
  padding-left: 0;
}
.pricing-table .feature-list li {
  font-size: 12px;
  line-height: 1.5;
  padding: 4px 0 4px 20px;
  color: #555;
}
.dark-mode .pricing-table .feature-list li {
  color: #d1d5db;
}
.pricing-table .feature-list li:before {
  content: "•";
  color: var(--primary);
  font-size: 14px;
  left: 4px;
}

.pricing-table { 
  width: 100%; 
  border-collapse: collapse; 
  margin: 18px 0; 
  font-size: 13px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.pricing-table th, .pricing-table td { 
  padding: 12px 14px; 
  text-align: left; 
  border-bottom: 1px solid var(--border-color); 
  vertical-align: top;
  transition: background-color 0.2s ease;
}

.pricing-table tbody tr:hover {
  background-color: rgba(13, 110, 253, 0.02);
}

.pricing-table th { 
  background-color: rgba(13, 110, 253, 0.06); 
  font-weight: 600;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: #495057;
}

.dark-mode .pricing-table th { 
  background-color: rgba(102, 179, 255, 0.15);
  color: #e8eaed;
  border-color: #374151;
}

.pricing-table tr:last-child td { border-bottom: none; }

.total-row { 
  font-weight: 600; 
  background-color: rgba(13, 110, 253, 0.08);
  font-size: 14px;
}

.dark-mode .total-row { 
  background-color: rgba(77, 171, 247, 0.15);
}

.btn-primary { 
  background: linear-gradient(135deg, #0d6efd 0%, #0856d0 100%);
  border: none;
  padding: 12px 28px; 
  font-weight: 600;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
  transition: var(--transition);
  letter-spacing: 0.02em;
}

.btn-primary:hover { 
  background: linear-gradient(135deg, #0b5ed7 0%, #0747a6 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(13, 110, 253, 0.4);
}

.dark-mode .btn-primary { color: #fff; }

.document-header { 
  display: flex; 
  justify-content: space-between; 
  align-items: flex-start; 
  margin-bottom: 20px; 
  border-bottom: 3px solid var(--primary); 
  padding-bottom: 18px;
  gap: 20px;
}

.document-title { text-align: right; }

.document-title h2 { 
  font-size: 24px; 
  margin-bottom: 6px; 
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.document-info { 
  border: 2px solid var(--border-color); 
  padding: 16px; 
  border-radius: 12px; 
  background: linear-gradient(135deg, #f9f9f9 0%, #ffffff 100%);
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.dark-mode .document-info { 
  background: linear-gradient(135deg, #25282c 0%, #1f2124 100%);
  border-color: rgba(255, 255, 255, 0.1);
}

.document-to { 
  margin-top: 18px; 
  padding: 16px; 
  background: linear-gradient(135deg, #f9f9f9 0%, #ffffff 100%);
  border-radius: 12px; 
  margin-bottom: 18px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.dark-mode .document-to { 
  background: linear-gradient(135deg, #25282c 0%, #1f2124 100%);
  border-color: rgba(255, 255, 255, 0.1);
}

.document-footer { 
  margin-top: 28px; 
  padding-top: 20px; 
  border-top: 2px solid var(--border-color); 
  text-align: center;
  color: #6c757d;
  font-size: 13px;
}

.signature-section { margin-top:40px; display:flex; justify-content:space-between; gap:20px; flex-wrap:wrap; }
.signature-box { flex:1 1 240px; text-align:center; }
.signature-line { border-top:1px solid #000; margin:40px 0 10px; }
.service-details { font-size:11px; color:#555; margin-top:3px; }
.dark-mode .service-details { color:#ddd; }
.remarks-box { background-color:#fff3cd; border:1px solid #ffeaa7; border-radius:8px; padding:10px; margin:10px 0; }
.dark-mode .remarks-box { background:#3a3305; border-color:#8a6d00; }
.bank-details-box { background-color:#e7f3ff; border:1px solid #a8d5ff; border-radius:8px; padding:15px; margin:10px 0; }
.dark-mode .bank-details-box { background:#0a1e36; border-color:#1a4d7a; }
.company-info { font-size:12px; color:#666; line-height:1.4; }
.dark-mode .company-info { color:#bbb; }

.document-number-input { width:160px; display:inline-block; }
.free-item { color: var(--success); font-weight:600; }

.price-adjustment { background-color: rgba(255,193,7,0.15); padding:8px; border-radius:8px; border-left:3px solid var(--warning); margin-top:10px; }
.dark-mode .price-adjustment { background-color: rgba(255,193,7,0.22); }
.price-input, .quantity-input { display:inline-block; }
.adjustment-label { font-size:12px; font-weight:600; color:#856404; margin-bottom:5px; }
.dark-mode .adjustment-label { color:#f1c75b; }
.form-check-input { cursor:pointer; }
.document-type-selector { margin-bottom:20px; }

/* Category filters */
.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.05) 0%, rgba(13, 110, 253, 0.02) 100%);
  border-radius: 12px;
  margin-bottom: 24px;
  border: 1px solid rgba(13, 110, 253, 0.1);
}

.dark-mode .category-filters { 
  background: linear-gradient(135deg, rgba(77, 171, 247, 0.1) 0%, rgba(77, 171, 247, 0.05) 100%);
  border-color: rgba(77, 171, 247, 0.15);
}

.category-btn {
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 20px;
  transition: var(--transition);
  font-weight: 500;
  border-width: 2px;
}

.category-btn.active {
  background-color: var(--primary) !important;
  color: white !important;
  border-color: var(--primary) !important;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
  transform: translateY(-2px);
}

.category-btn:hover:not(.active) {
  background-color: rgba(13, 110, 253, 0.12);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.category-header {
  margin-top: 16px;
  border-top: 2px solid var(--border-color);
  padding-top: 20px;
}
.category-header:first-of-type { border-top: none; margin-top: 0; }
.category-header h5 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.service-item {
  transition: opacity 0.3s ease;
}

/* Accessibility focus */
.service-card:focus-within, .service-card:focus { outline:2px solid var(--primary); outline-offset:2px; }

/* Responsive tweaks */
@media (max-width: 768px) {
  .feature-list { columns:1; }
  .receipt-container { padding:20px; }
  #documentOutput { padding:18px; }
}

/* Print */
@media print {
  body * { visibility:hidden; }
  #documentOutput, #documentOutput * { visibility:visible; }
  /* Persistent header on each printed page */
  .print-header, .print-header * { visibility:visible; }
  .print-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 0 12px 2px 12px; /* remove top padding, minimal bottom */
    z-index: 9999;
  }
  .print-header-inner { max-width: 900px; margin: 0 auto; }

  /* Remove top offset so logo sits at the very top */
  #documentOutput { position: absolute; left: 0; top: 0; width: 100%; border: none; margin: 32px 0 0 0; padding: 12px 15px; box-shadow: none; font-size: 11pt; }
  .no-print { display:none !important; }
  .pricing-table { font-size:10pt; }
  .logo { max-width:80px !important; }
  .feature-list li { font-size:9pt; line-height: 1.4; }
  .service-details { font-size:9pt; }
  .document-title h2 { font-size:18pt; }

  /* Keep structure across pages */
  .document-header { page-break-after: avoid; margin-top: 0; }
  .document-footer { page-break-before: avoid; }
  .document-info, .document-to, .remarks-box, .bank-details-box, .signature-section { page-break-inside: avoid; }
  .service-card, .price-option { page-break-inside: avoid; }
  .pricing-table thead { display: table-header-group; }
  .pricing-table tfoot { display: table-footer-group; }
  .pricing-table tr { page-break-inside: avoid; }
  .pricing-table .feature-list { margin-top: 6px; }
}
