/* Components: panels, buttons, status badges, chips, the dropdown and the shared building blocks.
   Templates combine these classes; markup helpers live in templates/components.html.
   Identity «کاتالوگ»: flat white panels with hairlines, one pine for actions, saffron for prices and tokens. */

/* --- surfaces ------------------------------------------------------------------------------------ */
.glass, .edge, .card { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-deep); }
.card { border-radius: var(--r-xl); padding: 22px; }
.panel {  /* a quiet box inside a card */
  border-radius: var(--r-md); padding: 18px; border: 1px solid var(--line); background: var(--surface-2);
}

/* --- text ---------------------------------------------------------------------------------------- */
.display { font-family: var(--font-display); }
.stat { font: 800 34px/1.15 var(--font-display); color: var(--text-strong); letter-spacing: -.5px; }
.stat small { font: 600 14px var(--font); color: var(--text-muted); letter-spacing: 0; }
.price { font: 800 26px/1.3 var(--font-display); color: var(--text-strong); }

/* --- buttons ------------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-md); cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 700; color: var(--text-strong); text-decoration: none;
  border: 1px solid var(--line-strong); background: var(--surface);
  transition: transform var(--t-fast), background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn:hover { color: var(--text-strong); border-color: var(--text-faint); }
.btn:active { transform: scale(.98); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); }
.btn-primary { color: var(--accent-ink); border-color: var(--accent); background: var(--accent); }
.btn-primary:hover { color: var(--accent-ink); background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-soft { color: var(--accent-mint); background: var(--accent-a10); border-color: var(--accent-a10); }
.btn-soft:hover { color: var(--accent-mint); border-color: var(--accent-a30); }
.btn-spark { color: var(--spark-ink); border-color: var(--spark); background: var(--spark); }
.btn-spark:hover { color: var(--spark-ink); background: #D4952A; border-color: #D4952A; }
.btn-danger { color: var(--danger); border-color: var(--line-strong); }
.btn-danger:hover { color: var(--danger-strong); background: var(--danger-soft); border-color: var(--danger); }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 15px; }
.btn.small, .btn-sm { min-height: 38px; padding: 0 14px; border-radius: var(--r-sm); font-size: 13px; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 38px; }
.btn[disabled], .btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* --- status badge (published / draft / working / failed) ------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
  color: var(--text-muted); background: var(--surface-3); border: 0;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.published { color: var(--accent-mint); background: var(--accent-a10); }
.badge.draft { color: var(--spark-text); background: var(--spark-a10); }
.badge.ready { color: var(--text-muted); background: var(--surface-3); }
.badge.failed { color: var(--danger-text); background: var(--danger-soft); }
.badge.processing, .badge.queued, .badge.sending, .badge.publishing, .badge.deleting { color: var(--info-text); background: var(--info-soft); }
.badge.processing::before, .badge.queued::before, .badge.sending::before, .badge.publishing::before { animation: pulse 1.2s ease-in-out infinite; }

/* --- chips ---------------------------------------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 600; color: var(--text-soft); background: var(--surface); border: 1px solid var(--line-strong);
}
.chip-accent { color: var(--accent-mint); background: var(--accent-a10); border-color: var(--accent-a10); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

/* --- icons ------------------------------------------------------------------------------------------ */
.icon { width: 20px; height: 20px; flex-shrink: 0; }
.icon-tile {  /* small square behind an icon */
  width: 38px; height: 38px; border-radius: var(--r-sm); display: grid; place-items: center; flex-shrink: 0;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-strong);
  transition: border-color var(--t-fast), color var(--t-fast);
}
a.icon-tile:hover, button.icon-tile:hover { border-color: var(--text-faint); }
.icon-tile .icon { width: 18px; height: 18px; color: currentColor; }
.num-tile {  /* the solid pine square behind an icon or a step number */
  width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; flex-shrink: 0;
  font: 800 19px var(--font-display); color: var(--accent-ink); background: var(--accent);
}

/* --- media ---------------------------------------------------------------------------------------- */
.thumb {
  width: 56px; height: 56px; border-radius: var(--r-sm); object-fit: cover; flex-shrink: 0;
  background: var(--thumb-bg); border: 1px solid var(--line);
}
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.gallery img { aspect-ratio: 1; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--line); }

/* --- drop zone (upload) ----------------------------------------------------------------------------- */
.dropzone {
  border-radius: var(--r-md); border: 1.5px dashed var(--line-strong); cursor: pointer; text-align: center;
  background: var(--surface-2); padding: 24px 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  transition: border-color var(--t-fast), background-color var(--t-fast);
}
.dropzone.drag, .dropzone:hover { border-color: var(--accent); background: var(--accent-a10); }
.dropzone .num-tile { width: 46px; height: 46px; border-radius: var(--r-md); }
.dropzone .num-tile .icon { width: 22px; height: 22px; color: var(--accent-ink); }
.dropzone-title { font-size: 15px; font-weight: 800; color: var(--text-strong); }

