/* Dashboard V2 - Main Styles */

/* Dashboard Grid Container con colonne dinamiche */
.dashboard-grid-container {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns, 8), 1fr);
  gap: var(--grid-gap, 20px);
  width: 100%;
  margin: 0;
  padding: var(--default-page-padding);
}

/* Dashboard Controls */
.dashboard-controls {
  padding: var(--default-page-padding);
}

.dashboard-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background: var(--color-background);
  text-align: center;
}

/* Dashboard Panel base */
.dashboard-panel {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
}

.dashboard-panel.drag-enabled {
  cursor: grab;
  transition: box-shadow 0.2s ease;
}

.dashboard-panel.is-dragging {
  opacity: 0.6;
  cursor: grabbing;
}

.dashboard-panel.drag-over {
  outline: 2px dashed var(--color-accent);
  outline-offset: 4px;
}

.dashboard-panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.dashboard-panel-settings {
  display: flex;
  position: relative;
  gap: 5px;
}

.menu-container {
  display: none;
  position: absolute;
  padding-top: var(--menu-padding);
  z-index: 1;
  top: 100%;
}

.menu-container.active {
  display: flex;
}

.dropdown-btn.active {
  color: var(--color-accent);
}

.menu {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-secondary);
  border-radius: var(--menu-border-radius);
  border: 1px solid var(--color-border-light);
  padding: var(--menu-padding);
  gap: var(--menu-items-gap);
}

.menu button {
  width: 100%;
}

/* Panel Header */
.panel-header {
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 5px 5px 5px;
}

.panel-title {
  margin: 0;
  font-size: 1rem;
  color: var(--color-text-primary);
}

/* Panel Content */
.panel-content {
  flex: 1;
  display: flex;
  position: relative;
  padding: 5px 5px 5px 5px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100px;
}

.dashboard-panel .dashboard-table {
  width: 100%;
  height: 100%;
}

.dashboard-table .tabulator,
.dashboard-table .tabulator-tableHolder {
  height: 100% !important;
}

.dashboard-table-fallback {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.dashboard-table-fallback th,
.dashboard-table-fallback td {
  border: 1px solid var(--color-border-subtle);
  padding: 6px 8px;
  text-align: left;
}

.dashboard-table-fallback thead {
  background: var(--color-bg-secondary);
}

/* Resize handles */
.resize-handles { pointer-events: none; }
.resize-handle {
  display: none;
  position: absolute;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-light);
  opacity: 0.6;
  border-radius: 2px;
  pointer-events: auto;
  z-index: 2;
}
.resize-handle:hover { opacity: 1; }

/* Edges */
.resize-handle[data-dir="e"] { top: 50%; right: -3px; transform: translateY(-50%); width: 6px; height: 28px; cursor: e-resize; }
.resize-handle[data-dir="w"] { top: 50%; left: -3px;  transform: translateY(-50%); width: 6px; height: 28px; cursor: w-resize; }
.resize-handle[data-dir="s"] { left: 50%; bottom: -3px; transform: translateX(-50%); width: 28px; height: 6px; cursor: s-resize; }
.resize-handle[data-dir="n"] { left: 50%; top: -3px;    transform: translateX(-50%); width: 28px; height: 6px; cursor: n-resize; }

/* Corners */
.resize-handle[data-dir="se"] { right: -3px; bottom: -3px; width: 10px; height: 10px; cursor: se-resize; }
.resize-handle[data-dir="ne"] { right: -3px; top: -3px;    width: 10px; height: 10px; cursor: ne-resize; }
.resize-handle[data-dir="sw"] { left: -3px;  bottom: -3px; width: 10px; height: 10px; cursor: sw-resize; }
.resize-handle[data-dir="nw"] { left: -3px;  top: -3px;    width: 10px; height: 10px; cursor: nw-resize; }

/* Edit Mode rules removed per request */

/* Chart Error Display */
.chart-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  text-align: center;
  color: var(--color-text-secondary);
}

.error-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.error-message {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.error-detail {
  font-size: 0.875rem;
  color: var(--color-text-tertiary);
}

/* Panel Debug Info (development only) */
.panel-debug-info {
  border-top: 1px solid var(--color-border-subtle);
  padding: 0.5rem 1rem;
  background: var(--color-surface-secondary);
}

.panel-debug-info details {
  font-size: 0.75rem;
}

.panel-debug-info summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.debug-content {
  margin-top: 0.5rem;
  font-family: monospace;
  line-height: 1.4;
  color: var(--color-text-tertiary);
}

/* Responsive Design */
@media (max-width: 1200px) {

}

@media (max-width: 768px) {
  .panel-meta {
    align-self: flex-end;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}
