/* =========================================
   PAYMENT RECEIPT SYSTEM — MAIN STYLES
   ========================================= */

:root {
  --primary: #4F46E5;
  --primary-dark: #3730A3;
  --primary-light: #EEF2FF;
  --accent: #10B981;
  --accent-dark: #059669;
  --danger: #EF4444;
  --warning: #F59E0B;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --border-focus: #A5B4FC;
  --bg-page: #F3F4F6;
  --bg-card: #FFFFFF;
  --bg-section: #FAFAFA;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --font: 'Inter', sans-serif;
  --header-h: 64px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* =========================================
   HEADER
   ========================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  box-shadow: 0 2px 10px rgba(79,70,229,0.4);
  height: var(--header-h);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.brand i { font-size: 22px; opacity: 0.9; }

.header-nav { display: flex; gap: 8px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-link:hover { background: rgba(255,255,255,0.15); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.2); color: #fff; }

/* =========================================
   MAIN CONTENT
   ========================================= */
.main-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.page-title { margin-bottom: 28px; }
.page-title h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-title h1 i { color: var(--primary); }
.page-title .subtitle {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* =========================================
   RECEIPT BANNER
   ========================================= */
.receipt-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg);
  padding: 20px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  color: white;
  box-shadow: var(--shadow-md);
}

.receipt-banner .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.75;
  display: block;
  margin-bottom: 4px;
}

.receipt-banner .value {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* =========================================
   FORM SECTIONS
   ========================================= */
.form-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px;
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
}
.section-header i {
  color: var(--primary);
  font-size: 18px;
  width: 22px;
  text-align: center;
}
.section-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-dark);
}

.section-body { padding: 24px; }

/* =========================================
   FORM ROWS & GROUPS
   ========================================= */
.form-row { display: flex; gap: 16px; margin-bottom: 16px; }
.form-row:last-child { margin-bottom: 0; }
.form-row.two-col > .form-group { flex: 1; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { flex: 1; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.required { color: var(--danger); }

input[type="text"],
input[type="number"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-card);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

textarea {
  resize: vertical;
  min-height: 80px;
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 18px;
  padding-right: 36px;
}

.custom-select-wrap { position: relative; flex: 1; }
.custom-select-wrap select { width: 100%; }

/* Input with leading icon */
.input-icon-wrap { position: relative; }
.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}
.input-icon-wrap input {
  padding-left: 34px;
}

/* Select with action button */
.select-with-action {
  display: flex;
  gap: 10px;
  align-items: center;
}
.select-with-action .custom-select-wrap { flex: 1; }

/* Field error */
.field-error {
  font-size: 12px;
  color: var(--danger);
  min-height: 16px;
  display: block;
}

/* Customer info card */
.customer-info-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--primary-light);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-top: 12px;
  animation: fadeIn 0.2s ease;
}
.customer-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}
.customer-details { display: flex; flex-direction: column; gap: 4px; }
.customer-name-badge {
  font-weight: 700;
  font-size: 15px;
  color: var(--primary-dark);
}
.info-detail {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}
.info-detail i { width: 12px; color: var(--primary); }
.info-detail span { }

/* =========================================
   SIGNATURE SECTION
   ========================================= */
.signatures-row { align-items: flex-start; }
.signature-group { flex: 1; }

.signature-box-wrap {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #FAFBFF;
  transition: border-color 0.2s;
  cursor: crosshair;
}
.signature-box-wrap:hover { border-color: var(--primary); }
.signature-box-wrap.has-sig { border-style: solid; border-color: var(--accent); }

.signature-canvas {
  display: block;
  width: 100%;
  height: 160px;
  touch-action: none;
}

.sig-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  pointer-events: none;
  transition: opacity 0.2s;
}
.sig-placeholder i { font-size: 24px; }
.sig-placeholder span { font-size: 12px; font-weight: 500; }
.sig-placeholder.hidden { opacity: 0; }

