/* ══════════════════════════ [ LPM STYLE ] ══════════════════════════ */
/* تمام استایل‌ها پیشوند lpm- دارند. از متغیرهای ریشه استفاده می‌کند. */

#lpm-root, #lpm-root * { box-sizing: border-box; direction: rtl; -webkit-tap-highlight-color: transparent; }

:root {
    --o:       #537717;
    --o-dk:    #405e0c;
    --o-lt:    #fff3e8;
    --o-glow:  rgba(83,119,23,.2);
    --txt:     #111318;
    --txt-2:   #5a5f6b;
    --txt-3:   #9399a5;
  --border:  #e6e1da;
  --surface: #ffffff;
  --bg:      #f4f1ed;
  --bg2:     #ece8e2;
  --green:   #0f9b6a;
  --green-bg:#e6f7f0;
  --red:     #c0392b;
  --red-bg:  #fdf0ef;
  --r:       12px;
  --r-lg:    18px;
  --sh:      0 1px 6px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --sh-o:    0 4px 28px rgba(83,119,23,.16);
  --safe-b:  env(safe-area-inset-bottom, 0px);
}

/* پایه‌ها */
.lpm-overlay { display: flex; align-items: center; justify-content: center; min-height: 100svh; padding: 1.5rem; background: var(--bg); }
.lpm-card { background: var(--surface); border-radius: var(--r-lg); border: 1.5px solid var(--border); padding: 2.25rem 1.75rem; width: 100%; max-width: 380px; box-shadow: var(--sh-o); text-align: center; }
.lpm-logo-circle { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, var(--o) 0%, var(--o-dk) 100%); margin: 0 auto 1.35rem; box-shadow: 0 6px 20px var(--o-glow); color: #fff; }
.lpm-logo-circle svg { width: 28px; height: 28px; }
.lpm-title { font-size: 20px; font-weight: 800; color: var(--txt); margin: 0 0 .3rem; }
.lpm-subtitle { font-size: 13px; color: var(--txt-2); margin: 0 0 1.6rem; }
.lpm-field { text-align: right; margin-bottom: 1rem; }
.lpm-field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--txt); margin-bottom: 6px; }
.lpm-input-wrap { position: relative; }
.lpm-input-wrap .lpm-input-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--txt-3); pointer-events: none; display: flex; }
.lpm-input-wrap .lpm-input-icon svg { width: 16px; height: 16px; }
.lpm-field input { width: 100%; padding: 13px 14px; border: 1.5px solid var(--border); border-radius: var(--r); font-size: 15px; font-family: inherit; color: var(--txt); background: #fafaf8; outline: none; transition: border-color .18s, box-shadow .18s; min-height: 48px; }
.lpm-input-wrap input { padding-right: 38px; }
.lpm-field input:focus { border-color: var(--o); box-shadow: 0 0 0 3px var(--o-glow); background: #fff; }
.lpm-btn { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; padding: 14px 22px; background: linear-gradient(135deg, var(--o) 0%, var(--o-dk) 100%); color: #fff; border: none; border-radius: var(--r); font-size: 15px; font-weight: 700; cursor: pointer; transition: opacity .18s, transform .12s; box-shadow: 0 4px 14px var(--o-glow); min-height: 52px; touch-action: manipulation; }
.lpm-btn:hover:not(:disabled) { opacity: .88; }
.lpm-btn:active:not(:disabled) { transform: scale(.97); }
.lpm-btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.lpm-btn.wide { width: 100%; }
.lpm-btn-ghost { display: flex; align-items: center; gap: 6px; background: none; border: 1.5px solid var(--border); border-radius: var(--r); padding: 8px 14px; font-size: 13px; cursor: pointer; color: var(--txt-2); transition: border-color .18s, color .18s; }
.lpm-btn-ghost svg { width: 15px; height: 15px; }
.lpm-btn-ghost:hover { border-color: var(--o); color: var(--o); }
.lpm-alert { padding: 12px 16px; border-radius: var(--r); font-size: 13.5px; font-weight: 600; text-align: center; margin-top: .75rem; }
.lpm-alert.error { background: var(--red-bg); color: var(--red); border: 1px solid #f5b4b0; }
.lpm-alert.success { background: var(--green-bg); color: var(--green); border: 1px solid #9edfc6; }
.lpm-spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: lpm-spin .7s linear infinite; }
.lpm-dot-spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--o); border-radius: 50%; animation: lpm-spin .7s linear infinite; }
@keyframes lpm-spin { to { transform: rotate(360deg); } }

/* پنل اصلی */
.lpm-panel { background: var(--bg); min-height: 100svh; margin: -20px; padding-bottom: calc(2rem + var(--safe-b)); }
.lpm-header { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1.5px solid var(--border); padding: 12px 16px; position: sticky; top: 0; z-index: 50; }
.lpm-header-brand { display: flex; align-items: center; gap: 9px; }
.lpm-logo-sm { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--o), var(--o-dk)); color: #fff; }
.lpm-logo-sm svg { width: 16px; height: 16px; }
.lpm-header-title { font-size: 15px; font-weight: 800; color: var(--txt); }
.lpm-body { max-width: 720px; margin: 20px auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.4rem; }

/* استاتیک‌ها */
.lpm-stats-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.lpm-stat { background: var(--surface); border-radius: var(--r); border: 1.5px solid var(--border); padding: .9rem 1rem; box-shadow: var(--sh); }
.lpm-stat.highlight { border-color: var(--o); background: var(--o-lt); }
.lpm-stat-num { font-size: 22px; font-weight: 800; color: var(--txt); }
.lpm-stat.highlight .lpm-stat-num { color: var(--o); }
.lpm-stat-lbl { font-size: 10px; font-weight: 700; color: var(--txt-3); }
.lpm-prog-track { height: 4px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.lpm-prog-fill { height: 100%; background: linear-gradient(90deg, var(--o), var(--o-dk)); border-radius: 99px; transition: width .6s; }

/* کارت فرم */
.lpm-form-card { background: var(--surface); border-radius: var(--r-lg); border: 1.5px solid var(--border); padding: 1.75rem; box-shadow: var(--sh); }
.lpm-section-title { font-size: 15px; font-weight: 800; color: var(--txt); margin: 0 0 1.1rem; display: flex; align-items: center; gap: 8px; padding-bottom: .9rem; border-bottom: 1.5px solid var(--border); }
.lpm-title-icon { display: flex; color: var(--o); }
.lpm-title-icon svg { width: 17px; height: 17px; }
.lpm-sku-row { display: flex; gap: 8px; align-items: stretch; }
.lpm-sku-input { flex: 1; }
.lpm-search-btn { display: flex; align-items: center; gap: 6px; padding: 0 18px; background: var(--o); color: #fff; border: none; border-radius: var(--r); font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap; min-height: 48px; }
.lpm-search-btn:disabled { background: var(--bg2); color: var(--txt-3); cursor: not-allowed; }
.lpm-state-box { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: var(--r); font-size: 13.5px; font-weight: 600; }
.lpm-state-box.loading { background: var(--bg); border: 1.5px solid var(--border); }
.lpm-state-box.error { background: var(--red-bg); border: 1.5px solid #f5b4b0; color: var(--red); }
.lpm-state-icon svg { width: 18px; height: 18px; }

/* پیش‌نمایش محصول */
.lpm-preview-card { display: flex; gap: 1rem; align-items: flex-start; background: var(--bg); border-radius: var(--r); border: 1.5px solid var(--border); padding: 1rem; margin: 1rem 0; }
.lpm-preview-thumb-wrap { flex-shrink: 0; }
.lpm-preview-img, .lpm-preview-img-ph { width: 80px; height: 80px; border-radius: 10px; border: 1.5px solid var(--border); object-fit: cover; display: block; background: var(--bg2); }
.lpm-preview-img-ph { display: flex; align-items: center; justify-content: center; color: var(--txt-3); }
.lpm-preview-info { flex: 1; min-width: 0; }
.lpm-preview-name { font-size: 14px; font-weight: 700; color: var(--txt); margin-bottom: 4px; }
.lpm-preview-sku-tag { display: inline-block; font-size: 10.5px; font-weight: 700; background: var(--o-lt); color: var(--o-dk); padding: 2px 8px; border-radius: 4px; margin-bottom: 8px; }
.lpm-preview-type { font-size: 11px; color: var(--txt-2); margin-bottom: 8px; }
.lpm-preview-price-grid { display: flex; flex-direction: column; gap: 4px; }
.lpm-pprice { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.lpm-pprice-lbl { font-size: 11px; color: var(--txt-3); min-width: 60px; }
.lpm-pprice-val.lir { color: var(--o-dk); font-weight: 700; }
.lpm-pprice-val.toman { color: var(--green); font-weight: 700; }

/* تب‌ها */
.lpm-tabs { display: flex; border-bottom: 2px solid var(--border); margin: 1.5rem 0 1rem; gap: 0; }
.lpm-tab { background: none; border: none; padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--txt-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: .18s; }
.lpm-tab.active { color: var(--o); border-bottom-color: var(--o); }
.lpm-tab-content { display: none; }
.lpm-tab-content.active { display: block; }

/* موجودی */
.lpm-stock-desc { font-size: 14px; margin: 0 0 1rem; }
.lpm-stock-desc strong { color: var(--txt); }
.lpm-variations-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 1rem; }
.lpm-variation-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--bg); border-radius: var(--r); border: 1px solid var(--border); }
.lpm-variation-name { font-size: 13px; font-weight: 600; }
.lpm-variation-status { font-size: 12px; padding: 4px 10px; border-radius: 6px; }
.lpm-variation-status.instock { background: var(--green-bg); color: var(--green); }
.lpm-variation-status.outofstock { background: var(--red-bg); color: var(--red); }
.lpm-toggle-var-btn { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r); padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--txt-2); }

