/* ==========================================================================
   app.css — افزوده‌های سامانه روی style.css قالب اصلی
   فونت محلی، اجزای مشترک، پنل کاربری و پنل مدیریت
   ========================================================================== */

/* فونت وزیرمتن (متغیر، self-host) */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* دسترس‌پذیری */
.skip-link { position: absolute; inset-inline-start: -999px; top: 8px; background: var(--color-forest); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm); z-index: 2000; }
.skip-link:focus { inset-inline-start: 8px; color: #fff; }
:focus-visible { outline: 2px solid var(--color-wood-light); outline-offset: 2px; }
button.btn-brand-primary, button.btn-brand-outline { cursor: pointer; }
.btn-brand-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm-brand { padding: 7px 16px; font-size: .85rem; }
.btn-danger-outline { background: #fff; color: #a3352b; border: 1px solid #e3b9b4; border-radius: var(--radius-sm); padding: 7px 16px; font-weight: 600; font-size: .85rem; }
.btn-danger-outline:hover { background: #a3352b; color: #fff; }
.link-button { background: none; border: 0; padding: 0; color: var(--color-wood); font-weight: 600; font-size: .9rem; }
.link-button:hover { color: var(--color-forest); }

/* اعلان‌ها */
.flash { border-radius: var(--radius-md); padding: 14px 18px; margin-bottom: 20px; font-size: .93rem; display: flex; gap: 10px; align-items: flex-start; border: 1px solid transparent; }
.flash-success { background: #eaf4ee; border-color: #b9dcc6; color: #1d5a3a; }
.flash-error { background: #fbeceb; border-color: #efc4c0; color: #8c2a22; }
.flash-info { background: #f3efe5; border-color: var(--color-border); color: var(--color-ink); }
.field-error { color: #a3352b; font-size: .8rem; margin-top: 5px; }
.form-control-brand.is-invalid { border-color: #c9675e; }
.form-hint { font-size: .78rem; color: var(--color-muted); margin-top: 5px; }
select.form-control-brand { appearance: auto; }

/* نشان وضعیت */
.badge-status { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; background: #eee9dd; color: var(--color-ink); }
.badge-ok { background: #e0f0e6; color: #1d5a3a; }
.badge-warn { background: #fbf0d9; color: #7d5a11; }
.badge-bad { background: #f9e1df; color: #8c2a22; }
.badge-info { background: #e2ecf4; color: #24506f; }

/* کارت و جدول عمومی */
.card-brand { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 22px; margin-bottom: 20px; }
.card-brand > h2, .card-brand > h3 { font-size: 1.05rem; margin-bottom: 16px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card-title-row h2, .card-title-row h3 { font-size: 1.05rem; margin: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-brand { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table-brand th { text-align: start; font-weight: 600; color: var(--color-muted); padding: 10px 12px; border-bottom: 1px solid var(--color-border); white-space: nowrap; background: #faf8f3; }
.table-brand td { padding: 11px 12px; border-bottom: 1px solid #f0ebe0; vertical-align: middle; }
.table-brand tbody tr:hover { background: #fcfbf8; }
.table-brand .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-brand tfoot td { font-weight: 700; background: #faf8f3; }
.text-debit { color: #8c2a22; }
.text-credit { color: #1d5a3a; }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 24px; margin: 0; }
.dl-grid dt { font-size: .78rem; color: var(--color-muted); font-weight: 500; }
.dl-grid dd { margin: 2px 0 0; font-weight: 600; font-size: .92rem; word-break: break-word; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 18px; }
.filter-bar > div { min-width: 140px; flex: 1 1 140px; max-width: 240px; }
.filter-bar .form-control-brand { padding: 9px 12px; font-size: .88rem; }
.filter-bar label { font-size: .76rem; color: var(--color-muted); margin-bottom: 3px; display: block; }
.pagination { --bs-pagination-color: var(--color-forest); --bs-pagination-active-bg: var(--color-forest); --bs-pagination-active-border-color: var(--color-forest); --bs-pagination-focus-box-shadow: none; margin-top: 18px; flex-wrap: wrap; }
.stat-card { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 18px 20px; height: 100%; display: block; }
a.stat-card:hover { border-color: var(--color-wood-light); box-shadow: var(--shadow-soft); }
.stat-card .stat-label { font-size: .82rem; color: var(--color-muted); }
.stat-card .stat-value { font-size: 1.45rem; font-weight: 700; margin-top: 4px; }
.stat-card .stat-note { font-size: .74rem; color: var(--color-muted); margin-top: 4px; }

/* فروشگاه */
.hero-banner { background-size: cover; background-position: center; }
.shop-product-card .spc-img img, .product-card .product-img img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.spc-price del { margin-inline-start: 8px; color: var(--color-muted); font-size: .78rem; font-weight: 400; }
.stock-out { color: #8c2a22; font-size: .85rem; font-weight: 600; }
.variant-options { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.variant-options input { position: absolute; opacity: 0; }
.variant-options label { border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 8px 16px; font-size: .88rem; cursor: pointer; background: #fff; }
.variant-options input:checked + label { border-color: var(--color-forest); background: var(--color-forest); color: #fff; }
.variant-options input:focus-visible + label { outline: 2px solid var(--color-wood-light); outline-offset: 2px; }
.variant-options input:disabled + label { opacity: .45; cursor: not-allowed; text-decoration: line-through; }
.variant-options input[data-available="0"]:not(:checked) + label { opacity: .6; }
/* فرم سفارش اختصاصی هر قلم */
.pd-options { border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: #fff; padding: 14px 16px; margin-bottom: 18px; }
.pd-option { padding: 8px 0; border-bottom: 1px dashed var(--color-border); font-size: .9rem; }
.pd-option:last-of-type { border-bottom: 0; }
.pd-option input[type="checkbox"] { width: 17px; height: 17px; vertical-align: middle; margin-inline-end: 6px; accent-color: var(--color-forest); }
.pd-option input[type="number"] { width: 84px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 6px 10px; margin-inline-start: 10px; text-align: center; }
.pd-option small, .item-options { color: var(--color-muted); font-size: .78rem; }
.pd-option-note { font-size: .84rem; margin: 0 0 8px; line-height: 1.9; }
.pd-option-note:last-child { margin: 8px 0 0; }
.pd-breakdown { list-style: none; margin: 0 0 18px; padding: 10px 16px; background: var(--color-cream); border-radius: var(--radius-sm); font-size: .85rem; }
.pd-breakdown li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.pd-breakdown li:last-child { font-weight: 700; border-top: 1px solid var(--color-border); margin-top: 4px; padding-top: 8px; }
.item-options { list-style: none; margin: 4px 0 0; padding: 0; line-height: 1.9; }
.page-body { background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 32px; line-height: 2.1; white-space: pre-line; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 22px 16px 0; border-inline-start: 0; font-size: .88rem; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 0; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--color-wood-light); }
.timeline li::after { content: ""; position: absolute; inset-inline-start: 4px; top: 20px; bottom: 0; width: 2px; background: var(--color-border); }
.timeline li:last-child::after { display: none; }
.timeline time { color: var(--color-muted); font-size: .78rem; display: block; }
.otp-input { letter-spacing: .6em; text-align: center; font-size: 1.4rem; font-weight: 700; direction: ltr; }
.chat-msg { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 12px; background: #fff; max-width: 85%; }
.chat-msg.is-staff { background: #f1f6f4; margin-inline-start: auto; }
.chat-msg .meta { font-size: .76rem; color: var(--color-muted); margin-bottom: 6px; }
.chat-msg p { margin: 0; white-space: pre-line; font-size: .92rem; }

/* پنل کاربری (مشتری / نماینده) */
.panel-nav { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 14px; position: sticky; top: 96px; }
.panel-nav .who { padding: 8px 10px 14px; border-bottom: 1px solid var(--color-border); margin-bottom: 10px; }
.panel-nav .who strong { display: block; }
.panel-nav .who span { font-size: .8rem; color: var(--color-muted); }
.panel-nav a, .panel-nav button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: .92rem; font-weight: 500; width: 100%; background: none; border: 0; text-align: start; color: var(--color-ink); }
.panel-nav a:hover, .panel-nav button:hover { background: var(--color-cream); }
.panel-nav a.active { background: var(--color-forest); color: #fff; }

/* پنل مدیریت */
.admin-body { background: #f4f2ec; }
.admin-shell { display: flex; min-height: 100vh; }
.admin-side { width: 250px; flex-shrink: 0; background: var(--color-forest); color: rgba(255,255,255,.85); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.admin-side .side-brand { padding: 20px 22px; font-weight: 800; font-size: 1.05rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.12); display: block; }
/* منوی آکاردئونی: هر گروه یک <details> است؛ فقط گروه صفحه جاری باز می‌ماند. */
.admin-side .side-group { border-bottom: 1px solid rgba(255,255,255,.07); }
.admin-side .side-group > summary { display: flex; align-items: center; gap: 8px; padding: 12px 22px; font-size: .86rem; font-weight: 600; color: rgba(255,255,255,.72); cursor: pointer; list-style: none; user-select: none; }
.admin-side .side-group > summary::-webkit-details-marker { display: none; }
.admin-side .side-group > summary > span:first-child { flex: 1; }
.admin-side .side-group > summary:hover, .admin-side .side-group[open] > summary { color: #fff; background: rgba(255,255,255,.06); }
.admin-side .side-group > summary.is-current { color: #fff; box-shadow: inset -3px 0 0 var(--color-wood-light); }
.admin-side .side-group > summary:focus-visible { outline-offset: -2px; }
.admin-side .side-caret { font-size: .72rem; opacity: .7; transition: transform .2s ease; }
.admin-side .side-group[open] .side-caret { transform: rotate(180deg); }
.admin-side .side-group > a { padding-inline-start: 34px; font-size: .86rem; background: rgba(0,0,0,.1); }
.admin-side .side-group > a:hover { background: rgba(255,255,255,.08); }
.admin-side .side-group > a.active { background: rgba(255,255,255,.14); }
.admin-side .side-group[open] > summary .cx-badge { display: none; }
.admin-side a { display: flex; align-items: center; gap: 10px; padding: 9px 22px; font-size: .9rem; color: rgba(255,255,255,.85); }
.admin-side a:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-side a.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset -3px 0 0 var(--color-wood-light); }
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-top { background: #fff; border-bottom: 1px solid var(--color-border); padding: 12px 24px; display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 50; }
.admin-top form.quick-search { flex: 1; max-width: 420px; position: relative; }
.admin-top form.quick-search input { width: 100%; border: 1px solid var(--color-border); border-radius: 999px; padding: 8px 40px 8px 16px; font-size: .88rem; background: var(--color-cream); }
.admin-top form.quick-search i { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--color-muted); }
.admin-top .user-chip { margin-inline-start: auto; font-size: .86rem; display: flex; align-items: center; gap: 12px; }
.admin-content { padding: 24px; flex: 1; }
.admin-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-page-head h1 { font-size: 1.3rem; }
.admin-page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 20px; }
.perm-group { margin-bottom: 18px; }
.perm-group h4 { font-size: .9rem; margin-bottom: 8px; color: var(--color-wood); }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed #ebe5d8; font-size: .86rem; }
.perm-row select { font-size: .8rem; padding: 3px 6px; border: 1px solid var(--color-border); border-radius: 6px; background: #fff; }
.estimate-note { background: #fbf0d9; border: 1px solid #ecd9a8; color: #6b4d0e; border-radius: var(--radius-sm); padding: 10px 14px; font-size: .84rem; margin-bottom: 16px; }

@media (max-width: 991.98px) {
  .admin-side { position: fixed; inset-inline-start: 0; z-index: 1050; transform: translateX(100%); transition: transform .25s ease; width: min(280px, 86vw); }
  .admin-side .side-group > summary, .admin-side .side-group > a { padding-block: 13px; }
  .admin-side.is-open { transform: none; }
  .admin-content { padding: 16px; }
  .panel-nav { position: static; margin-bottom: 20px; }
  .chat-msg { max-width: 100%; }
}

@media print {
  .no-print, .topbar, .main-nav, .site-footer, .panel-nav, .admin-side, .admin-top, #backToTop { display: none !important; }
  body { background: #fff; }
  .card-brand { border: 0; padding: 0; }
}
