/* ========================================
   Bakuldigital — Pricelist Templates
   Templates: minimal | list | chips | table | compact
   ======================================== */

.pl-page {
  --pl-accent: #4f46e5;
  --pl-wa: #16a34a;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
}

.pl-shell {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 1rem 1.1rem 2rem;
}

/* ---------- Top ---------- */
.pl-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.pl-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: 9999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ---------- Template picker ---------- */
.pl-tpl-picker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.75rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.pl-tpl-picker-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.pl-tpl-picker-head small {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-faint);
}

.pl-tpl-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
}

.pl-tpl-btn {
  border: 1.5px solid var(--border);
  background: var(--surface-hover);
  color: var(--text-muted);
  border-radius: 0.65rem;
  padding: 0.45rem 0.2rem;
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  line-height: 1.25;
  transition: all 0.15s ease;
}

.pl-tpl-btn i {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.pl-tpl-btn.active {
  border-color: #818cf8;
  background: #eef2ff;
  color: #4338ca;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.12);
}

html.dark .pl-tpl-btn.active,
body.theme-dark .pl-tpl-btn.active {
  background: rgba(79, 70, 229, 0.2);
  color: #c7d2fe;
  border-color: #6366f1;
}

@media (max-width: 420px) {
  .pl-tpl-options {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Header simple ---------- */
.pl-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.pl-logo {
  width: 3rem;
  height: 3rem;
  border-radius: 0.85rem;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.pl-header-text h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.pl-header-text p {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Toolbar ---------- */
.pl-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
  position: sticky;
  top: 0.4rem;
  z-index: 15;
}

.pl-search {
  position: relative;
}

.pl-search > i {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 0.8rem;
  pointer-events: none;
}

.pl-search input {
  width: 100%;
  padding: 0.7rem 0.9rem 0.7rem 2.25rem;
  border: 1.5px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
}

.pl-search input:focus {
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.pl-categories {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.pl-categories::-webkit-scrollbar {
  display: none;
}

.pl-cat {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 9999px;
  padding: 0.4rem 0.7rem;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.pl-cat.active {
  background: var(--pl-accent);
  border-color: var(--pl-accent);
  color: #fff;
}

/* ---------- Shared ---------- */
.pl-main {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.pl-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.pl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  border-radius: 0.7rem;
  border: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.pl-btn-wa {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
  width: 100%;
  padding: 0.85rem;
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.25);
}

.pl-footer {
  margin-top: 1.5rem;
  text-align: center;
}

.pl-copy {
  margin: 0.85rem 0 0.35rem;
  font-size: 0.7rem;
  color: var(--text-faint);
}

.pl-help {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--pl-accent);
  text-decoration: none;
}

html.dark .pl-help,
body.theme-dark .pl-help {
  color: #a5b4fc;
}

.pl-price {
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--pl-accent);
  white-space: nowrap;
}

html.dark .pl-price,
body.theme-dark .pl-price {
  color: #a5b4fc;
}

.pl-old {
  font-size: 0.68rem;
  color: var(--text-faint);
  text-decoration: line-through;
  margin-right: 0.25rem;
}

.pl-tag {
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.12rem 0.4rem;
  border-radius: 9999px;
  background: #e0e7ff;
  color: #4338ca;
}

html.dark .pl-tag,
body.theme-dark .pl-tag {
  background: rgba(79, 70, 229, 0.22);
  color: #c7d2fe;
}

.pl-tag--hot { background: #fee2e2; color: #b91c1c; }
.pl-tag--new { background: #cffafe; color: #0e7490; }
.pl-tag--promo { background: #ffedd5; color: #c2410c; }

html.dark .pl-tag--hot,
body.theme-dark .pl-tag--hot { background: rgba(220,38,38,.2); color: #fca5a5; }
html.dark .pl-tag--new,
body.theme-dark .pl-tag--new { background: rgba(8,145,178,.2); color: #67e8f9; }
html.dark .pl-tag--promo,
body.theme-dark .pl-tag--promo { background: rgba(234,88,12,.2); color: #fdba74; }

.pl-ico {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: #f1f5f9;
  color: #334155;
}

html.dark .pl-ico,
body.theme-dark .pl-ico {
  background: #334155;
  color: #e2e8f0;
}

.pl-wa-mini {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dcfce7;
  color: #16a34a;
  text-decoration: none;
  flex-shrink: 0;
}

html.dark .pl-wa-mini,
body.theme-dark .pl-wa-mini {
  background: rgba(22, 163, 74, 0.2);
  color: #86efac;
}

.hidden { display: none !important; }

/* ========================================
   TEMPLATE 1 — MINIMAL (card simple)
   ======================================== */
.pl-tpl-minimal .pl-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.85rem;
}

.pl-tpl-minimal .pl-item-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.65rem;
}

.pl-tpl-minimal .pl-item-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
}

.pl-tpl-minimal .pl-item-meta {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.pl-tpl-minimal .pl-plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
}

.pl-tpl-minimal .pl-plan-row:first-of-type {
  border-top: none;
  padding-top: 0;
}

.pl-tpl-minimal .pl-plan-left {
  color: var(--text-secondary);
  min-width: 0;
}

.pl-tpl-minimal .pl-plan-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* ========================================
   TEMPLATE 2 — LIST (flat rows)
   ======================================== */
.pl-tpl-list .pl-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  overflow: hidden;
  gap: 0;
}

.pl-tpl-list .pl-item {
  border-bottom: 1px solid var(--border-light);
  padding: 0.75rem 0.9rem;
}

.pl-tpl-list .pl-item:last-child {
  border-bottom: none;
}

.pl-tpl-list .pl-item-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.45rem;
}

.pl-tpl-list .pl-item-name {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
}

.pl-tpl-list .pl-item-meta {
  margin: 0.1rem 0 0;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.pl-tpl-list .pl-plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.28rem 0 0.28rem 3.05rem;
  font-size: 0.78rem;
}

.pl-tpl-list .pl-plan-left {
  color: var(--text-muted);
}

.pl-tpl-list .pl-plan-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pl-tpl-list .pl-ico {
  width: 2.15rem;
  height: 2.15rem;
  font-size: 0.9rem;
}

/* ========================================
   TEMPLATE 3 — CHIPS (harga pill)
   ======================================== */
.pl-tpl-chips .pl-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.9rem;
}

.pl-tpl-chips .pl-item-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.75rem;
}

.pl-tpl-chips .pl-item-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
}

.pl-tpl-chips .pl-item-meta {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.pl-tpl-chips .pl-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pl-tpl-chips .pl-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.55rem 0.4rem 0.65rem;
  border-radius: 9999px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  font-size: 0.72rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.pl-tpl-chips .pl-chip:hover {
  border-color: #a5b4fc;
  background: #eef2ff;
}

html.dark .pl-tpl-chips .pl-chip:hover,
body.theme-dark .pl-tpl-chips .pl-chip:hover {
  background: rgba(79, 70, 229, 0.15);
}

.pl-tpl-chips .pl-chip-label {
  color: var(--text-muted);
  font-weight: 600;
}

.pl-tpl-chips .pl-chip .pl-price {
  font-size: 0.78rem;
}

.pl-tpl-chips .pl-chip i {
  color: #16a34a;
  font-size: 0.85rem;
}

/* ========================================
   TEMPLATE 4 — TABLE (rapi seperti menu)
   ======================================== */
.pl-tpl-table .pl-main {
  gap: 0.85rem;
}

.pl-tpl-table .pl-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  overflow: hidden;
}

.pl-tpl-table .pl-group-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-hover);
}

.pl-tpl-table .pl-group-head h2 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
  flex: 1;
}

