/* ==========================================
   SMARTFACTORY - CSS TERMINAL DE PLANTA (MES)
   ========================================== */

/* ── Barra de configuración estación/operario ─────────────── */
.terminal-config-bar {
  display: flex;
  align-items: center;
  gap: 0;
  height: 46px;
  padding: 0 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.terminal-config-group {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 0 0;
}

.terminal-config-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.terminal-config-select {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  min-width: 180px;
  outline: none;
  transition: border-color 0.15s;
}

.terminal-config-select:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px rgba(245,197,24,0.15);
}

.terminal-config-divider {
  width: 1px;
  height: 24px;
  background: var(--border-subtle);
  margin: 0 20px;
  flex-shrink: 0;
}

.terminal-config-spacer {
  flex: 1;
}

.terminal-config-status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}

.terminal-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.terminal-status-dot--idle    { background: var(--text-3); }
.terminal-status-dot--active  { background: var(--green); box-shadow: 0 0 6px rgba(46,125,50,0.5); }
.terminal-status-dot--paused  { background: var(--yellow); }

.terminal-status-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  white-space: nowrap;
}

/* ── Layout principal ─────────────────────────────────────── */
.terminal-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 20px;
  height: calc(100vh - 102px); /* 56px header + 46px config bar */
  overflow: hidden;
  box-sizing: border-box;
}

/* Left panel style */
.terminal-left-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  overflow: hidden;
}

.terminal-panel-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.scanner-card {
  flex-shrink: 0;
}

.scanner-card h3, .queue-card h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.5px;
}

.scanner-input-group {
  display: flex;
  gap: 8px;
}

.scanner-input-group input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

.scanner-hint {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 8px;
}

.queue-card {
  flex-grow: 1;
  overflow: hidden;
}

.panel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.count-badge {
  background: var(--yellow);
  color: #000;
  padding: 2px 6px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 900;
  margin-left: 4px;
}

.terminal-queue-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex-grow: 1;
  padding-right: 4px;
}

/* Queue Card Items */
.terminal-queue-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  cursor: pointer;
  transition: all var(--transition-slow);
  user-select: none;
}

.terminal-queue-item:hover {
  border-color: var(--text-3);
  transform: translateY(-2px);
  background: rgba(255,255,255,0.02);
}

.terminal-queue-item.active {
  background: rgba(245, 197, 24, 0.05);
  border-color: var(--yellow);
  border-left-color: var(--yellow);
}
.terminal-queue-item.awaiting {
  border-left-color: var(--blue, #3498db);
  animation: pulse-awaiting 2s ease-in-out infinite;
}
@keyframes pulse-awaiting {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 8px rgba(52,152,219,0.4); }
}

.queue-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.queue-item-code {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--yellow);
  font-size: 12px;
}

