/* Industrial Dashboard Styles - C410-HP */
/* Ottimizzato per pannello touch industriale 1366x768 */

:root {
  /* Color Palette - Industrial Dark Theme */
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3a3a3a;
  --bg-panel: #252525;

  /* Accent Colors */
  --accent-red: #c62828;
  --accent-red-hover: #e53935;
  --accent-yellow: #f9a825;
  --accent-yellow-hover: #fbc02d;
  --accent-green: #2e7d32;
  --accent-green-hover: #43a047;
  --accent-blue: #1565c0;
  --accent-cyan: #00bcd4;

  /* Status Colors */
  --status-pending: #757575;
  --status-in-progress: #f9a825;
  --status-completed: #2e7d32;
  --status-error: #c62828;

  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-muted: #707070;

  /* Border & Dividers */
  --border-color: #404040;
  --border-light: #505050;

  /* Table */
  --table-header-bg: #3a3a3a;
  --table-row-odd: #2a2a2a;
  --table-row-even: #323232;
  --table-row-active: #3d3d3d;

  /* Spacing */
  --spacing-xs: 2px;
  --spacing-sm: 6px;
  --spacing-md: 10px;
  --spacing-lg: 14px;
  --spacing-xl: 18px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.5);

  /* Touch Target Size */
  --touch-target: 44px;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 1366px;
  height: 768px;
  font-family: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Main Container */
.dashboard {
  display: grid;
  grid-template-rows: 60px 1fr auto;
  height: 768px;
  width: 1366px;
  background: linear-gradient(135deg, var(--bg-primary) 0%, #0d0d0d 100%);
}

/* Status Bar */
.status-bar {
  background: var(--bg-tertiary);
  padding: var(--spacing-sm) var(--spacing-lg);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

/* Header - Altezza fissa 60px */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--spacing-lg);
  height: 60px;
  background: #4a4a4a;
  border-bottom: 2px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-xl);
}

.header-field {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.header-field label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-field .value {
  background: var(--bg-tertiary);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: 'Roboto Mono', monospace;
  font-size: 1rem;
  font-weight: 600;
  min-width: 150px;
  text-align: center;
}

.header-field .value.highlight {
  background: var(--accent-cyan);
  color: #000;
  border-color: var(--accent-cyan);
}

.btn-insert {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  height: 40px;
}

.btn-insert:hover {
  background: var(--border-light);
}

.btn-insert:active {
  transform: scale(0.98);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-xl);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.logo-img {
  height: 48px;
  width: auto;
}

.logo-placeholder {
  width: 44px;
  height: 36px;
  background: var(--accent-red);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.8rem;
}

.machine-info {
  text-align: right;
}

.machine-model {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
}

.machine-code {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.machine-code span {
  font-weight: 600;
  color: var(--text-primary);
}

/* Main Content */
.main-content {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--spacing-lg);
  padding: var(--spacing-lg);
  overflow: hidden;
}

/* Left Panel - Table & Parameters */
.left-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: var(--spacing-lg);
  height: 100%;
  overflow: hidden;
}

/* Table Section */
.table-section {
  background: var(--bg-panel);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  max-height: 280px;
}

/* Table Scroll Container - Sempre visibile per touch */
.table-scroll-container {
  flex: 1;
  overflow-y: scroll;
  overflow-x: hidden;
  /* Scrollbar sempre visibile */
  scrollbar-width: auto;
  scrollbar-color: var(--border-light) var(--bg-tertiary);
  -webkit-overflow-scrolling: touch;
}

/* Webkit scrollbar - sempre visibile */
.table-scroll-container::-webkit-scrollbar {
  width: 14px;
  display: block;
}

.table-scroll-container::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 0;
}

.table-scroll-container::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 7px;
  border: 3px solid var(--bg-tertiary);
  min-height: 40px;
}

.table-scroll-container::-webkit-scrollbar-thumb:hover {
  background: #606060;
}

.table-scroll-container::-webkit-scrollbar-thumb:active {
  background: #707070;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table thead {
  background: var(--table-header-bg);
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th {
  padding: var(--spacing-md);
  text-align: center;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-primary);
  line-height: 1.3;
}

.data-table tbody tr {
  transition: background-color 0.2s ease;
}

.data-table tbody tr:nth-child(odd) {
  background: var(--table-row-odd);
}

.data-table tbody tr:nth-child(even) {
  background: var(--table-row-even);
}

.data-table tbody tr:hover {
  background: var(--bg-tertiary);
}

.data-table tbody tr.active {
  background: var(--table-row-active);
  border-left: 3px solid var(--accent-cyan);
}

.data-table tbody tr.in-progress {
  background: linear-gradient(90deg, rgba(249, 168, 37, 0.2) 0%, transparent 100%);
  border-left: 3px solid var(--accent-yellow);
}

.data-table tbody tr.completed {
  background: linear-gradient(90deg, rgba(46, 125, 50, 0.2) 0%, transparent 100%);
  border-left: 3px solid var(--accent-green);
}

.data-table td {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  height: 36px;
}

.data-table td:first-child {
  font-weight: 600;
  color: var(--text-secondary);
}

.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.pending {
  background: var(--status-pending);
  color: var(--text-primary);
}

.status-badge.in-progress {
  background: var(--status-in-progress);
  color: #000;
}

.status-badge.completed {
  background: var(--status-completed);
  color: var(--text-primary);
}

/* Parameters Section - Espansa */
.params-section {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-md);
  align-content: stretch;
}

