/* ==========================================================================
   APLIKASI CETAK NOTA PENJUALAN - THERMAL PRINTER
   Modern UI / UX Stylesheet (Screen Display)
   ========================================================================== */

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --secondary: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --dark: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --bg-app: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --font-main: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-thermal: 'Courier New', Courier, monospace;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--slate-800);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header Navbar */
.app-navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.navbar-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--dark);
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.brand-info h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--dark);
}

.brand-info p {
  font-size: 0.75rem;
  color: var(--slate-500);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Badge & Buttons */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--slate-100);
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.btn-secondary {
  background: #fff;
  color: var(--slate-700);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: var(--slate-100);
  border-color: var(--slate-400);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  filter: brightness(0.95);
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: #fecaca;
}
.btn-danger-outline:hover {
  background: #fee2e2;
  border-color: var(--danger);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
}

/* Main Layout: Split Screen (Left: Controls, Right: Live Receipt Preview) */
.main-layout {
  max-width: 1440px;
  margin: 1.5rem auto;
  padding: 0 1.5rem 3rem;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 1fr);
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* Control Panel (Left Column) */
.control-panel {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  background: var(--slate-100);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 0.5rem 0;
  gap: 0.25rem;
  overflow-x: auto;
}

.tab-btn {
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-600);
  background: transparent;
  border: none;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--primary);
  background: rgba(255, 255, 255, 0.6);
}

.tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 -2px 5px rgba(0,0,0,0.03);
  border-bottom: 2px solid var(--primary);
}

.tab-content {
  padding: 1.5rem;
  display: none;
}

.tab-content.active {
  display: block;
}

/* Form Styles */
.form-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--slate-800);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 640px) {
  .form-grid-2, .form-grid-3 {
    grid-template-columns: 1fr;
  }
}

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--slate-700);
}

.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  outline: none;
  background-color: #fff;
  color: var(--slate-800);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 70px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.form-check input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Items Table */
.items-table-wrapper {
  overflow-x: auto;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.items-table th {
  background: var(--slate-100);
  color: var(--slate-700);
  font-weight: 600;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.items-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--slate-200);
  vertical-align: middle;
}

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

.items-table input.item-input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.825rem;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  outline: none;
}

.items-table input.item-input:focus {
  border-color: var(--primary);
}

.items-table .td-price,
.items-table .td-qty,
.items-table .td-subtotal {
  width: 120px;
}

.items-table .td-qty {
  width: 75px;
}

.items-table .td-subtotal {
  font-weight: 600;
  text-align: right;
  color: var(--slate-800);
}

.items-table .td-action {
  width: 45px;
  text-align: center;
}

/* Calculation Summary Card */
.calc-summary-card {
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-top: 1.25rem;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  font-size: 0.875rem;
}

.calc-row.grand-total-row {
  border-top: 2px dashed var(--slate-300);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
}

.calc-row.kembalian-row {
  font-weight: 700;
  color: var(--success);
  border-top: 1px solid var(--slate-200);
  margin-top: 0.4rem;
  padding-top: 0.5rem;
}

/* Upload Dropzone Preview */
.upload-dropzone {
  border: 2px dashed var(--slate-300);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
  background: var(--slate-100);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.upload-dropzone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-dropzone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

.dropzone-img-preview {
  max-width: 120px;
  max-height: 80px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--slate-200);
  padding: 4px;
}

/* Radio Paper Selector Cards */
.paper-selector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.paper-option-card {
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
  position: relative;
}

.paper-option-card:hover {
  border-color: var(--primary);
}

.paper-option-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.paper-option-card input[type="radio"] {
  display: none;
}

.paper-option-card .paper-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--slate-800);
  display: block;
}

.paper-option-card .paper-desc {
  font-size: 0.75rem;
  color: var(--slate-500);
}

/* ==========================================================================
   RIGHT COLUMN: LIVE RECEIPT PREVIEW (Screen simulation)
   ========================================================================== */
