/* Dashboards — sürükle-bırak düzenleyici */

.dash-editor {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 120px);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

html.theme-dark .dash-editor {
  background: var(--card, #0f172a);
}

.dash-editor.is-preview .dash-editor__palette {
  display: none;
}

.dash-editor.is-preview {
  grid-template-columns: 1fr;
}

.dash-editor.is-preview .dash-editor__board {
  background: #f8fafc;
}

.dash-editor.is-preview .dashboard-widget-card__remove,
.dash-editor.is-preview .dashboard-widget-card__drag {
  display: none !important;
}

.dash-editor.is-preview .dashboard-widget-card {
  cursor: default;
  border-style: solid;
}

/* —— Palette —— */
.dash-editor__palette {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: #f8fafc;
  min-height: 0;
}

html.theme-dark .dash-editor__palette {
  background: rgba(15, 23, 42, 0.55);
}

.dash-editor__palette-head {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}

.dash-editor__palette-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.dash-editor__palette-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.dash-editor__palette-scroll {
  overflow-y: auto;
  padding: 10px 12px 16px;
  flex: 1;
  min-height: 0;
}

.dash-palette-group + .dash-palette-group {
  margin-top: 16px;
}

.dash-palette-group__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
  padding: 6px 4px;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.dash-palette-group__label:hover {
  color: var(--text, #0f172a);
}

.dash-palette-group__caret {
  font-size: 10px;
  opacity: 0.85;
  transition: transform 0.18s ease;
}

.dash-palette-group.is-collapsed .dash-palette-group__caret {
  transform: rotate(-90deg);
}

.dash-palette-group.is-collapsed .dash-palette-list {
  display: none;
}

.dash-palette-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dash-palette-item {
  display: grid;
  grid-template-columns: 36px 1fr 20px;
  gap: 10px;
  align-items: center;
  padding: 10px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: grab;
  user-select: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

html.theme-dark .dash-palette-item {
  background: rgba(30, 41, 59, 0.8);
}

.dash-palette-item:hover {
  border-color: rgba(30, 136, 229, 0.45);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.dash-palette-item:active,
.dash-palette-item.is-dragging {
  cursor: grabbing;
  opacity: 0.7;
  transform: scale(0.98);
}

.dash-palette-item__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 136, 229, 0.1);
  color: var(--primary, #1e88e5);
  font-size: 15px;
}

.dash-palette-item__text strong {
  display: block;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
}

.dash-palette-item__text span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
}

.dash-palette-item__grip {
  color: #94a3b8;
  font-size: 12px;
  justify-self: end;
}

/* —— Canvas / board —— */
.dash-editor__canvas-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #fff;
}

html.theme-dark .dash-editor__canvas-wrap {
  background: transparent;
}

.dash-editor__canvas-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 10px;
  border-bottom: 1px solid var(--border);
}

.dash-editor__canvas-title h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.dash-editor__canvas-title p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.dash-editor__canvas-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.dash-viewport-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
}

html.theme-dark .dash-viewport-toggle {
  background: rgba(15, 23, 42, 0.4);
}

