/* Coffee Calculator Pro — Frontend v4 */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

.ccp-wrap {
  --cp: #5C3317; --ca: #D4A853;
  --bg: #FEFAF5; --bg2: #F9F2E7; --bd: #E8D5BC; --bd2: #D4B896;
  --tx: #2A1505; --tx2: #7A5030; --tx3: #A07850;
  --ok: #2E7D32; --ok-bg: #E8F5E9;
  --err: #C62828; --err-bg: #FFEBEE;
  --r: 12px; --tr: .2s ease;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  direction: rtl; color: var(--tx);
  max-width: 620px; margin: 0 auto;
  box-shadow: 0 4px 32px rgba(92,51,23,.12);
  border-radius: 16px; overflow: hidden;
}

/* ── Header ── */
.ccp-hd {
  background: linear-gradient(135deg, var(--cp) 0%, #3d1e08 100%);
  padding: 20px 24px;
  display: flex; align-items: center; gap: 14px;
  position: relative; overflow: hidden;
}
.ccp-hd::after {
  content: '';
  position: absolute; top: -40px; left: -40px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(212,168,83,.2), transparent 70%);
  pointer-events: none;
}
.ccp-hd-icon { font-size: 32px; }
.ccp-hd-title { color: #fff; margin: 0 0 3px; font-size: 18px; font-weight: 800; }
.ccp-hd-sub { color: rgba(255,255,255,.7); margin: 0; font-size: 12px; }

/* ── Body ── */
.ccp-body { background: var(--bg); padding: 0; }

/* ── Section ── */
.ccp-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--bd);
}
.ccp-section:last-of-type { border-bottom: none; }

.ccp-section-hd {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.ccp-step-n {
  width: 26px; height: 26px;
  background: var(--cp); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; flex-shrink: 0;
}
.ccp-section-title { font-size: 15px; font-weight: 700; color: var(--cp); flex: 1; }
.ccp-section-val {
  font-size: 12px; font-weight: 600;
  background: var(--bg2); padding: 2px 9px; border-radius: 20px;
  color: var(--tx2); border: 1px solid var(--bd);
}
.ccp-pct-total {
  font-size: 13px; font-weight: 800;
  padding: 2px 10px; border-radius: 20px; margin-right: auto;
}
.ccp-pct-total.ok  { background: var(--ok-bg);  color: var(--ok); }
.ccp-pct-total.err { background: var(--err-bg); color: var(--err); }

.ccp-hint-text { font-size: 12px; color: var(--tx3); margin: -6px 0 12px; line-height: 1.5; }

/* ── Slider (weight) ── */
.ccp-slider-wrap { }
.ccp-slider-top {
  display: flex; align-items: baseline; gap: 5px; margin-bottom: 8px;
}
.ccp-slider-num { font-size: 28px; font-weight: 800; color: var(--cp); }
.ccp-slider-unit { font-size: 14px; color: var(--tx2); }

input[type=range].ccp-slider {
  -webkit-appearance: none; width: 100%; height: 6px;
  border-radius: 3px; outline: none; cursor: pointer;
  background: var(--bd);
}
input[type=range].ccp-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px;
  background: var(--cp); border: 3px solid #fff;
  border-radius: 50%; cursor: pointer;
  box-shadow: 0 2px 8px rgba(92,51,23,.3);
}
.ccp-slider-ticks {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--tx3); margin-top: 4px;
}

