/* =========================================================================
   FACTORY DASHBOARD PAGE + SHARED CARD CHROME
   -------------------------------------------------------------------------
   This file owns the permanent dashboard page structure and the shared card
   appearance. Widget-specific styles live in dashboard.css.
   ========================================================================= */

.admin-content {
  background: linear-gradient(
      145deg,
      rgba(24, 32, 44, 0.92),
      rgba(31, 41, 55, 0.88)
  );
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.dashboard-view-shell {
  --dashboard-bg: rgba(31, 41, 55, 0.85);
  --dashboard-surface: #111827;
  --dashboard-surface-2: #172033;
  --dashboard-border: rgba(148, 163, 184, 0.18);
  --dashboard-border-strong: rgba(148, 163, 184, 0.34);
  --dashboard-text: #e5edf8;
  --dashboard-muted: #94a3b8;
  --dashboard-accent: #38bdf8;
  --dashboard-dot-grid: rgba(148, 163, 184, 0.16);
  --dashboard-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
  --dashboard-radius: 11px;

  --bg: var(--dashboard-bg);
  --surface: var(--dashboard-surface);
  --surface-2: var(--dashboard-surface-2);
  --border: var(--dashboard-border);
  --border-strong: var(--dashboard-border-strong);
  --text: var(--dashboard-text);
  --text-muted: var(--dashboard-muted);
  --accent: var(--dashboard-accent);
  --dot-grid: var(--dashboard-dot-grid);
  --shadow: var(--dashboard-shadow);
  --radius: var(--dashboard-radius);
  --status-ok: #4ade80;
  --status-warning: #fbbf24;
  --status-critical: #f87171;
  --chart-font: monospace;
  --font-mono: monospace;

  --series-1: #38bdf8;
  --chart-grid: rgba(148, 163, 184, 0.16);
  --chart-axis: #94a3b8;
  --chart-text: #cbd5e1;
  --limit-min: #a78bfa;
  --limit-max: #f87171;

  color: var(--dashboard-text);

  /* The page module sets this value from the shell's actual viewport position.
     This keeps the outer page static without depending on base-layout heights. */
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: auto;
}

.dashboard-view-shell[hidden] {
  display: none;
}

/* ---------------------------------------------------------- page header */
.dashboard-page-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  margin-top: -15px;
}

.dashboard-page-header h1 {
  margin: 2px 0 4px;
  font-size: 1.4rem;
}

.dashboard-eyebrow {
  margin: 0;
  color: var(--dashboard-accent);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.dashboard-muted {
  margin: 0;
  color: var(--dashboard-muted);
  font-size: 0.9rem;
}

.dashboard-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.dashboard-primary-button,
.dashboard-back-button,
.dashboard-icon-button {
  border: 1px solid var(--dashboard-border);
  border-radius: 9px;
  color: var(--dashboard-text);
  background: var(--dashboard-surface);
  cursor: pointer;
  padding: 10px 14px;
  text-decoration: none;
}

.dashboard-primary-button {
  background: #0f766e;
  border-color: #0f766e;
  font-weight: 700;
}

.dashboard-icon-button {
  display: inline-grid;
  place-items: center;
  padding: 7px 10px;
}

.dashboard-icon-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.dashboard-back-button {
  display: block;
  width: fit-content;
  margin: 0 0 13px auto;
  font-weight: normal;
  font-size: 0.8rem;
}

/* ------------------------------------------------------- list controls */
.dashboard-list-toolbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.dashboard-search-box {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: 9px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--dashboard-border);
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.76);
}

.dashboard-search-box:focus-within {
  border-color: color-mix(in srgb, var(--dashboard-accent) 68%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dashboard-accent) 14%, transparent);
}

.dashboard-search-box svg,
.dashboard-view-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.dashboard-search-box svg {
  flex: 0 0 auto;
  color: var(--dashboard-muted);
}

.dashboard-search-box input {
  width: 100%;
  min-width: 0;
  padding: 11px 0;
  color: var(--dashboard-text);
  font: inherit;
  border: 0;
  outline: 0;
  background: transparent;
}

.dashboard-search-box input::placeholder {
  color: var(--dashboard-muted);
}

.dashboard-view-toggle {
  color: var(--dashboard-muted);
}

