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

/* BASE */
html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #fff5f5;
  color: #333;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 15px;
}

/* ============ HEADER ============ */
header {
  background: linear-gradient(135deg, #e60000 0%, #cc0000 100%);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 4px 15px rgba(230, 0, 0, 0.25);
  text-align: center;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

h1 {
  color: white;
  font-size: 28px;
  margin-bottom: 5px;
  font-weight: 700;
  position: relative;
  z-index: 1;
  letter-spacing: 0.5px;
}

.bot-credit {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  text-align: center;
  color: rgba(255, 255, 255, 0.95);
  position: relative;
  z-index: 1;
}

.bot-credit a {
  text-decoration: none;
  color: #ffff00;
  margin: 0 3px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.bot-credit a:hover {
  text-decoration: underline;
  color: #fff;
}

/* ============ SEARCH BOX ============ */
.search-box {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-box input {
  flex: 1;
  min-width: 200px;
  padding: 12px 15px;
  border: 2px solid #e60000;
  border-radius: 25px;
  font-size: 14px;
  outline: none;
  background: white;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(230, 0, 0, 0.1);
}

.search-box input:focus {
  border-color: #ff6666;
  box-shadow: 0 4px 12px rgba(230, 0, 0, 0.2);
}

.search-box button {
  padding: 12px 25px;
  background: linear-gradient(135deg, #e60000 0%, #cc0000 100%);
  color: white;
  border: none;
  border-radius: 25px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(230, 0, 0, 0.2);
  white-space: nowrap;
  font-size: 14px;
}

.search-box button:hover {
  background: linear-gradient(135deg, #ff6666 0%, #ff3333 100%);
  box-shadow: 0 4px 12px rgba(230, 0, 0, 0.3);
  transform: translateY(-1px);
}

.search-box button:active {
  transform: translateY(0);
}

/* ============ LOADING ============ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  padding: 30px;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #ffe6e6;
  border-top: 4px solid #e60000;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading p {
  color: #e60000;
  font-weight: 600;
  font-size: 14px;
}

/* ============ ERROR MESSAGE ============ */
.error-message {
  background: linear-gradient(135deg, #ff9999 0%, #ff6666 100%);
  color: white;
  padding: 15px;
  border-radius: 8px;
  text-align: center;
  margin-bottom: 15px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(230, 0, 0, 0.2);
}

/* ============ PRODUCT LIST ============ */
.product-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

/* ============ PRODUCT CARD (Compact untuk HP) ============ */
.product-card {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  border: 1px solid #f0f0f0;
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(230, 0, 0, 0.18);
  border-color: #e60000;
}

/* gambar list – lebih rapat & tidak terpotong */
.product-img {
  width: 100%;
  height: 110px;
  object-fit: contain;
  background: #f5f5f5;
  padding: 2px;
}

.product-info {
  padding: 4px 8px;
}

.product-name {
  font-size: 11px;
  font-weight: 600;
  color: #333;
  margin: 0 0 2px 0;

  line-height: 1.2;

  word-break: break-word;
  overflow-wrap: anywhere;
}

.product-meta {
  display: flex;
  gap: 2px;
  margin-top: -2px;
  margin-bottom: 0;
  align-items: center;
  flex-wrap: wrap;
}

.plu {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: #999;
  background: #f5f5f5;
  padding: 2px 4px;
  border-radius: 4px;
}

.promo-badge {
  background: #ffcc00;
  color: #333;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 7px;
  font-weight: 700;
  line-height: 1;
}

/* barcode kecil tepat nempel di bawah PLU */
.product-barcode {
  margin-top: 0;
  line-height: 1; /* rapat */
}

.barcode-value {
  display: inline-block;
  font-size: 9px;
  color: #777;
  font-family: 'Courier New', monospace;
  background: #f0f0f0;
  padding: 1px 4px;
  border-radius: 4px;
}

.barcode-label {
  display: none;
}


.product-prices {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.price-promo {
  background: linear-gradient(135deg, #e60000 0%, #cc0000 100%);
  color: white;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(230, 0, 0, 0.3);
}

.price-normal {
  background: linear-gradient(135deg, #e60000 0%, #cc0000 100%);
  color: white;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(230, 0, 0, 0.3);
}

.price-original {
  color: #999;
  text-decoration: line-through;
  font-size: 9px;
}

/* ============ PRODUCT DETAIL MODAL ============ */
.product-detail {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  padding: 15px;
  overflow-y: auto;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.detail-content {
  background: white;
  border-radius: 15px;
  overflow: hidden;
  max-width: 550px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
  max-height: 95vh;
  overflow-y: auto;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: linear-gradient(135deg, #e60000 0%, #cc0000 100%);
  border: none;
  color: white;
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(230, 0, 0, 0.3);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: linear-gradient(135deg, #ff6666 0%, #ff3333 100%);
  transform: scale(1.1) rotate(90deg);
}

/* ============ IMAGE SECTION ============ */
.image-section {
  width: 100%;
  height: 350px;
  background: linear-gradient(135deg, #fff5f5 0%, #ffe6e6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* gambar di modal – supaya utuh */
.image-section img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* ============ INFO SECTION ============ */
/* tanpa padding seperti permintaan */
.info-section {
  padding: 0;
}

.info-section h2 {
  font-size: 20px;
  color: #333;
  margin-bottom: 8px;
  font-weight: 700;
}

.description {
  color: #666;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 15px;
}

/* ============ SPECS SECTION ============ */
.specs-section {
  background: linear-gradient(135deg, #fff5f5 0%, #ffe6e6 100%);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 15px;
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  border: 1px solid #ffcccc;
}

.spec-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spec-item .label {
  font-size: 11px;
  color: #999;
  font-weight: 600;
  text-transform: uppercase;
}

.spec-item .value {
  font-size: 13px;
  color: #333;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

/* ============ PRICE SECTION (DETAIL) ============ */
.price-section {
  margin-bottom: 20px;
}

.price-item {
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.price-item.promo {
  background: linear-gradient(135deg, #ffff99 0%, #ffff66 100%);
  border: 1px solid #ffff00;
}

.price-item.normal,
.price-item.original {
  background: linear-gradient(135deg, #ff6666 0%, #e60000 100%);
  color: white;
}

.price-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  opacity: 0.9;
}

.price-value {
  font-size: 24px;
  font-weight: 700;
}

.price-value.strikethrough {
  text-decoration: line-through;
  font-size: 16px;
  opacity: 0.8;
}

/* ============ BARCODE SECTION (DETAIL) ============ */
.barcode-section {
  border-top: 2px solid #e60000;
  padding-top: 15px;
  margin-top: 15px;
}

.barcode-section h3 {
  font-size: 15px;
  color: #333;
  margin-bottom: 10px;
  font-weight: 700;
}

.barcode-container {
  background: linear-gradient(135deg, #fff5f5 0%, #ffe6e6 100%);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.barcode-container img {
  max-width: 100%;
  max-height: 280px;
  border: 2px solid #e60000;
  border-radius: 6px;
  padding: 8px;
  background: white;
}

.barcode-text {
  text-align: center;
  font-size: 12px;
  color: #666;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  margin: 0;
  word-break: break-all;
  background: #f5f5f5;
  padding: 10px;
  border-radius: 6px;
}

/* ============ RESPONSIVE - TABLET ============ */
@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  header {
    padding: 15px;
    margin-bottom: 15px;
  }

  h1 {
    font-size: 24px;
    margin-bottom: 3px;
  }

  .search-box {
    gap: 8px;
    margin-bottom: 15px;
  }

  .product-list {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .product-img {
    height: 100px;
  }

  .product-name {
    font-size: 11px;
  }

  .image-section {
    height: 300px;
  }

  .info-section {
    padding: 0;
  }

  .info-section h2 {
    font-size: 18px;
  }
}

/* ============ RESPONSIVE - MOBILE ============ */
@media (max-width: 480px) {
  .container {
    padding: 10px;
  }

  header {
    padding: 12px;
    margin-bottom: 12px;
  }

  h1 {
    font-size: 20px;
    margin-bottom: 2px;
  }

  .bot-credit {
    font-size: 11px;
  }

  .search-box {
    gap: 6px;
    margin-bottom: 12px;
  }

  .search-box input {
    padding: 10px 12px;
    font-size: 13px;
    min-width: 150px;
  }

  .search-box button {
    padding: 10px 20px;
    font-size: 13px;
  }

  .product-list {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
  }

  .product-img {
    height: 90px;
  }

  .product-info {
    padding: 6px 8px;
  }

  .product-name {
  font-size: 11px;
  font-weight: 600;
  color: #333;
  margin: 0 0 3px 0;
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: anywhere;
}

  .product-meta {
    gap: 4px;
    margin-bottom: 3px;
  }

  .plu {
    font-size: 9px;
    padding: 2px 4px;
  }

  .promo-badge {
    font-size: 9px;
    padding: 2px 6px;
  }

  .product-prices {
    gap: 4px;
  }

  .price-promo,
  .price-normal {
    padding: 3px 6px;
    font-size: 10px;
  }

  .price-original {
    font-size: 9px;
  }

  .product-detail {
    padding: 10px;
  }

  .detail-content {
    max-width: 100%;
    border-radius: 12px;
  }

  .close-btn {
    width: 36px;
    height: 36px;
    font-size: 20px;
    top: 10px;
    right: 10px;
  }

  .image-section {
    height: 250px;
  }

  .info-section {
    padding: 0;
  }

  .info-section h2 {
    font-size: 16px;
    margin-bottom: 6px;
  }

  .description {
    font-size: 12px;
    margin-bottom: 12px;
  }

  .specs-section {
    padding: 10px;
    gap: 10px;
    margin-bottom: 12px;
  }

  .spec-item .label {
    font-size: 10px;
  }

  .spec-item .value {
    font-size: 12px;
  }

  .price-section {
    margin-bottom: 15px;
  }

  .price-item {
    padding: 12px;
    margin-bottom: 8px;
  }

  .price-label {
    font-size: 10px;
  }

  .price-value {
    font-size: 20px;
  }

  .price-value.strikethrough {
    font-size: 14px;
  }

  .barcode-section {
    padding-top: 12px;
    margin-top: 12px;
  }

  .barcode-section h3 {
    font-size: 14px;
    margin-bottom: 8px;
  }

  .barcode-container {
    min-height: 180px;
    padding: 8px;
  }

  .barcode-container img {
    max-height: 240px;
    border-width: 2px;
    padding: 6px;
  }

  .barcode-text {
    font-size: 11px;
    padding: 8px;
  }

  .loading {
    padding: 20px;
    gap: 12px;
  }

  .spinner {
    width: 35px;
    height: 35px;
    border-width: 3px;
  }

  .loading p {
    font-size: 13px;
  }

  .error-message {
    padding: 12px;
    font-size: 13px;
    margin-bottom: 12px;
  }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f5f5f5;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #e60000 0%, #cc0000 100%);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #ff6666 0%, #ff3333 100%);
}

.loading-spin {
  display: inline-block;
  animation: spinBarcode 1s linear infinite;
}

@keyframes spinBarcode {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.detail-title-row,
.barcode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.id-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.copy-btn-mini {
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 5px;
}

.copy-btn {
  border: none;
  background: #e60000;
  color: white;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
}

.copy-btn:hover {
  opacity: 0.9;
}

.input-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.input-wrapper input {
  width: 100%;
  padding-right: 40px;
}

#clear-search {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);

  border: none;
  background: transparent;
  color: #999;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
}

#clear-search:hover {
  color: #e60000;
}

.search-history {
  display: none;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
}

.history-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f2f2f2;
  font-size: 14px;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item:hover {
  background: #fff5f5;
}

.history-icon {
  color: #999;
  margin-right: 8px;
}

.history-header {
  padding: 8px 12px;
  background: #f8f8f8;
  font-size: 12px;
  font-weight: bold;
  color: #666;
  display: flex;
  justify-content: space-between;
}

.clear-history-btn {
  color: #e60000;
  cursor: pointer;
}

.spec-card {
  flex: 1;
  min-width: 140px;
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  border: 1px solid #ffd0d0;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

.detail-title-row {
  padding: 15px;
  border-bottom: 1px solid #eee;
}

.price-section {
  padding: 0 15px;
}

.barcode-text-section {
  padding: 0 15px 15px;
}

.barcode-header {
  margin-bottom: 10px;
}

.detail-footer {
  margin-top: 15px;
  text-align: center;
  font-size: 11px;
  color: #888;
  border-top: 1px solid #eee;
  padding-top: 12px;
}

.detail-content {
  border-radius: 20px;
}

.barcode-container {
  border-radius: 12px;
}

.specs-section {
  margin: 15px;
}