.preview-column {
  position: sticky;
  top: 5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-toolbar {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.preview-toolbar-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--slate-700);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.preview-container-box {
  background: #cbd5e1;
  background-image: radial-gradient(#94a3b8 1px, transparent 1px);
  background-size: 16px 16px;
  border-radius: var(--radius-lg);
  padding: 2rem 1rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 520px;
  max-height: calc(100vh - 12rem);
  overflow-y: auto;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

/* Realistic Thermal Receipt Paper */
.receipt-paper {
  background: #ffffff;
  color: #000000;
  font-family: var(--font-thermal);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.25);
  padding: 16px 14px 24px;
  transition: width 0.3s ease;
  position: relative;
  word-break: break-word;
  user-select: none;
}

/* Default dynamic widths based on thermal paper selection */
.receipt-paper.paper-58mm {
  width: 250px; /* ~58mm physical simulated display */
  font-size: 11px;
  line-height: 1.35;
}

.receipt-paper.paper-80mm {
  width: 340px; /* ~80mm physical simulated display */
  font-size: 13px;
  line-height: 1.4;
}

.receipt-paper.paper-custom {
  /* dynamically styled via inline width */
  font-size: 12px;
  line-height: 1.35;
}

/* Paper Zig-Zag Bottom Edge (Simulated paper tear-off) */
.receipt-paper::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  height: 8px;
  background: radial-gradient(circle, transparent, transparent 50%, #ffffff 50%, #ffffff 100%);
  background-size: 12px 12px;
}

/* Receipt Elements Inside Paper */
.receipt-header {
  text-align: center;
  margin-bottom: 8px;
}

.receipt-store-info {
  text-align: center;
}

.receipt-logo-container {
  display: block;
}

.receipt-logo-container.no-logo,
.no-logo .receipt-logo-container,
.receipt-logo-container[style*="display: none"] {
  display: none !important;
}

.receipt-logo {
  max-width: 80px;
  max-height: 60px;
  object-fit: contain;
  margin: 0 auto 6px;
  display: block;
  filter: grayscale(100%) contrast(150%);
}

.receipt-logo.no-logo,
.no-logo .receipt-logo,
.receipt-logo:not([src]),
.receipt-logo[src=""],
.receipt-logo[style*="display: none"] {
  display: none !important;
}

/* Layout khusus jika ukuran nota > 100 mm dan ada logo:
   Logo di sisi kiri, tulisan header (nama, alamat, telp) menggunakan ALIGN CENTER */
.receipt-paper.paper-gt-100mm.has-logo .receipt-header {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
}

.receipt-paper.paper-gt-100mm.has-logo .receipt-logo-container {
  margin: 0;
  max-width: 95px;
  max-height: 75px;
  flex-shrink: 0;
  display: block;
}

.receipt-paper.paper-gt-100mm.has-logo .receipt-logo {
  margin: 0;
  max-width: 95px;
  max-height: 75px;
  flex-shrink: 0;
  display: block;
}

.receipt-paper.paper-gt-100mm .receipt-store-info {
  flex: 1;
  text-align: center;
}

.receipt-paper.paper-gt-100mm .receipt-store-name,
.receipt-paper.paper-gt-100mm .receipt-store-address,
.receipt-paper.paper-gt-100mm .receipt-store-phone {
  text-align: center;
}

.receipt-store-name {
  font-size: 1.15em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.receipt-store-address,
.receipt-store-phone {
  font-size: 0.88em;
  line-height: 1.3;
}

.receipt-divider {
  border: none;
  border-top: 1px dashed #000000;
  margin: 6px 0;
}

.receipt-divider-double {
  border: none;
  border-top: 1px double #000000;
  border-top-width: 3px;
  margin: 6px 0;
}

.receipt-meta {
  font-size: 0.88em;
  line-height: 1.35;
  margin-bottom: 6px;
}

.receipt-meta-row {
  display: flex;
  justify-content: space-between;
}

/* Receipt Items */
.receipt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  margin: 4px 0;
}

.receipt-table th {
  border-top: 1px dashed #000;
  border-bottom: 1px dashed #000;
  padding: 3px 0;
  font-weight: 700;
  text-transform: uppercase;
}

.receipt-table td {
  padding: 2px 0;
  vertical-align: top;
}

.receipt-table .text-left { text-align: left; }
.receipt-table .text-center { text-align: center; }
.receipt-table .text-right { text-align: right; }

.receipt-item-row {
  margin-bottom: 2px;
}

.receipt-item-name {
  font-weight: 600;
}

.receipt-item-details {
  display: flex;
  justify-content: space-between;
  font-size: 0.92em;
}

/* Totals Summary */
.receipt-totals {
  font-size: 0.92em;
  line-height: 1.4;
  margin: 4px 0;
}

.receipt-total-row {
  display: flex;
  justify-content: space-between;
}

.receipt-total-row.grand {
  font-weight: 800;
  font-size: 1.08em;
  padding: 2px 0;
}

/* Stamp & Authorization */
.receipt-footer-stamp {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
}

.receipt-footer-stamp.align-center {
  align-items: center;
  text-align: center;
}

.receipt-footer-stamp.align-right {
  align-items: flex-end;
  text-align: right;
}

.stamp-title-text {
  font-size: 0.88em;
  font-weight: 600;
  margin-bottom: 4px;
}

.stamp-img-container {
  display: inline-block;
  margin: 4px 0;
}

.stamp-img {
  object-fit: contain;
  transition: filter 0.2s ease;
}

.stamp-img.stamp-monochrome,
body.stamp-mode-monochrome .stamp-img {
  filter: grayscale(100%) contrast(180%);
}

.stamp-img.stamp-color,
body.stamp-mode-color .stamp-img {
  filter: none !important;
}

.stamp-signer-name {
  font-size: 0.88em;
  border-top: 1px dotted #000;
  padding-top: 2px;
  min-width: 90px;
  text-align: center;
}

/* Footer Greeting */
.receipt-footer-notes {
  margin-top: 12px;
  text-align: center;
  font-size: 0.82em;
  line-height: 1.3;
  white-space: pre-line;
}

/* History Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--dark);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--slate-100);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--dark);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success { background: #065f46; border-left: 4px solid var(--success); }
.toast.error { background: #7f1d1d; border-left: 4px solid var(--danger); }
.toast.info { background: #1e293b; border-left: 4px solid var(--secondary); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