.pl-tpl-table .pl-table {
  width: 100%;
  border-collapse: collapse;
}

.pl-tpl-table .pl-table th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--border-light);
}

.pl-tpl-table .pl-table td {
  padding: 0.6rem 0.85rem;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

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

.pl-tpl-table .pl-table td:last-child,
.pl-tpl-table .pl-table th:last-child {
  text-align: right;
}

.pl-tpl-table .pl-table-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  justify-content: flex-end;
}

/* ========================================
   TEMPLATE 5 — COMPACT (padat, 1 baris)
   ======================================== */
.pl-tpl-compact .pl-main {
  gap: 0.4rem;
}

.pl-tpl-compact .pl-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.6rem 0.7rem;
}

.pl-tpl-compact .pl-ico {
  width: 2rem;
  height: 2rem;
  font-size: 0.85rem;
  border-radius: 0.55rem;
}

.pl-tpl-compact .pl-item-name {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1.2;
}

.pl-tpl-compact .pl-item-meta {
  margin: 0.1rem 0 0;
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-tpl-compact .pl-item-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}

.pl-tpl-compact .pl-chevron {
  font-size: 0.65rem;
  color: var(--text-faint);
  transition: transform 0.2s ease;
  margin-top: 0.1rem;
}

.pl-tpl-compact .pl-item.is-open .pl-chevron {
  transform: rotate(180deg);
}