/* --- segmented tabs ----------------------------------------------------------------------------------- */
.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.tabs a, .tabs button {
  min-height: 32px; padding: 0 12px; border: none; border-radius: 9px; background: transparent;
  color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}
.tabs .active, .tabs [aria-pressed=true] { background: var(--surface); color: var(--text-strong); font-weight: 700; box-shadow: 0 1px 2px rgb(11 23 21 / .1); }

/* underlined tabs (product page, modules/tabs.js) */
.utabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.utabs button { border: 0; background: none; padding: 10px 14px; font: inherit; font-weight: 700; font-size: 14px; color: var(--text-faint); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.utabs button[aria-selected="true"] { color: var(--text-strong); border-bottom-color: var(--accent); }
[data-tab-panel][hidden] { display: none; }

/* --- misc shared blocks ---------------------------------------------------------------------------------- */
.plan { display: flex; flex-direction: column; gap: 10px; position: relative; }
.plan.featured { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.plan .btn { margin-top: auto; }
.code-box {
  font: 800 36px var(--font-display); letter-spacing: .35em; text-align: center; direction: ltr; padding: 14px;
  color: var(--text-strong); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line-strong);
}
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--accent-a30); border-top-color: var(--accent);
  border-radius: 50%; display: inline-block; vertical-align: middle; animation: spin 1s linear infinite;
}
.attr-table { margin-bottom: 12px; }
.attr-table td { padding: 6px 4px; border-bottom: 0; }
.attr-table th { background: none; }
.attr-table input:not([type=checkbox]) { width: 100%; min-width: 0; }
.attr-table .check { width: 1%; white-space: nowrap; text-align: center; }
.price-preview { margin-top: 4px; min-height: 1.2em; color: var(--accent-light); }

/* charts (web/charts.py) */
.chart { width: 100%; height: 180px; display: block; }
.chart-bar { fill: var(--accent); opacity: .9; }
.chart-bar:hover { opacity: 1; fill: var(--accent-deep); }
.chart-axis { stroke: var(--line-strong); }
.chart-label { fill: var(--text-faint); font-size: 12px; font-family: inherit; }

