/**
 * FitRonix — داشبورد کاربری · چیدمان و inset
 * ویجت‌ها از لبه داشبورد فاصله دارند — نه full-bleed
 */

html[data-user-panel-theme="fitronix"] #view-dashboard,
html[data-user-panel-theme="firouzi"] #view-dashboard {
  --fx-dash-container-max: none;
  --dashboard-gap: var(--fx-dash-gap, 16px);
  --fx-dash-gap: var(--dashboard-gap);
  --fx-dash-pad-block: var(--fx-dash-inset-y, clamp(1rem, 2vw, 1.5rem));
  --fx-dash-pad-inline: var(--fx-dash-inset-x, clamp(1.25rem, 2.5vw, 2rem));
  --fx-dash-card-pad: var(--fx-card-pad, clamp(1rem, 1.75vw, 1.5rem));
  --fx-dash-title: clamp(0.8125rem, 0.2vw + 0.75rem, 0.9375rem);
  --fx-dash-label: clamp(0.6875rem, 0.15vw + 0.625rem, 0.8125rem);
}

/* ═══ دسکتاپ — inset از لبه main (عرض/مارجین در user-panel-theme-fitronix.css) ═══ */
@media (min-width: 881px) {
  html[data-user-panel-theme="fitronix"] .shell-user .main:has(#view-dashboard.active),
  html[data-user-panel-theme="firouzi"] .shell-user .main:has(#view-dashboard.active) {
    padding-inline: var(--fx-dash-pad-inline) !important;
    padding-block: var(--fx-dash-pad-block) !important;
    box-sizing: border-box;
    background: var(--color-gray-100, #f1f5f9) !important;
  }
}

html[data-user-panel-theme="fitronix"] .shell-user .main:has(#view-dashboard.active) > .header,
html[data-user-panel-theme="fitronix"] .shell-user .main:has(#view-dashboard.active) > .content,
html[data-user-panel-theme="firouzi"] .shell-user .main:has(#view-dashboard.active) > .header,
html[data-user-panel-theme="firouzi"] .shell-user .main:has(#view-dashboard.active) > .content {
  width: 100% !important;
  max-width: none !important;
  margin-inline: 0 !important;
  box-sizing: border-box;
}

html[data-user-panel-theme="fitronix"] .shell-user .main:has(#view-dashboard.active) > .content,
html[data-user-panel-theme="firouzi"] .shell-user .main:has(#view-dashboard.active) > .content {
  padding-inline: 0 !important;
}

html[data-user-panel-theme="fitronix"] .shell-user .main:has(#view-dashboard.active) .content,
html[data-user-panel-theme="firouzi"] .shell-user .main:has(#view-dashboard.active) .content {
  width: 100% !important;
  max-width: none !important;
  margin-inline: 0 !important;
  padding: 0 !important;
  box-sizing: border-box;
}

html[data-user-panel-theme="fitronix"] #view-dashboard,
html[data-user-panel-theme="firouzi"] #view-dashboard {
  width: 100% !important;
  max-width: none !important;
  margin-inline: 0 !important;
  padding: 0 !important;
  box-sizing: border-box;
}

html[data-user-panel-theme="fitronix"] #view-dashboard .fx-dash[data-dash-sortable="fx-main"],
html[data-user-panel-theme="firouzi"] #view-dashboard .fx-dash[data-dash-sortable="fx-main"] {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--dashboard-gap);
  width: 100% !important;
  max-width: none !important;
  min-width: 0;
  margin-inline: 0;
  box-sizing: border-box;
}

/* ─── خوش‌آمدگویی v3 ─── */
html[data-user-panel-theme="fitronix"] .fx-greet-v3.fx-dash-greet,
html[data-user-panel-theme="fitronix"] .fx-greet-v3.up-dash-greet,
html[data-user-panel-theme="firouzi"] .fx-greet-v3.fx-dash-greet,
html[data-user-panel-theme="firouzi"] .fx-greet-v3.up-dash-greet {
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box;
}

html[data-user-panel-theme="fitronix"] .fx-greet-v3 .fx-greet-layout,
html[data-user-panel-theme="firouzi"] .fx-greet-v3 .fx-greet-layout {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: clamp(16px, 2vw, 28px);
  align-items: start;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

html[data-user-panel-theme="fitronix"] .fx-greet-v3 .fx-greet-main,
html[data-user-panel-theme="firouzi"] .fx-greet-v3 .fx-greet-main {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

html[data-user-panel-theme="fitronix"] .fx-greet-v3 .fx-greet-tasks,
html[data-user-panel-theme="firouzi"] .fx-greet-v3 .fx-greet-tasks {
  min-width: 0;
  width: 100%;
  max-width: none;
  justify-self: stretch;
}

html[data-user-panel-theme="fitronix"] .fx-greet-v3 .up-dash-greet-portrait,
html[data-user-panel-theme="firouzi"] .fx-greet-v3 .up-dash-greet-portrait {
  justify-self: start;
}

/* ─── برنامه‌های من ─── */
html[data-user-panel-theme="fitronix"] #view-dashboard .fx-programs-section,
html[data-user-panel-theme="firouzi"] #view-dashboard .fx-programs-section {
  width: 100% !important;
  max-width: none !important;
}

html[data-user-panel-theme="fitronix"] #view-dashboard .fx-programs-grid,
html[data-user-panel-theme="firouzi"] #view-dashboard .fx-programs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: var(--dashboard-gap);
  width: 100%;
}

/* ─── دسترسی سریع ─── */
html[data-user-panel-theme="fitronix"] #view-dashboard .fx-quick-grid,
html[data-user-panel-theme="firouzi"] #view-dashboard .fx-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--dashboard-gap);
  width: 100%;
}

html[data-user-panel-theme="fitronix"] #view-dashboard .fx-quick-row .fx-card,
html[data-user-panel-theme="firouzi"] #view-dashboard .fx-quick-row .fx-card {
  padding: var(--fx-dash-card-pad);
}

/* ─── سفارشی‌سازی ویجت ─── */
html[data-user-panel-theme="fitronix"] #view-dashboard .fx-customize,
html[data-user-panel-theme="firouzi"] #view-dashboard .fx-customize {
  border: 1px solid var(--color-gray-300, #c8d5e1);
  border-radius: var(--fx-radius-sm, 12px);
  background: var(--color-white);
  overflow: hidden;
}

html[data-user-panel-theme="fitronix"]:not([data-theme="dark"]) #view-dashboard .fx-customize summary,
html[data-user-panel-theme="firouzi"]:not([data-theme="dark"]) #view-dashboard .fx-customize summary {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--color-dark);
}

/* تبلت */
@media (max-width: 1199px) and (min-width: 901px) {
  html[data-user-panel-theme="fitronix"] .fx-greet-v3 .fx-greet-layout,
  html[data-user-panel-theme="firouzi"] .fx-greet-v3 .fx-greet-layout {
    grid-template-columns: 168px minmax(0, 1fr) minmax(220px, 280px);
    gap: 20px;
  }
}

@media (max-width: 900px) {
  html[data-user-panel-theme="fitronix"] .fx-greet-v3 .fx-greet-layout,
  html[data-user-panel-theme="firouzi"] .fx-greet-v3 .fx-greet-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  html[data-user-panel-theme="fitronix"] .fx-greet-v3 .up-dash-greet-portrait,
  html[data-user-panel-theme="firouzi"] .fx-greet-v3 .up-dash-greet-portrait {
    justify-self: center;
  }
}

@media (max-width: 880px) {
  html[data-user-panel-theme="fitronix"] .shell-user .main:has(#view-dashboard.active),
  html[data-user-panel-theme="firouzi"] .shell-user .main:has(#view-dashboard.active) {
    width: 100% !important;
    max-width: 100vw !important;
    margin-right: 0 !important;
    padding-inline: 0 !important;
    padding-block: 0 !important;
    background: var(--color-gray-100, #f1f5f9) !important;
  }

  html[data-user-panel-theme="fitronix"] .shell-user .main:has(#view-dashboard.active) > .header,
  html[data-user-panel-theme="fitronix"] .shell-user .main:has(#view-dashboard.active) > .content,
  html[data-user-panel-theme="firouzi"] .shell-user .main:has(#view-dashboard.active) > .header,
  html[data-user-panel-theme="firouzi"] .shell-user .main:has(#view-dashboard.active) > .content {
    max-width: 100% !important;
    margin-inline: 0 !important;
    padding-inline: 0 !important;
  }

  html[data-user-panel-theme="fitronix"] #view-dashboard,
  html[data-user-panel-theme="firouzi"] #view-dashboard {
    padding: var(--fx-dash-inset-y, 1rem) var(--fx-dash-inset-x, 1rem) calc(var(--panel-bn-h, 4rem) + 1rem + env(safe-area-inset-bottom, 0)) !important;
  }

  html[data-user-panel-theme="fitronix"] #view-dashboard .fx-programs-grid,
  html[data-user-panel-theme="firouzi"] #view-dashboard .fx-programs-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1900px) {
  html[data-user-panel-theme="fitronix"] .shell-user .main:has(#view-dashboard.active),
  html[data-user-panel-theme="firouzi"] .shell-user .main:has(#view-dashboard.active) {
    padding-inline: clamp(1.5rem, 3vw, 2.5rem) !important;
  }
}