.param-group {
  background: var(--bg-panel);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: var(--spacing-sm) var(--spacing-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.param-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs) 0;
  border-bottom: 1px solid var(--border-color);
}

.param-row:last-child {
  border-bottom: none;
}

.param-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.param-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  min-width: 70px;
  text-align: center;
}

/* Right Panel - Visualization & Actions */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  height: 100%;
}

/* Visualization Panel - Full Height */
.visualization-panel {
  background: var(--bg-panel);
  border-radius: var(--radius-md);
  border: 4px solid var(--accent-green);
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  flex: 1;
}

.visualization-panel.error-state {
  border-color: var(--accent-red);
}

.visualization-panel.warning-state {
  border-color: var(--accent-yellow);
}

.viz-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.viz-direction {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
}

.viz-measurement {
  font-size: 4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.viz-graphic {
  margin-top: var(--spacing-md);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Piega Graphic */
.piega-graphic {
  position: relative;
  width: 160px;
  height: 60px;
}

.piega-shape {
  width: 100%;
  height: 50px;
  border: 3px solid var(--text-primary);
  border-radius: 0 25px 25px 0;
  position: relative;
}

.piega-shape::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 40%;
  height: 3px;
  background: var(--text-primary);
  transform: translateY(-50%);
}

/* Unione Graphic */
.unione-graphic {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
}

.unione-line {
  width: 80%;
  height: 3px;
  background: var(--text-primary);
  position: relative;
}

.unione-line::before,
.unione-line::after {
  content: '';
  position: absolute;
  top: -6px;
  width: 3px;
  height: 15px;
  background: var(--text-primary);
}

.unione-line::before {
  left: 30%;
}

.unione-line::after {
  right: 30%;
}

/* Phase Counter */
.phase-counter {
  background: var(--bg-panel);
  border-radius: var(--radius-md);
  padding: var(--spacing-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 2px solid var(--border-light);
  flex-shrink: 0;
  min-height: 80px;
}

.phase-label {
  font-size: 1.1rem;
  color: var(--text-primary);
  text-transform: uppercase;
  font-weight: 600;
}

.phase-numbers {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  font-size: 2.2rem;
  font-weight: 700;
}

.phase-current {
  color: var(--accent-cyan);
}

.phase-divider {
  color: var(--text-muted);
}

.phase-total {
  color: var(--text-secondary);
}

/* Action Buttons */
.actions-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 50px;
  box-shadow: var(--shadow-sm);
  line-height: 1.2;
  text-align: center;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent-green);
  color: var(--text-primary);
  border: 2px solid #2e7d32;
}

.btn-primary:hover {
  background: var(--accent-green-hover);
}

.btn-warning {
  background: var(--accent-yellow);
  color: #000;
  border: 2px solid #ffca28;
}

.btn-warning:hover {
  background: var(--accent-yellow-hover);
}

.btn-danger {
  background: var(--accent-red);
  color: var(--text-primary);
  border: 2px solid #c62828;
}

.btn-danger:hover {
  background: var(--accent-red-hover);
}

.btn-blue {
  background: var(--accent-blue);
  color: var(--text-primary);
  border: 2px solid #1e88e5;
}

.btn-blue:hover {
  background: #1976d2;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--border-light);
}

.btn-conclude-phase {
  background: transparent;
  border: 2px solid var(--text-primary);
  color: var(--text-primary);
}

.btn-conclude-phase:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-disabled,
.btn-disabled:hover {
  background: #4a4a4a;
  color: #707070;
  border: 2px solid #555;
  cursor: not-allowed;
}

.btn-disabled:active {
  transform: none;
}

/* Footer Actions - Controllo Macchina */
.footer-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-lg);
  padding: var(--spacing-lg);
  border-top: 2px solid var(--border-color);
  background: var(--bg-secondary);
}

.footer-actions .btn,
.footer-actions .btn-conclude-phase-panel {
  min-height: 70px;
  padding: var(--spacing-lg) var(--spacing-md);
  width: 75%;
  justify-self: center;
}

/* Loading State */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  margin-top: var(--spacing-lg);
  font-size: 1.1rem;
  color: var(--text-secondary);
  text-transform: lowercase;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

.empty-state-text {
  font-size: 1.1rem;
}

/* Conclude phase button */
.btn-conclude-phase-panel {
  background: transparent;
  border: 2px solid var(--text-primary);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  line-height: 1.3;
}

.btn-conclude-phase-panel:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Working indicator pulse animation */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-badge.in-progress {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Table loading overlay */
.table-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 26, 26, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius-md);
}

.loading-spinner-large {
  width: 80px;
  height: 80px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--accent-cyan);
  border-right-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Value states */
.value.active {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid var(--accent-cyan);
  color: var(--text-primary);
}

.value.highlight-cyan {
  background: var(--accent-cyan);
  color: #000;
  font-weight: 700;
}

.value.highlight-gray {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 700;
}

.value.border-green {
  border: 4px solid #2e7d32;
}

.value.border-red {
  border: 4px solid #c62828;
}

.machine-code.border-green {
  border: 4px solid #2e7d32;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.machine-code.border-red {
  border: 4px solid #c62828;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

/* Piega SVG */
.viz-graphic-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.piega-shape-svg {
  width: 160px;
  height: 60px;
}

.piega-shape-svg path {
  fill: none;
  stroke: var(--text-primary);
  stroke-width: 3;
}

/* Unione SVG */
.unione-shape-svg {
  width: 180px;
  height: 70px;
}

.unione-shape-svg path,
.unione-shape-svg line {
  fill: none;
  stroke: var(--text-primary);
  stroke-width: 3;
}