/* دیالوگ تأیید */
.lpm-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; z-index: 9999; opacity: 0; pointer-events: none; transition: opacity .22s; }
.lpm-modal-overlay.visible { opacity: 1; pointer-events: auto; }
.lpm-modal { background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 1.75rem 1.5rem calc(1.75rem + var(--safe-b)); width: 100%; max-width: 480px; text-align: center; transform: translateY(40px); transition: transform .22s; }
.lpm-modal-overlay.visible .lpm-modal { transform: translateY(0); }
.lpm-modal-icon { width: 52px; height: 52px; background: var(--o-lt); color: var(--o); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; border: 2px solid var(--o); }
.lpm-modal-icon svg { width: 24px; height: 24px; }
.lpm-modal-title { font-size: 17px; font-weight: 800; color: var(--txt); margin: 0 0 .5rem; }
.lpm-modal-desc { font-size: 13px; color: var(--txt-2); margin: 0 0 1rem; }
.lpm-modal-actions { display: flex; gap: 10px; }
.lpm-modal-btn { flex: 1; padding: 13px 16px; border: none; border-radius: var(--r); font-size: 14px; font-weight: 700; cursor: pointer; min-height: 50px; }
.lpm-modal-btn.cancel { background: var(--bg2); color: var(--txt-2); }
.lpm-modal-btn.confirm { background: linear-gradient(135deg, var(--o), var(--o-dk)); color: #fff; box-shadow: 0 3px 12px var(--o-glow); }

/* لاگ */
.lpm-log-card { background: var(--surface); border-radius: var(--r-lg); border: 1.5px solid var(--border); padding: 1.5rem; box-shadow: var(--sh); }
.lpm-log-item { display: flex; align-items: flex-start; gap: 12px; padding: 13px 8px; border-bottom: 1px solid var(--border); }
.lpm-log-thumb, .lpm-log-thumb-ph { width: 52px; height: 52px; border-radius: 9px; border: 1.5px solid var(--border); object-fit: cover; background: var(--bg2); }
.lpm-log-thumb-ph { display: flex; align-items: center; justify-content: center; color: var(--txt-3); }
.lpm-log-body { flex: 1; }
.lpm-log-top { display: flex; gap: 8px; margin-bottom: 4px; font-size: 13px; }
.lpm-log-name { font-weight: 700; }
.lpm-log-sku { font-size: 10px; background: var(--o-lt); color: var(--o-dk); padding: 2px 6px; border-radius: 4px; }
.lpm-log-time { font-size: 11px; color: var(--txt-3); margin-right: auto; }
.lpm-log-desc { font-size: 12px; color: var(--txt-2); }
.lpm-log-empty { text-align: center; color: var(--txt-3); padding: 2rem; }

/* رسپانسیو */
@media (min-width: 540px) {
  .lpm-modal-overlay { align-items: center; }
  .lpm-modal { border-radius: var(--r-lg); max-width: 420px; }
}