/**
 * MetalVision - Estilos Centro de Trabajo (Workspace)
 */

/* ============================================
   WORKSPACE CONTAINER
   ============================================ */

.workspace-container {
  width: 100%;
  max-width: none;
}

.workspace-header {
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ============================================
   INBOX (BANDEJA)
   ============================================ */

.inbox-header {
  background: var(--surface);
}

.inbox-stats .badge {
  font-weight: 500;
}

.inbox-list {
  background: var(--bg);
}

/* Base item styles */
.inbox-item {
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--surface);
  margin-bottom: 2px;
}

.inbox-item:hover {
  background-color: var(--surface-hover);
  transform: translateX(2px);
}

.inbox-item > div {
  padding: 0.875rem 1rem !important;
  border-bottom: none !important;
}

/* Email items - estilos inline por direction */
.inbox-item-email.unread {
  font-weight: 500;
}

/* Task items */
.inbox-item-task {
  background: linear-gradient(to right, rgba(234, 179, 8, 0.05), var(--surface));
  border-left: 3px solid var(--warning);
}

/* Alert items */
.inbox-item-alert {
  border-left-width: 3px !important;
}

.inbox-item-alert > div {
  border-left: none !important;
}

/* Icon alignment */
.inbox-item-icon {
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
}

.inbox-item-icon .avatar-circle {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.inbox-item-icon .form-check {
  margin: 0;
  padding: 0;
  min-height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
}

.inbox-item-icon .form-check-input {
  margin: 0;
  width: 1.25rem;
  height: 1.25rem;
}

/* Content alignment */
.inbox-item-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.inbox-item-subject {
  font-size: 0.9rem;
  line-height: 1.3;
}

.inbox-item-preview {
  font-size: 0.8rem;
  opacity: 0.7;
  line-height: 1.3;
}

/* Actions */
.inbox-item-actions {
  opacity: 0;
  transition: opacity 0.15s ease;
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
}

.inbox-item:hover .inbox-item-actions {
  opacity: 1;
}

.inbox-footer {
  background: var(--surface);
}

/* ============================================
   PRODUCTION PANEL
   ============================================ */

.production-header {
  background: linear-gradient(135deg, var(--dark) 0%, color-mix(in srgb, var(--dark) 80%, var(--primary)) 100%);
}

.production-grid {
  background: var(--surface);
}

.production-area {
  height: 100%;
}

.area-header .badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.station-card {
  background: var(--surface);
  transition: all 0.15s ease;
}

.station-card:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.station-card.border-warning {
  border-width: 2px !important;
}

.avatar-mini {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 600;
}

/* ============================================
   KPI WIDGETS
   ============================================ */

.kpi-widgets {
  background: var(--surface);
}

.kpi-widget-item {
  transition: all 0.15s ease;
  background: var(--surface);
}

.kpi-widget-item:hover {
  background: var(--surface-hover);
  border-color: var(--primary) !important;
}

.kpi-icon {
  flex-shrink: 0;
}

.kpi-value {
  line-height: 1.2;
}

.kpi-label {
  font-size: 0.75rem;
  line-height: 1.2;
}

.kpi-trend {
  font-weight: 600;
}

/* ============================================
   ANIMACIONES
   ============================================ */

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

.spin i {
  animation: spin 0.5s linear;
}

/* Indicador de actualización en vivo */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.badge .bi-circle-fill {
  animation: pulse 2s ease-in-out infinite;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1199.98px) {
  .inbox-stats {
    display: none !important;
  }
}

@media (max-width: 991.98px) {
  .production-header .d-flex.gap-4 {
    flex-wrap: wrap;
    gap: 0.5rem !important;
  }
  
  .production-header .d-flex.gap-4 span {
    flex: 0 0 auto;
  }
  
  /* En tablets, 2 columnas */
  .workspace-container .col-lg-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  .workspace-container .col-lg-3 {
    flex: 0 0 50%;
    max-width: 50%;
  }
}

@media (max-width: 767.98px) {
  /* En móvil, todo a 1 columna */
  .workspace-container .col-lg-6,
  .workspace-container .col-lg-3 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  .inbox-list {
    max-height: 350px !important;
    min-height: 250px !important;
  }
  
  .production-grid {
    max-height: 300px !important;
  }
}

/* ============================================
   DARK MODE
   ============================================ */

.dark .inbox-item.unread {
  background-color: color-mix(in srgb, var(--primary) 15%, var(--surface));
}

.dark .station-card {
  border-color: var(--border);
}

.dark .production-header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* ============================================
   TASK PANEL - STATUS INDICATORS
   ============================================ */

.hub-task-item {
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.hub-task-item.status-urgent {
  border-left-color: var(--danger);
  background: linear-gradient(to right, rgba(220, 53, 69, 0.08), transparent);
}

.hub-task-item.status-high {
  border-left-color: var(--warning);
  background: linear-gradient(to right, rgba(255, 193, 7, 0.08), transparent);
}

.hub-task-item.status-in-progress {
  border-left-color: var(--primary);
  background: linear-gradient(to right, rgba(59, 130, 246, 0.08), transparent);
}

.hub-task-title .badge-sm {
  font-size: 0.65rem;
  padding: 0.15em 0.4em;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* Subtasks toggle */
.hub-task-subtasks-toggle {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.hub-task-subtasks-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
}

.hub-task-subtasks-toggle .bi-chevron-right,
.hub-task-subtasks-toggle .bi-chevron-down {
  font-size: 0.7rem;
  transition: transform 0.15s ease;
}

/* Subtasks list */
.hub-task-subtasks-list {
  margin-top: 8px;
  padding-left: 8px;
  border-left: 2px solid var(--border-muted, #e9ecef);
}

.hub-subtask-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 0.85rem;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.hub-subtask-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

.hub-subtask-item.completed .hub-subtask-title {
  text-decoration: line-through;
  opacity: 0.6;
}

.hub-subtask-item .form-check-input {
  margin: 0;
  flex-shrink: 0;
}

.hub-subtask-title {
  flex: 1;
}

/* Dark mode */
.dark .hub-task-item.status-urgent {
  background: linear-gradient(to right, rgba(220, 53, 69, 0.15), transparent);
}

.dark .hub-task-item.status-high {
  background: linear-gradient(to right, rgba(255, 193, 7, 0.12), transparent);
}

.dark .hub-task-item.status-in-progress {
  background: linear-gradient(to right, rgba(59, 130, 246, 0.15), transparent);
}

.dark .hub-task-subtasks-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
}

.dark .hub-subtask-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ============================================
   WORKSHOP PANEL - WORKSTATIONS
   ============================================ */

.hub-workshop-kpis {
  display: flex;
  justify-content: space-around;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.hub-kpi {
  text-align: center;
}

.hub-kpi-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
}

.hub-kpi-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.hub-workshop-detail {
  padding-top: 0.5rem;
}

.hub-workshop-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.15s ease;
}

.hub-workshop-toggle:hover {
  color: var(--text);
}

.hub-ws-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
  gap: 0.4rem !important;
}

.hub-ws-item {
  padding: 0.4rem 0.5rem;
  border-left: 3px solid var(--border);
  background: var(--surface);
  transition: all 0.15s ease;
  border-radius: 4px;
  min-width: 0;
  overflow: hidden;
}

.hub-ws-item:hover {
  background: var(--surface-hover);
}

.hub-ws-item.working {
  border-left-color: var(--success);
}

.hub-ws-item.idle {
  border-left-color: var(--secondary);
}

.hub-ws-item.maintenance {
  border-left-color: var(--warning);
}

.hub-ws-item.blocked {
  border-left-color: var(--danger);
}

.hub-ws-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hub-ws-status {
  font-size: 1rem;
}

.hub-ws-status i {
  font-size: 1rem;
}

.hub-ws-id {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  min-width: 0;
  overflow: hidden;
}

.hub-ws-id strong {
  font-weight: 600;
}

.hub-ws-name {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-ws-task {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.hub-ws-of {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--primary);
}

.hub-ws-progress {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.hub-ws-progress-bar {
  height: 100%;
  transition: width 0.3s ease;
}

.hub-ws-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-ws-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.25rem;
}

.hub-ws-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.25rem;
  font-size: 0.7rem;
}

.hub-ws-operator {
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.hub-ws-operator i {
  font-size: 0.7rem;
}

.hub-ws-queue {
  color: var(--warning);
  font-weight: 500;
}