/* --- dropdown (modules/select.js): a button like the inputs + a white list ---------------------------------- */
.select-native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.select { position: relative; width: 100%; }
.select.w-auto { width: auto; min-width: 200px; }
.select-btn {
  width: 100%; min-height: 46px; padding: 10px 14px 10px 42px; text-align: start; font: inherit; font-size: 14px; color: var(--text-strong);
  border-radius: var(--r-md); border: 1px solid var(--line-strong); background-color: var(--field-bg);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.select-btn:hover { border-color: var(--text-faint); }
.select-btn:focus-visible, .select.open .select-btn { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-a16); }
.select-value { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-list {
  position: fixed; z-index: 50; margin: 0; padding: 6px; list-style: none; max-height: 280px; overflow-y: auto;
  border-radius: var(--r-md); background: var(--popover); border: 1px solid var(--line); box-shadow: var(--shadow-float);
  animation: pop var(--t-base) var(--ease);
}
.select-list li {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px; border-radius: var(--r-sm); cursor: pointer;
  font-size: 14px; color: var(--text);
}
.select-list li.active { background: var(--surface-2); color: var(--text-strong); }
.select-list li[aria-selected="true"] { color: var(--accent-mint); font-weight: 700; background: var(--accent-a10); }
.select-list li[aria-selected="true"]::after {
  content: ""; margin-inline-start: auto; width: 16px; height: 16px; flex-shrink: 0; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.select-list li[aria-disabled="true"] { opacity: .45; cursor: default; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }

/* --- token packages strip (partials/plans.html: home page + /pricing) ----------------------------------------------------------- */
.plans { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.plans .plan { padding: 26px 22px; display: grid; gap: 8px; align-content: start; }
.plans .plan + .plan { border-inline-start: 1px solid var(--line); }
.plans .plan h3 { font: 700 15px var(--font); color: var(--text-muted); margin: 0; }
.plans .plan .amt { font: 800 30px/1.3 var(--font-display); color: var(--text-strong); margin: 0; }
.plans .plan .amt small { font: 600 14px var(--font); color: var(--text-muted); }
.plans .plan .per { font-size: 14px; color: var(--text-muted); margin: 0; }
.plans .plan .per b { color: var(--text-strong); }
.plans .plan .btn { margin-top: 10px; width: 100%; }
.plans .plan.first { background: var(--accent-a10); }
@media (max-width: 1080px) {
  .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plans .plan:nth-child(3) { border-inline-start: 0; }
  .plans .plan:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 620px) {
  .plans { grid-template-columns: 1fr; }
  .plans .plan + .plan { border-inline-start: 0; border-top: 1px solid var(--line); }
}

/* package sale (admin «تخفیف بسته‌ها»): a percent chip and the old price crossed out */
.sale-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; margin-inline-start: 6px; border-radius: var(--r-pill);
  font: 800 12px/1 var(--font); color: var(--spark-ink); background: var(--spark); vertical-align: middle; }
.plans .plan .was, .plan .was { margin: 0; font-size: 14px; color: var(--text-faint); }
.plans .plan.on-sale { background: var(--spark-a10); }

/* what each action costs (partials/token_costs.html): the values in one column at the end */
.cost-table td:last-child { width: 1%; white-space: nowrap; text-align: end; }
.cost-table tbody tr:hover { background: none; }
.cost-table .free { font-weight: 700; color: var(--accent-mint); }

/* --- date picker (modules/datepicker.js): a calendar icon in the field + a white panel like the dropdown list ----- */
input[data-date] { padding-left: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2370857F' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='17' rx='2'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; }
.datepicker { position: fixed; z-index: 60; width: 292px; padding: 12px; border-radius: var(--r-lg); background: var(--popover);
  border: 1px solid var(--line); box-shadow: var(--shadow-float); animation: pop var(--t-base) var(--ease); direction: rtl; }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp-head b { font: 800 15px var(--font-display); color: var(--text-strong); }
.dp-nav { width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text-strong);
  font: 700 18px/1 var(--font); cursor: pointer; }
.dp-nav:hover { border-color: var(--text-faint); }
.dp-week, .dp-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dp-week span { font-size: 12px; font-weight: 700; color: var(--text-faint); padding: 4px 0; }
.dp-days button { height: 36px; border: 0; border-radius: var(--r-sm); background: none; font: 600 14px var(--font); color: var(--text); cursor: pointer;
  transition: background-color var(--t-fast); }
.dp-days button:hover { background: var(--surface-2); }
.dp-days button.today { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent-mint); }
.dp-days button.picked { background: var(--accent); color: var(--accent-ink); }
.dp-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.dp-foot button { border: 0; background: none; font: 700 13px var(--font); color: var(--accent-light); cursor: pointer; padding: 6px 8px; border-radius: var(--r-sm); }
.dp-foot button:hover { background: var(--surface-2); }
.dp-foot [data-clear] { color: var(--text-muted); }

/* --- light/dark switch (macro theme_toggle): shows the theme it switches to ------------------------------- */
.theme-toggle { display: inline-flex; margin: 0; }
.theme-toggle .i-sun, [data-theme="dark"] .theme-toggle .i-moon { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: block; }
.theme-toggle .icon { color: var(--text-muted); }

/* --- partner logos -------------------------------------------------------------------------------------------
   brand_mark: the single-colour mark (static/img/brands/<name>.svg), drawn in currentColor or, with .in-color,
   in the partner's own colour. brand_logo: the partner's full-colour logo (static/img/brands/color/). */
.brand-mark {
  display: inline-block; width: 22px; height: 22px; flex-shrink: 0; background: currentColor;
  -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat;
}
.brand-woocommerce { width: 36px; }
.brand-rankmath { width: 30px; }
.brand-woocommerce { --logo: url(/static/img/brands/woocommerce.svg); --brand: var(--c-woocommerce); }
.brand-wordpress   { --logo: url(/static/img/brands/wordpress.svg);   --brand: var(--c-wordpress); }
.brand-mixin       { --logo: url(/static/img/brands/mixin.svg);       --brand: var(--c-mixin); }
.brand-rankmath    { --logo: url(/static/img/brands/rankmath.svg);    --brand: var(--c-rankmath); }
.brand-yoast       { --logo: url(/static/img/brands/yoast.svg);       --brand: var(--c-yoast); }
.brand-bale        { --logo: url(/static/img/brands/bale.svg);        --brand: var(--c-bale); }
.brand-telegram    { --logo: url(/static/img/brands/telegram.svg);    --brand: var(--c-telegram); }
.brand-mark.in-color { background: var(--brand); }
[data-theme="dark"] .brand-mark.in-color.brand-mixin { background: #8C91F0; }  /* the mixin indigo is too dark on dark */
.brand-logo { height: 22px; width: auto; display: inline-block; }
.brand-with-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text-strong); }
[data-theme="dark"] .brand-logo { filter: brightness(1.35) saturate(.9); }
.store-mark {  /* a store's platform mark in a small tile (tables, lists) */
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface);
  display: inline-grid; place-items: center; flex-shrink: 0;
}
.store-mark .brand-mark { width: 18px; height: 14px; }

/* --- motion (all off with prefers-reduced-motion) ------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes grow { from { transform: scaleY(0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* --- staff logged in as a user: a bar that never lets them forget ----------------------------------------- */
.impersonating {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; padding: 10px 14px;
  border-radius: var(--r-md); font-size: 14px; color: var(--danger-text); background: var(--danger-soft);
  border: 1px solid var(--danger-soft);
}
.impersonating > span { flex: 1; min-width: 200px; }