.pl-tpl-compact .pl-item {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pl-tpl-compact .pl-item.is-open {
  border-color: #c7d2fe;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.08);
}

.pl-tpl-compact .pl-price {
  font-size: 0.85rem;
}

.pl-tpl-compact .pl-from {
  font-size: 0.62rem;
  color: var(--text-faint);
  font-weight: 600;
}

.pl-tpl-compact .pl-item-link {
  text-decoration: none;
  color: inherit;
  display: contents;
}

/* Compact expand plans */
.pl-tpl-compact .pl-item.is-open {
  grid-template-columns: 1fr;
}

.pl-tpl-compact .pl-item.is-open .pl-item-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
}

.pl-tpl-compact .pl-item-top {
  display: contents;
}

.pl-tpl-compact .pl-expand {
  display: none;
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border-light);
}

.pl-tpl-compact .pl-item.is-open .pl-expand {
  display: block;
}

.pl-tpl-compact .pl-plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.78rem;
}

.pl-tpl-compact .pl-plan-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* wider shell for table on larger screens */
@media (min-width: 640px) {
  .pl-tpl-table .pl-shell,
  body.pl-tpl-table .pl-shell {
    max-width: 640px;
  }
}

body.pl-tpl-table .pl-shell {
  max-width: 560px;
}

/* ---------- Pricelist responsive + effects ---------- */
@keyframes pl-fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.pl-shell {
  padding-left: max(1.1rem, env(safe-area-inset-left));
  padding-right: max(1.1rem, env(safe-area-inset-right));
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

.pl-back,
.pl-cat,
.pl-btn,
.pl-app,
.pl-plan-row,
.pl-order-btn,
a[href*="wa.me"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.15s ease;
}

.pl-app,
.pl-card,
.pl-item {
  animation: pl-fade-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}

.pl-back:active,
.pl-cat:active,
.pl-btn:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .pl-app:hover,
  .pl-card:hover,
  .pl-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }

  .pl-cat:hover {
    transform: translateY(-1px);
  }

  .pl-btn-wa:hover,
  .pl-btn.pl-btn-wa:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(22, 163, 74, 0.28);
  }
}

.pl-categories {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0.15rem;
}

.pl-categories::-webkit-scrollbar {
  display: none;
}

.pl-cat {
  flex: 0 0 auto;
}

.pl-search input:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

@media (max-width: 380px) {
  .pl-shell {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .pl-header {
    gap: 0.65rem;
  }

  .pl-logo {
    width: 44px;
    height: 44px;
  }

  #plTitle {
    font-size: 1.1rem;
  }
}

@media (min-width: 768px) {
  .pl-shell {
    max-width: 560px;
    padding-top: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pl-app,
  .pl-card,
  .pl-item {
    animation: none;
  }
}