.dashboard-view-toggle:hover {
  color: var(--dashboard-accent);
}

.dashboard-sort-bar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding: 9px 12px;
  border: 1px solid var(--dashboard-border);
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.56);
}

.dashboard-sort-bar-label {
  color: var(--dashboard-muted);
  font-size: 0.82rem;
}

.dashboard-sort-button {
  padding: 4px 7px;
  color: var(--dashboard-muted);
  font: inherit;
  font-size: 0.82rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.dashboard-sort-button:hover,
.dashboard-sort-button--active {
  color: var(--dashboard-text);
  background: var(--dashboard-surface-2);
}

.dashboard-sort-button--active {
  color: var(--dashboard-accent);
}

/* ------------------------------------------------------- dashboard list */
.dashboard-list {
  flex: 1 1 auto;
  min-height: auto;
  overscroll-behavior: contain;
  align-content: start;
  gap: 12px;
  margin-bottom: 15px;
}

.dashboard-list::-webkit-scrollbar {
    width: 6px;
}

.dashboard-list::-webkit-scrollbar-track {
    background: transparent;
}

.dashboard-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 999px;
}


.dashboard-list--list  {
  display: grid;
  grid-template-columns: 1fr;
}

.dashboard-list--grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  max-width: 100%;
  align-items: stretch;
}

.dashboard-list-card {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  min-height: 88px;
  padding: 14px 16px;
  color: var(--dashboard-text);
  text-align: center;
  background: rgba(17, 24, 39, 0.78);
  border: 1px solid var(--dashboard-border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
  overflow: hidden;
  min-width: 0;
}

.dashboard-card-icon-wrap,
.dashboard-favorite-button {
  flex-shrink: 0;
}

/* .dashboard-list-card::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge جدید 
} 
*/

.dashboard-list-card:hover,
.dashboard-list-card:focus-visible {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--dashboard-accent) 60%, transparent);
  outline: 0;
}

.dashboard-card-icon-wrap {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--dashboard-surface-2);
}

.dashboard-card-icon {
  width: 23px;
  height: 23px;
  object-fit: contain;
  opacity: 0.88;
}

.dashboard-list-card-main {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(84px, 0.35fr) minmax(160px, 0.65fr);
  align-items: center;
  gap: 14px;
  flex: 1 1 auto;
  min-width: 0;
}

.dashboard-list-card-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-card-meta {
  display: grid;
  gap: 3px;
  color: var(--dashboard-muted);
  font-size: 0.82rem;
}

.dashboard-card-meta-label {
  display: none;
}

.dashboard-favorite-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  color: #fbbf24;
  font-size: 1.55rem;
  line-height: 1;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.dashboard-favorite-button:hover,