.dash-viewport-btn {
  border: 0;
  background: transparent;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dash-viewport-btn.is-active {
  background: #fff;
  color: var(--primary, #1e88e5);
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

html.theme-dark .dash-viewport-btn.is-active {
  background: rgba(30, 136, 229, 0.15);
}

.dash-editor__board {
  position: relative;
  flex: 1;
  min-height: 520px;
  margin: 8px 10px 10px 8px;
  padding: 12px 12px 12px 10px;
  border-radius: 14px;
  border: 1px dashed rgba(148, 163, 184, 0.55);
  background-color: #f1f5f9;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 18px 18px;
  transition: max-width 0.2s ease, margin 0.2s ease;
}

html.theme-dark .dash-editor__board {
  background-color: rgba(15, 23, 42, 0.35);
  background-image: radial-gradient(rgba(148, 163, 184, 0.25) 1px, transparent 1px);
}

.dash-editor__board.is-dragover {
  border-color: var(--primary, #1e88e5);
  box-shadow: inset 0 0 0 2px rgba(30, 136, 229, 0.18);
}

.dash-editor__board[data-viewport="tablet"] {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

.dash-editor__board[data-viewport="mobile"] {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.dash-editor__board-label {
  position: absolute;
  top: 10px;
  left: 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
  pointer-events: none;
}

.dash-board-grid {
  margin-top: 12px;
  min-height: 280px;
}

.dashboard-widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  align-content: start;
}

.dash-editor__board[data-viewport="mobile"] .dashboard-widgets-grid {
  grid-template-columns: 1fr;
}

.dashboard-widgets-empty {
  display: none;
  place-items: center;
  min-height: 280px;
  margin-top: 24px;
}

.dashboard-widgets-empty.is-visible {
  display: grid;
}

.dashboard-widgets-empty__card {
  text-align: center;
  max-width: 360px;
  padding: 28px 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px dashed rgba(148, 163, 184, 0.7);
}

html.theme-dark .dashboard-widgets-empty__card {
  background: rgba(30, 41, 59, 0.7);
}

.dashboard-widgets-empty__icon {
  font-size: 28px;
  color: var(--primary, #1e88e5);
  margin-bottom: 10px;
}

.dashboard-widgets-empty__card h4 {
  margin: 0 0 6px;
  font-size: 16px;
}

.dashboard-widgets-empty__card p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.dash-drop-ghost {
  pointer-events: none;
  border: 2px dashed var(--primary, #1e88e5);
  border-radius: 14px;
  background: rgba(30, 136, 229, 0.08);
  min-height: 140px;
}

.dash-drop-ghost.hidden {
  display: none !important;
}

/* —— Widget cards —— */
.dashboard-widget-card {
  position: relative;
  min-height: 148px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
}

html.theme-dark .dashboard-widget-card {
  background: rgba(30, 41, 59, 0.92);
}

.dashboard-widget-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  opacity: 0.85;
}

.dashboard-widget-card--kpi::before {
  background: linear-gradient(90deg, #6366f1, #4f46e5);
}

.dashboard-widget-card--sensor::before {
  background: linear-gradient(90deg, #0ea5e9, #0284c7);
}

.dashboard-widget-card--activity::before,
.dashboard-widget-card--chart::before {
  background: linear-gradient(90deg, #10b981, #059669);
}

.dashboard-widget-card--placeholder::before {
  background: linear-gradient(90deg, #94a3b8, #64748b);
}

.dashboard-widget-card:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.dash-editor:not(.is-preview) .dashboard-widget-card {
  cursor: grab;
  border-style: dashed;
  border-color: rgba(30, 136, 229, 0.28);
}

.dash-editor:not(.is-preview) .dashboard-widget-card:active {
  cursor: grabbing;
}

.dashboard-widget-card--dragging {
  opacity: 0.45;
  transform: scale(0.98);
}

.dashboard-widget-card--drop-target {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(30, 136, 229, 0.2);
}

.dashboard-widget-card--wide {
  grid-column: span 2;
}

.dash-editor__board[data-viewport="mobile"] .dashboard-widget-card--wide {
  grid-column: span 1;
}

.dashboard-widget-card__drag {
  position: absolute;
  top: 10px;
  left: 8px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.05);
  pointer-events: none;
}

.dash-editor:not(.is-preview) .dashboard-widget-card__drag {
  display: inline-flex;
}

.dash-editor:not(.is-preview) .dashboard-widget-card__head {
  padding-left: 28px;
}

.dashboard-widget-card__remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  cursor: pointer;
}

.dash-editor:not(.is-preview) .dashboard-widget-card__remove {
  display: inline-flex;
}

.dashboard-widget-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-right: 28px;
}

.dashboard-widget-card__title {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.dashboard-widget-card__sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.dashboard-widget-card__icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 136, 229, 0.1);
  color: var(--primary, #1e88e5);
  flex-shrink: 0;
}

.dashboard-widget-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.dashboard-widget-card__value {
  font-size: 34px;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.dashboard-widget-card__empty {
  font-size: 13px;
  color: var(--muted);
}

.dashboard-widget-card__dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dashboard-widget-card__metric-k {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.dashboard-widget-card__metric-v {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dashboard-widget-water-bar {
  margin-top: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.dashboard-widget-water-bar > div {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #0284c7);
  border-radius: inherit;
}

.dashboard-widget-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 15px;
}

.dashboard-widget-status--online {
  color: #059669;
}

.dashboard-widget-status--offline {
  color: #dc2626;
}

.dashboard-widget-activity {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.dashboard-widget-activity__row {
  display: flex;
  gap: 8px;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.03);
}

.dashboard-widget-placeholder {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}

.dash-widget-type-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(30, 136, 229, 0.1);
  color: var(--primary-dark, #0c4a6e);
  font-weight: 650;
  font-size: 13px;
}

.dashboard-widget-modal {
  max-width: 480px;
}

.dashboard-widget-modal__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 980px) {
  .dash-editor {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .dash-editor__palette {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 280px;
  }

  .dashboard-widget-card--wide {
    grid-column: span 1;
  }
}

/* Widget panosu mockup hizası:
   "Widget panosu" ↔ "Widget'lar" aynı sol çizgi */
.main:has(#page-dashboards.active) {
  padding-left: 16px;
  padding-right: 16px;
}

.main:has(#page-dashboards.active) .topbar {
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-bottom: 12px;
}

.main:has(#page-dashboards.active) .page-title,
.main:has(#page-dashboards.active) .hexnet-page-title-text {
  padding-left: 0;
  margin-left: 0;
}

.main-body:has(#page-dashboards.active) {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

#page-dashboards {
  max-width: none !important;
  width: 100%;
  margin: 0 !important;
}

#page-dashboards .dash-editor {
  min-height: calc(100vh - 100px);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

/* Palet metni / kartları başlık ile aynı x (ekstra sol pad yok) */
#page-dashboards .dash-editor__palette-head {
  padding: 14px 14px 10px 0;
}

#page-dashboards .dash-editor__palette-scroll {
  padding: 10px 12px 16px 0;
}

#page-dashboards .dash-palette-group__label {
  padding-left: 0;
  margin-left: 0;
}

#page-dashboards .dash-palette-item {
  border-radius: 0; /* mockup seçili/liste kartı: dik köşe */
}

#page-dashboards .dash-editor__canvas-toolbar {
  padding-left: 14px;
}

#page-dashboards .dashboard-widgets-grid {
  justify-content: start;
}
