/* ==========================================================================
   استایل‌های استودیوی حرفه‌ای و واکنش‌گرای ساخت آنلاین نمودار (Chart Studio)
   طراحی ۱۰۰٪ ریسپانسیو بدون اسکرول افقی در تمام دستگاه‌ها
   ========================================================================== */

.chart-studio-layout {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* ۱. نوار الگوهای آماده سریع (Quick Presets) */
.presets-quick-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.presets-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  flex-shrink: 0;
}

.presets-buttons-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  width: 100%;
}

.presets-buttons-scroll::-webkit-scrollbar {
  display: none;
}

.preset-pill {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 5px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  flex-shrink: 0;
}

.preset-pill:hover {
  border-color: #4f46e5;
  color: #4f46e5;
  background: #ffffff;
}

.preset-pill.active {
  border-color: #4f46e5;
  background: rgba(99, 102, 241, 0.1);
  color: #4f46e5;
}

/* ۲. استیج پیش‌نمایش نمودار (Hero Canvas Stage) */
.chart-stage-card {
  background: #ffffff;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.stage-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-light);
  gap: 10px;
}

.stage-status-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  animation: pulseLive 2s infinite;
}

@keyframes pulseLive {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.85); opacity: 0.5; }
}

.stage-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
}

.preview-badge {
  font-size: 11.5px;
  font-weight: 700;
  color: #4f46e5;
  background: rgba(99, 102, 241, 0.1);
  padding: 3px 12px;
  border-radius: 20px;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

/* بوم گرافیکی پیش‌نمایش */
.chart-canvas-area {
  position: relative;
  min-height: 360px;
  max-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background-color: #ffffff;
  background-image: radial-gradient(#e2e8f0 1.2px, transparent 1.2px);
  background-size: 20px 20px;
  overflow: hidden;
  box-sizing: border-box;
}

.svg-stage-container {
  width: 100%;
  max-width: 820px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.svg-stage-container svg {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: 420px !important;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.04));
}

.chart-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(2px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.spinner-circle {
  width: 34px;
  height: 34px;
  border: 3.5px solid rgba(79, 70, 229, 0.15);
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* نوار ابزارهای دانلود و کپی */
.stage-toolbar {
  padding: 14px 20px;
  background: #ffffff;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.stage-main-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-action-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  background: #4f46e5;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
  transition: var(--transition);
}

.btn-action-primary:hover {
  background: #4338ca;
  transform: translateY(-1px);
}

.btn-action-secondary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-action-secondary:hover {
  border-color: #4f46e5;
  color: #4f46e5;
  background: #ffffff;
}

.stage-copy-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-copy-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.btn-copy-tag:hover {
  border-color: #4f46e5;
  color: #4f46e5;
  background: #ffffff;
}

/* ۳. استودیوی تنظیمات و ویرایش داده‌ها (Studio Control Center) */
.studio-controls-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* تب‌های استودیو */
.studio-tabs-bar {
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border-bottom: 1.5px solid var(--border-light);
  overflow-x: auto;
  scrollbar-width: none;
}

.studio-tabs-bar::-webkit-scrollbar {
  display: none;
}

.studio-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.studio-tab-btn:hover {
  color: #4f46e5;
  background: rgba(255, 255, 255, 0.5);
}

.studio-tab-btn.active {
  color: #4f46e5;
  background: #ffffff;
  border-bottom-color: #4f46e5;
  font-weight: 800;
}

.studio-tab-panel {
  display: none;
  padding: 22px;
  box-sizing: border-box;
}

.studio-tab-panel.active {
  display: block;
}

/* کنترل‌های تب ۱: نوع نمودار و پالت رنگی */
.control-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.block-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
}

.chart-types-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

@media (max-width: 860px) {
  .chart-types-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .chart-types-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
}

.type-card-modern {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 6px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  text-align: center;
  min-height: 68px;
}

.type-card-modern:hover {
  border-color: #4f46e5;
  background: #ffffff;
  transform: translateY(-1px);
}

.type-card-modern.active {
  border-color: #4f46e5;
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.15);
}

.tc-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.tc-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.type-card-modern.active .tc-title {
  color: #4f46e5;
  font-weight: 800;
}

/* تم‌های رنگی مدرن */
.themes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 640px) {
  .themes-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

.theme-card-modern {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  text-align: right;
}

.theme-card-modern:hover {
  border-color: #4f46e5;
  background: #ffffff;
}

.theme-card-modern.active {
  border-color: #4f46e5;
  background: rgba(99, 102, 241, 0.08);
}

.theme-palette-dots {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.theme-palette-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.theme-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-card-modern.active .theme-name {
  color: #4f46e5;
}

/* کنترل‌های تب ۲: عناوین و داده‌ها */
.meta-inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

@media (max-width: 600px) {
  .meta-inputs-grid {
    grid-template-columns: 1fr;
  }
}

.input-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-cell label {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-main);
}

.studio-input {
  width: 100%;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-main);
  background: var(--bg-subtle);
  outline: none;
  transition: var(--transition);
  box-sizing: border-box;
}

.studio-input:focus {
  border-color: #4f46e5;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* جدول داده‌ها */
.data-table-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.table-scroll-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: #ffffff;
  box-sizing: border-box;
}

.chart-data-table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: center;
}

.chart-data-table th,
.chart-data-table td {
  padding: 8px 10px;
  border: 1px solid var(--border-light);
}

.chart-data-table th {
  background: var(--bg-subtle);
  font-weight: 800;
  color: var(--text-main);
}

.th-action {
  width: 44px;
  text-align: center;
}

.th-label-input,
.td-data-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-main);
  background: transparent;
  outline: none;
  transition: var(--transition);
  box-sizing: border-box;
}

.th-label-input:focus,
.td-data-input:focus {
  border-color: #4f46e5;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.td-data-input {
  direction: ltr;
  text-align: center;
}

.btn-del-row,
.btn-del-col {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  margin: 0 auto;
  transition: var(--transition);
}

.btn-del-row:hover,
.btn-del-col:hover {
  background: #fee2e2;
}

.table-action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-table-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-subtle);
  border: 1.5px dashed var(--border-light);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
}

.btn-table-pill:hover {
  border-color: #4f46e5;
  color: #4f46e5;
  background: rgba(99, 102, 241, 0.05);
}

/* کنترل‌های تب ۳: کد JSON */
.json-code-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.json-code-editor {
  width: 100%;
  height: 240px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12.5px;
  direction: ltr;
  text-align: left;
  outline: none;
  background: #0f172a;
  color: #f8fafc;
  resize: vertical;
  box-sizing: border-box;
}

.btn-apply-json {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  background: #4f46e5;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
}

.btn-apply-json:hover {
  background: #4338ca;
}

/* ریسپانسیو اختصاصی موبایل برای صفحه چارت */
@media (max-width: 640px) {
  .chart-canvas-area {
    min-height: 280px;
    padding: 16px 10px;
  }

  .stage-toolbar {
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
  }

  .stage-main-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .btn-action-primary,
  .btn-action-secondary {
    justify-content: center;
    padding: 9px 10px;
    font-size: 12px;
  }

  .stage-copy-group {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .btn-copy-tag {
    justify-content: center;
    padding: 6px 4px;
    font-size: 11px;
  }

  .studio-tabs-bar {
    padding: 0 4px;
  }

  .studio-tab-btn {
    padding: 12px 14px;
    font-size: 12.5px;
  }

  .studio-tab-panel {
    padding: 16px 12px;
  }
}