.dashboard-favorite-button:focus-visible {
  background: color-mix(in srgb, #fbbf24 13%, transparent);
  outline: 0;
}

.dashboard-list--grid .dashboard-list-card {
  display: grid;
  justify-items: center;
  align-content: start;
  height: auto;
  min-height: 220px;
  padding: 20px 16px 14px;
  text-align: center;
  overflow: auto;
  width: 100%;
}

.dashboard-list--grid .dashboard-list-card-title {
  text-align: center;
}

.dashboard-list--grid .dashboard-card-icon-wrap {
  width: 80px;
  height: 80px;
  border-radius: 18px;
}

.dashboard-list--grid .dashboard-card-icon {
  width: 47px;
  height: 47px;
}

.dashboard-list--grid .dashboard-list-card-main {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 8px;
  width: 100%;
}

.dashboard-list--grid .dashboard-card-meta {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.dashboard-list--grid .dashboard-card-meta-label {
  display: inline;
}

.dashboard-list--grid .dashboard-favorite-button {
  position: absolute;
  top: 9px;
  left: 9px;
}

/* ------------------------------------------------------- live header */
.dashboard-live-title-area {
  min-width: 0;
  flex: 1 1 auto;
}

.dashboard-live-dashboard-meta {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  padding: 5px 10px;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.66);
  flex: 1;
}

.dashboard-live-dashboard-meta h1 {
  margin: 0px !important;
  font-size: 1.2rem;
  font-weight: normal;
  letter-spacing: 0.5px;
  /* text-shadow: 0 0 12px rgba(58,168,255,0.6); */

}

.dashboard-live-dashboard-icon {
  width: 42px;
  height: 42px;
  padding: 8px;
  border-radius: 10px;
  background: var(--dashboard-surface-2);
  object-fit: contain;
}



.dashboard-live-favorite-button {
  margin-right: auto;
  margin-left: 0;
}

/* ------------------------------------------------------ dashboard canvas */
.dashboard-frame {
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  overscroll-behavior: contain;
  width: 100%;
  padding: 18px;
  background-color: var(--dashboard-bg);
  background-image: radial-gradient(var(--dashboard-dot-grid) 0.5px, transparent 1px);
  background-size: 22px 22px;
  border-radius: 12px;

  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.dashboard-frame::-webkit-scrollbar {
    width: 6px;
}

.dashboard-frame::-webkit-scrollbar-track {
    background: transparent;
}

.dashboard-frame::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 999px;
}


.grid-stack {
  min-height: 530px;
  background: transparent;
}

/* --------------------------------------------------------- shared cards */
.grid-stack-item-content {
  inset: 0;
}

.grid-stack-item-content.widget-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.widget-header {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
  cursor: move;
  user-select: none;
}

.widget-title {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.widget-unit {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.widget-unit:empty {
  display: none;
}

.widget-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.grid-stack-item:hover > .ui-resizable-handle {
  opacity: 0.9;
}

.dashboard-empty,
.dashboard-error {
  color: var(--dashboard-muted);
  padding: 20px;
  text-align: center;
}

.dashboard-error {
  font-family: var(--font-mono);
}

@media (max-width: 800px) {
  .dashboard-page-header,
  .dashboard-live-header {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-header-actions {
    justify-content: flex-start;
  }

  .dashboard-list-card-main {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .dashboard-card-meta-label {
    display: inline;
  }

  .dashboard-card-meta {
    display: flex;
    gap: 5px;
  }

}

@media (max-width: 520px) {
  .dashboard-list-toolbar {
    align-items: stretch;
  }

  .dashboard-sort-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-list--grid {
    grid-template-columns: 1fr;
  }
}

/* ----------------------------------------------------- live title top row */
.dashboard-live-header {

    position: sticky !important;
  top: -26px !important;
  z-index: 80 !important;

  margin-inline: -26px !important;
  padding: 12px 26px !important;
  padding-top: 18px !important;


  background: linear-gradient(
      270deg,
      rgba(26, 34, 48, 0.7),
      rgba(24, 32, 44, 0.7)
  ) ; 
  
  
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(50px);


  margin-top: -25px;  
}

.dashboard-live-title-area {
  width: 100%;
}

.dashboard-live-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  /* margin-bottom: 14px; */
}

.dashboard-live-top-row .dashboard-back-button {
  margin: 0;
}

.dashboard-header h1 {
  margin: 0 0 3px;
}

.dashboard-header p {
  margin: 0;
}

@media (max-width: 600px) {
  .dashboard-live-top-row {
    align-items: stretch;
    flex-direction: column;
  }
}






/* ---------------------header animation------------------------ */
.copilot-icon-wrapper {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -3px;
}

.industrial-icon {
  width: 100%;
  height: 100%;
  fill: none;
  stroke-linecap: round;
}

/* قوس داشبورد */
.gauge {
  stroke: var(--bs-primary);
  stroke-width: 3;
  opacity: 0.9;
}

/* هسته مرکزی */
.core {
  fill: var(--bs-primary);
  filter: drop-shadow(0 0 3px var(--bs-primary));
  animation: pulse 2s infinite ease-in-out;
}

/* عقربه */
.needle {
  stroke: var(--bs-primary);
  stroke-width: 2.5;
  transform-origin: 50px 65px;
  animation: sweep 3s ease-in-out infinite;
}

/* انیمیشن عقربه */
@keyframes sweep {
  0%   { transform: rotate(-35deg); }
  50%  { transform: rotate(35deg); }
  100% { transform: rotate(-35deg); }
}

/* pulse هسته */
@keyframes pulse {
  0%, 100% {
    opacity: 0.7;
    filter: drop-shadow(0 0 3px var(--bs-primary));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 8px var(--bs-primary));
  }
}