/* ── Coffee row ── */
.ccp-coffee-row {
  border: 1px solid var(--bd); border-radius: var(--r);
  padding: 12px 14px; margin-bottom: 10px;
  background: var(--bg2);
  transition: border-color var(--tr);
}
.ccp-coffee-row:last-child { margin-bottom: 0; }
.ccp-coffee-row.has-brand { border-color: var(--ca); background: #FFFDF5; }

.ccp-coffee-row-hd {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.ccp-coffee-icon { font-size: 18px; }
.ccp-coffee-name { font-size: 14px; font-weight: 700; color: var(--cp); flex: 1; }
.ccp-coffee-pct  { font-size: 18px; font-weight: 800; color: var(--cp); min-width: 44px; text-align: left; }

/* Brand chips */
.ccp-brand-row { margin-bottom: 10px; }
.ccp-field-label { font-size: 11px; font-weight: 700; color: var(--tx2); display: block; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.ccp-brand-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.ccp-brand-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px;
  border: 1.5px solid var(--bd2); background: #fff;
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--tx2);
  cursor: pointer; transition: all var(--tr);
}
.ccp-brand-chip:hover { border-color: var(--ca); color: var(--cp); }
.ccp-brand-chip.sel   { background: var(--cp); border-color: var(--cp); color: #fff; }
.ccp-chip-logo { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; }
.ccp-chip-ppg  { font-size: 10px; opacity: .75; }
.ccp-brand-chip.sel .ccp-chip-ppg { opacity: .85; }

/* Percent bar + slider */
.ccp-pct-row { }
.ccp-pct-slider-wrap { position: relative; }
.ccp-pct-slider-wrap { position: relative; height: 22px; }
.ccp-pct-bar-bg {
  height: 6px; background: var(--bd); border-radius: 3px;
  overflow: hidden; position: absolute; top: 50%; left: 0; right: 0;
  transform: translateY(-50%); pointer-events: none;
}
.ccp-pct-bar-fill {
  position: absolute; top: 0; right: 0; height: 100%;
  background: linear-gradient(90deg, var(--cp), var(--ca));
  border-radius: 3px; transition: width .25s ease;
}
input[type=range].ccp-pct-slider {
  -webkit-appearance: none; width: 100%; height: 22px;
  background: transparent; outline: none; cursor: pointer;
  position: relative; z-index: 1; margin: 0; padding: 0;
}
input[type=range].ccp-pct-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px;
  background: var(--cp); border: 3px solid #fff;
  border-radius: 50%; cursor: pointer;
  box-shadow: 0 1px 6px rgba(92,51,23,.3);
}
input[type=range].ccp-pct-slider::-moz-range-thumb {
  width: 18px; height: 18px; background: var(--cp);
  border: 3px solid #fff; border-radius: 50%; cursor: pointer;
}

/* Percent status */
.ccp-pct-status {
  margin-top: 12px; padding: 8px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  background: var(--err-bg); color: var(--err);
  display: flex; align-items: center; gap: 7px;
}
.ccp-pct-status.ok { background: var(--ok-bg); color: var(--ok); }

/* ── Addon chips ── */
.ccp-chips-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ccp-opt-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 14px; border-radius: 10px;
  border: 1.5px solid var(--bd2); background: #fff;
  font-family: inherit; cursor: pointer; transition: all var(--tr);
}
.ccp-opt-chip:hover { border-color: var(--ca); }
.ccp-opt-chip.sel   { background: var(--cp); border-color: var(--cp); color: #fff; }
.ccp-opt-label { font-size: 13px; font-weight: 600; }
.ccp-opt-extra { font-size: 10px; opacity: .7; }
.ccp-opt-chip.sel .ccp-opt-extra { opacity: .85; }

/* ── Price panel ── */
.ccp-price-panel {
  background: linear-gradient(135deg, #2A1505 0%, #4a2009 100%);
  padding: 16px 20px;
}
.ccp-price-lines { margin-bottom: 12px; }
.ccp-price-line {
  display: flex; justify-content: space-between;
  font-size: 12px; color: rgba(255,255,255,.65); padding: 3px 0;
}
.ccp-price-line .pl-note { font-size: 10px; color: rgba(255,255,255,.4); }
.ccp-price-line .pl-disc { color: var(--ca); font-size: 10px; }
.ccp-price-total-row {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid rgba(255,255,255,.12); padding-top: 10px; margin-top: 4px;
}
.ccp-price-label { color: rgba(255,255,255,.75); font-size: 13px; }
.ccp-price-val {
  font-size: 26px; font-weight: 800; color: var(--ca);
  transition: all .3s cubic-bezier(.34,1.56,.64,1);
}
.ccp-price-val.pop { transform: scale(1.08); }

/* ── Add to cart ── */
.ccp-atc-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 20px;
  background: linear-gradient(135deg, var(--cp), #3d1e08);
  color: #fff; border: none;
  font-family: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all var(--tr);
  box-shadow: 0 2px 14px rgba(92,51,23,.3);
}
.ccp-atc-btn:hover:not(:disabled) {
  box-shadow: 0 4px 22px rgba(92,51,23,.45);
  filter: brightness(1.08);
}
.ccp-atc-btn:disabled { background: #c8b8a8; cursor: not-allowed; box-shadow: none; }
.ccp-atc-icon { font-size: 18px; }

.ccp-success {
  background: var(--ok-bg); padding: 12px 20px;
  font-size: 13px; font-weight: 600; color: var(--ok);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.ccp-success a { color: var(--ok); text-decoration: underline; font-size: 12px; }
.ccp-reorder {
  background: var(--cp); color: #fff; border: none;
  padding: 5px 14px; border-radius: 20px;
  font-family: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all var(--tr); margin-right: auto;
}
.ccp-reorder:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* Optional addon deselect hint */
.ccp-opt-chip.sel::after {
  content: '✓';
  font-size: 10px; margin-right: 4px;
}
.ccp-section[data-required="0"] .ccp-opt-chip.sel::after {
  content: '✓ کلیک برای لغو';
  font-size: 9px;
}

/* Optional section */
.ccp-section[data-required="0"] .ccp-section-title { color: var(--tx2); }
.ccp-optional-tag {
  font-size: 10px; font-weight: 600; color: var(--tx3);
  background: var(--bg2); border: 1px solid var(--bd);
  padding: 1px 7px; border-radius: 20px;
}

/* Cart meta */
small.ccp-cart-meta-sub { font-size: 11px; color: #888; display: block; margin-top: 3px; }

@media (max-width: 480px) {
  .ccp-hd { padding: 14px 16px; }
  .ccp-section { padding: 14px 14px; }
  .ccp-slider-num { font-size: 22px; }
  .ccp-price-val  { font-size: 20px; }
}

/* ── Minicart (portal — fixed to body) ── */
.ccp-minicart { position: relative; margin-right: auto; margin-left: 4px; flex-shrink: 0; }

.ccp-mc-btn {
  display: flex; align-items: center; justify-content: center;
  position: relative;
  width: 40px; height: 40px;
  background: rgba(255,255,255,.12);
  border: 1.5px solid rgba(255,255,255,.2);
  border-radius: 50%;
  cursor: pointer; transition: all .2s ease;
  padding: 0; color: #fff;
}
.ccp-mc-btn:hover { background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.4); transform: translateY(-1px); }
.ccp-mc-btn svg { width: 20px; height: 20px; }

.ccp-mc-count {
  position: absolute; top: -5px; left: -5px;
  min-width: 18px; height: 18px;
  background: var(--ca, #D4A853); color: #2A1505;
  border-radius: 20px; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
  opacity: 0; transform: scale(0);
  transition: all .25s cubic-bezier(.34,1.56,.64,1);
}
.ccp-mc-count.has-items { opacity: 1; transform: scale(1); }
.ccp-mc-count.pop { transform: scale(1.4); }

/* Portal dropdown — fixed در body */
.ccp-mc-portal {
  position: absolute;
  background: #fff; border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.08);
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s cubic-bezier(.34,1.2,.64,1);
  transform: translateY(6px);
  z-index: 999999;
  overflow: hidden;
  direction: rtl;
}
.ccp-mc-portal.open { opacity: 1; pointer-events: auto; transform: translateY(0); }

.ccp-mc-arrow {
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  width: 14px; height: 14px; background: var(--cp,#5C3317);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
.ccp-mc-hd {
  background: linear-gradient(135deg, var(--cp,#5C3317), #3d1e08);
  color: #fff; padding: 11px 14px;
  font-size: 13px; font-weight: 700;
}
.ccp-mc-body { max-height: 240px; overflow-y: auto; padding: 6px 0; }
.ccp-mc-body::-webkit-scrollbar { width: 4px; }
.ccp-mc-body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.ccp-mc-loading { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 20px; font-size: 12px; color: #888; }
.ccp-mc-spin { width: 16px; height: 16px; border: 2px solid #eee; border-top-color: var(--cp,#5C3317); border-radius: 50%; animation: ccp-spin .7s linear infinite; flex-shrink: 0; }
@keyframes ccp-spin { to { transform: rotate(360deg); } }

.ccp-mc-empty { text-align: center; padding: 24px 16px; font-size: 13px; color: #aaa; }
.ccp-mc-empty-ico { font-size: 32px; margin-bottom: 8px; }

.ccp-mc-list { list-style: none; margin: 0; padding: 0; }
.ccp-mc-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #f0f0f0; transition: background .15s; }
.ccp-mc-item:last-child { border-bottom: none; }
.ccp-mc-item:hover { background: #fafafa; }

.ccp-mc-img { width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: #f5f0ea; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 20px; }
.ccp-mc-img img { width: 100%; height: 100%; object-fit: cover; }

.ccp-mc-info { flex: 1; min-width: 0; }
.ccp-mc-name { font-size: 12.5px; font-weight: 700; color: #2A1505; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.ccp-mc-meta { font-size: 10.5px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; line-height: 1.4; }
.ccp-mc-qty-price { display: flex; align-items: center; gap: 8px; }
.ccp-mc-qty { font-size: 11px; color: #888; background: #f5f0ea; padding: 1px 6px; border-radius: 10px; }
.ccp-mc-price { font-size: 12px; font-weight: 700; color: var(--cp,#5C3317); }

.ccp-mc-remove { background: none; border: none; cursor: pointer; color: #ccc; font-size: 13px; padding: 2px 4px; border-radius: 50%; transition: all .15s; line-height: 1; flex-shrink: 0; }
.ccp-mc-remove:hover { color: #e53e3e; background: #fff0f0; }

.ccp-mc-total { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-top: 1px solid #f0f0f0; font-size: 13px; font-weight: 700; color: #2A1505; background: #fafaf8; }

.ccp-mc-foot { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid #eee; background: #fff; }
.ccp-mc-checkout, .ccp-mc-pay {
  display: flex; align-items: center; justify-content: center;
  flex: 1; padding: 9px 12px; border-radius: 10px;
  font-size: 12px; font-weight: 700; text-decoration: none; transition: all .18s;
}
.ccp-mc-checkout { background: #f5f0ea; color: var(--cp,#5C3317); border: 1.5px solid #e8d5bc; }
.ccp-mc-checkout:hover { background: #ede5d8; }
.ccp-mc-pay { background: linear-gradient(135deg, var(--cp,#5C3317), #3d1e08); color: #fff; }
.ccp-mc-pay:hover { filter: brightness(1.1); transform: translateY(-1px); }

@media (max-width: 480px) {
  .ccp-mc-portal { width: 280px !important; }
}