.sig-controls {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

/* =========================================
   BUTTONS
   ========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 14px rgba(79,70,229,0.4); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-page); color: var(--text-primary); }

.btn-success {
  background: var(--accent);
  color: #fff;
}
.btn-success:hover { background: var(--accent-dark); }

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 5px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* =========================================
   FORM ACTIONS
   ========================================= */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* =========================================
   MODAL
   ========================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

.modal-receipt { max-width: 480px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.success-header { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: white; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.success-header .modal-close { color: rgba(255,255,255,0.8); border-color: rgba(255,255,255,0.3); }

.modal-close {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--border);
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
  font-size: 14px;
}
.modal-close:hover { background: var(--bg-page); color: var(--text-primary); }

.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-section);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* =========================================
   RECEIPT PREVIEW (success modal)
   ========================================= */
.receipt-preview-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.receipt-preview-box .rp-header {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  text-align: center;
}
.receipt-preview-box .rp-header h4 { font-size: 16px; font-weight: 700; }
.receipt-preview-box .rp-header p { font-size: 12px; opacity: 0.8; margin-top: 2px; }

.rp-body { padding: 16px 20px; }
.rp-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.rp-row:last-child { border-bottom: none; }
.rp-row .rp-label { color: var(--text-secondary); }
.rp-row .rp-val { font-weight: 600; color: var(--text-primary); text-align: right; }
.rp-row.rp-total .rp-label { color: var(--primary); font-weight: 700; font-size: 15px; }
.rp-row.rp-total .rp-val { color: var(--primary); font-weight: 700; font-size: 18px; }

.rp-sigs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-section);
  border-radius: var(--radius-sm);
}
.rp-sig-box { text-align: center; }
.rp-sig-box img {
  width: 100%;
  height: 70px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
}
.rp-sig-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* =========================================
   RECORDS PAGE
   ========================================= */
.records-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.search-wrap input {
  padding-left: 36px;
  width: 100%;
}

.records-table-wrap {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--primary-light);
}
th {
  padding: 14px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-page); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: #D1FAE5; color: var(--accent-dark); }
.badge-blue { background: #EFF6FF; color: #1D4ED8; }
.badge-yellow { background: #FEF3C7; color: #92400E; }
.badge-purple { background: #F5F3FF; color: var(--primary-dark); }
.badge-gray { background: #F3F4F6; color: #374151; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px;
  border-top: 1px solid var(--border);
}
.page-btn {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--border);
  background: white;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 15px; }
.empty-state a { color: var(--primary); font-weight: 600; text-decoration: none; }

/* View detail modal */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.detail-item { padding: 12px; background: var(--bg-section); border-radius: 8px; }
.detail-item .d-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.detail-item .d-val { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.detail-item.full { grid-column: 1/-1; }
.detail-amount { background: var(--primary-light); }
.detail-amount .d-val { font-size: 20px; color: var(--primary); }

.detail-sigs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}
.detail-sig-box { text-align: center; }
.detail-sig-box img {
  width: 100%;
  height: 90px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
}
.detail-sig-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-top: 4px; }

/* =========================================
   STATS CARDS (records page)
   ========================================= */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.green { background: #D1FAE5; color: var(--accent-dark); }
.stat-icon.yellow { background: #FEF3C7; color: #92400E; }

.stat-info .stat-value { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.stat-info .stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* =========================================
   TOAST
   ========================================= */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-primary);
  color: white;
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transform: translateY(16px);
  transition: all 0.3s;
  pointer-events: none;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--accent-dark); }
.toast.error { background: var(--danger); }

/* =========================================
   ANIMATIONS
   ========================================= */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 640px) {
  .header-inner { padding: 0 16px; }
  .brand span { display: none; }
  .nav-link span { display: none; }
  .nav-link { padding: 8px 12px; }
  .main-content { padding: 20px 16px 48px; }
  .form-row.two-col { flex-direction: column; }
  .signatures-row { flex-direction: column; }
  .receipt-banner { flex-direction: column; gap: 8px; align-items: flex-start; }
  .stats-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-sigs { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
  .select-with-action { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
  .form-actions { flex-direction: column-reverse; }
  .btn { justify-content: center; }
  .modal { border-radius: var(--radius); }
}