.queue-item-state {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Queue State Colors */
.state-badge-released { background: rgba(52, 152, 219, 0.15); color: #3498db; border: 1px solid rgba(52, 152, 219, 0.3); }
.state-badge-queued { background: rgba(148, 163, 184, 0.15); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.3); }
.state-badge-in-progress { background: rgba(46, 204, 113, 0.15); color: #2ecc71; border: 1px solid rgba(46, 204, 113, 0.3); }
.state-badge-paused { background: rgba(241, 196, 15, 0.15); color: #f1c40f; border: 1px solid rgba(241, 196, 15, 0.3); }
.state-badge-blocked { background: rgba(231, 76, 60, 0.15); color: #e74c3c; border: 1px solid rgba(231, 76, 60, 0.3); animation: flashRed 1.5s infinite; }
.state-badge-rework { background: rgba(230, 126, 34, 0.15); color: #e67e22; border: 1px solid rgba(230, 126, 34, 0.3); }
.state-badge-inspection { background: rgba(155, 89, 182, 0.15); color: #9b59b6; border: 1px solid rgba(155, 89, 182, 0.3); }

.queue-item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-item-prod {
  font-size: 11px;
  color: var(--text-3);
}

/* Right panel style */
.terminal-right-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}

.terminal-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  text-align: center;
  padding: 40px;
  color: var(--text-3);
}

.terminal-placeholder h2 {
  font-family: var(--font-sans);
  font-size: 18px;
  margin-top: 16px;
  margin-bottom: 8px;
  color: var(--text-2);
}

.terminal-placeholder p {
  font-size: 13px;
}

/* Active Task Content Layout */
.terminal-execution-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px;
  box-sizing: border-box;
  overflow-y: auto;
}

.exec-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.exec-order-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  background: var(--yellow);
  color: #000;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 6px;
}

.exec-header h2 {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 900;
  color: var(--text-1);
}

.exec-product-name {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 4px;
}

.mes-badge {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
  text-align: center;
  text-transform: uppercase;
}

.state-released { background: rgba(52, 152, 219, 0.1); color: #3498db; border: 1px solid #3498db; }
.state-queued { background: rgba(148, 163, 184, 0.1); color: #94a3b8; border: 1px solid #94a3b8; }
.state-in-progress { background: rgba(46, 204, 113, 0.1); color: #2ecc71; border: 1px solid #2ecc71; }
.state-paused { background: rgba(241, 196, 15, 0.1); color: #f1c40f; border: 1px solid #f1c40f; }
.state-blocked { background: rgba(231, 76, 60, 0.15); color: #e74c3c; border: 1px solid #e74c3c; animation: flashRedBorder 1.5s infinite; }
.state-rework { background: rgba(230, 126, 34, 0.1); color: #e67e22; border: 1px solid #e67e22; }
.state-inspection { background: rgba(155, 89, 182, 0.1); color: #9b59b6; border: 1px solid #9b59b6; }

/* Timers Grid style */
.exec-timers-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.timer-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  text-align: center;
  position: relative;
  transition: all 0.3s ease;
}

.timer-card.active-timer {
  background: rgba(255, 255, 255, 0.03);
}

/* Card highlight states */
.timer-setup.active-timer { border-color: #3498db; box-shadow: 0 0 10px rgba(52, 152, 219, 0.2); }
.timer-productive.active-timer { border-color: #2ecc71; box-shadow: 0 0 10px rgba(46, 204, 113, 0.2); }
.timer-paused.active-timer { border-color: #f1c40f; box-shadow: 0 0 10px rgba(241, 196, 15, 0.2); }
.timer-blocked.active-timer { border-color: #e74c3c; box-shadow: 0 0 10px rgba(231, 76, 60, 0.2); animation: flashRedBorder 1.5s infinite; }

.timer-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.timer-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
}

.timer-setup.active-timer .timer-value { color: #3498db; }
.timer-setup.active-timer .timer-label { color: #3498db; }
.timer-productive.active-timer .timer-value { color: #2ecc71; }
.timer-productive.active-timer .timer-label { color: #2ecc71; }
.timer-paused.active-timer .timer-value { color: #f1c40f; }
.timer-paused.active-timer .timer-label { color: #f1c40f; }
.timer-blocked.active-timer .timer-value { color: #e74c3c; }
.timer-blocked.active-timer .timer-label { color: #e74c3c; }

/* Instructions and Checklist */
.exec-instructions {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 20px;
}

.exec-instructions h4 {
  margin-top: 0;
  margin-bottom: 10px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  color: var(--yellow);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.exec-instructions p {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 12px;
  line-height: 1.4;
}

.qa-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  margin-top: 8px;
}

.checkpoint-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.checkpoint-item:hover {
  background: rgba(255,255,255,0.02);
}

.checkpoint-item input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.checkpoint-item-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text-2);
}

.checkpoint-item-details strong {
  color: var(--text-1);
}

.mandatory-tag {
  background: rgba(231, 76, 60, 0.1);
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.3);
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
  margin-left: 6px;
  text-transform: uppercase;
}

/* Andon call status bar */
.active-andon-alert-bar {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid #e74c3c;
  color: #e74c3c;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 0 15px rgba(231,76,60,0.2);
  animation: flashRedBorder 1.5s infinite;
}

.flashing-icon {
  font-size: 18px;
  animation: rotateBell 2s infinite;
}

/* Control Buttons (Setup, Start, Pause, Resume, Complete) */
.exec-actions-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto; /* push to bottom */
}

.action-row-primary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.btn-terminal {
  border: none;
  border-radius: 6px;
  padding: 18px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all var(--transition-slow);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.btn-terminal:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
}

.btn-terminal:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-sm);
}

.btn-terminal[disabled] {
  background: var(--border) !important;
  color: var(--text-3) !important;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  opacity: 0.5;
}

.btn-accept { background: linear-gradient(135deg, #1a7a3a, #27ae60); border-bottom: 3px solid #145a2b; color: #fff; }
.btn-setup { background: linear-gradient(135deg, #2980b9, #3498db); border-bottom: 3px solid #2471a3; }
.btn-start { background: linear-gradient(135deg, #27ae60, #2ecc71); border-bottom: 3px solid #1e8449; }
.btn-pause { background: linear-gradient(135deg, #d35400, #e67e22); border-bottom: 3px solid #a04000; }
.btn-resume { background: linear-gradient(135deg, #16a085, #1abc9c); border-bottom: 3px solid #117a65; }
.btn-complete { background: linear-gradient(135deg, #2c3e50, #7f8c8d); border-bottom: 3px solid #1a252f; }

/* Secondary tactile actions */
.action-row-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.btn-terminal-sec {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-1);
  border-radius: 6px;
  padding: 12px 10px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-slow);
}

.btn-terminal-sec:hover {
  background: rgba(255,255,255,0.03);
  border-color: var(--text-3);
}

.btn-andon-sup { border-color: rgba(241, 196, 15, 0.4); color: var(--yellow); }
.btn-andon-sup:hover { background: rgba(241, 196, 15, 0.05); }
.btn-andon-mat { border-color: rgba(52, 152, 219, 0.4); color: #3498db; }
.btn-andon-mat:hover { background: rgba(52, 152, 219, 0.05); }
.btn-defect { border-color: rgba(231, 76, 60, 0.4); color: #e74c3c; }
.btn-defect:hover { background: rgba(231, 76, 60, 0.05); }

/* Animation keyframes */
@keyframes flashRed {
  0%, 100% { background: rgba(231, 76, 60, 0.15); color: #e74c3c; }
  50% { background: rgba(231, 76, 60, 0.4); color: #fff; }
}

@keyframes flashRedBorder {
  0%, 100% { border-color: #e74c3c; box-shadow: 0 0 5px rgba(231, 76, 60, 0.2); }
  50% { border-color: #ff0000; box-shadow: 0 0 15px rgba(231, 76, 60, 0.5); }
}

@keyframes rotateBell {
  0%, 100% { transform: rotate(0); }
  10%, 30% { transform: rotate(15deg); }
  20%, 40% { transform: rotate(-15deg); }
  50% { transform: rotate(0); }
}

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


/* ═══ Fase 1 planmovil — Terminal usable en teléfono (apilar el grid) ═══ */
@media (max-width: 768px) {
  .terminal-config-bar {
    height: auto;
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 10px;
  }
  .terminal-config-group { padding: 0; }
  .terminal-config-divider { display: none; }
  .terminal-config-spacer { display: none; }
  .terminal-config-status { width: 100%; }
  .terminal-config-select { min-width: 0; flex: 1; }

  .terminal-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
    gap: 14px;
  }
  .terminal-left-panel,
  .terminal-right-panel {
    height: auto;
    overflow: visible;
  }
  /* La cola arriba, acotada para no empujar demasiado el panel de ejecución */
  .terminal-queue-list { max-height: 45vh; }
  .terminal-execution-content { height: auto; overflow: visible; }
}
