/* ============================================
   Schedule Grid & Week Selector
   ============================================ */

/* Week Navigation */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.week-nav-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.week-nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.week-selector {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
}

.week-selector-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.week-selector-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.week-selector-btn.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(79, 124, 255, 0.3);
}

.week-nav-arrows {
  display: flex;
  gap: var(--space-1);
}

.week-arrow-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.week-arrow-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.week-arrow-btn svg {
  width: 16px;
  height: 16px;
}

.week-label {
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.week-dates {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

/* Publish Status */
.publish-status {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.status-indicator.draft {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-yellow);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-indicator.published {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  animation: pulse 2s infinite;
}

.status-dot.draft {
  background: var(--accent-yellow);
}

.status-dot.published {
  background: var(--accent-green);
}

/* Events Row */
.events-row {
  margin-bottom: var(--space-4);
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.events-row-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 600;
}

.events-row-header svg {
  width: 16px;
  height: 16px;
  color: var(--accent-orange);
}

.events-container {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  width: 100%;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.event-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.2);
  color: var(--accent-orange);
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.event-chip:hover {
  background: rgba(249, 115, 22, 0.18);
  transform: translateY(-1px);
}

.event-chip-date {
  color: var(--text-tertiary);
  font-weight: 500;
}

.event-chip-actions {
  display: flex;
  gap: 5px;
  align-items: center;
}

.event-chip-actions button {
  opacity: 0.6;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.event-chip-actions button:hover {
  opacity: 1;
  transform: scale(1.2);
}

.event-chip-actions button svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.2;
}

/* Schedule Grid */
.schedule-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-primary);
  background: var(--bg-card);
  animation: fadeIn 0.5s ease-out;
}

.schedule-grid {
  display: grid;
  grid-template-columns: 160px repeat(7, 1fr);
  min-width: 900px;
}

/* Grid Header */
.schedule-header-cell {
  padding: var(--space-4) var(--space-3);
  text-align: center;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-primary);
  border-right: 1px solid var(--border-primary);
  position: sticky;
  top: 0;
  z-index: 5;
}

.schedule-header-cell:first-child {
  text-align: left;
  padding-left: var(--space-5);
  position: sticky;
  left: 0;
  z-index: 6;
  background: var(--bg-secondary);
}

.schedule-header-cell:last-child {
  border-right: none;
}

.schedule-header-day {
  display: block;
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.schedule-header-date {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 500;
}

.schedule-header-cell.today {
  background: rgba(79, 124, 255, 0.08);
}

.schedule-header-cell.today .schedule-header-day {
  color: var(--accent-blue);
}

/* Section Row Header */
.schedule-section-cell {
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border-primary);
  border-right: 1px solid var(--border-primary);
  background: var(--bg-card);
  position: sticky;
  left: 0;
  z-index: 4;
  min-height: 70px;
}

.schedule-section-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.schedule-section-name {
  font-weight: 600;
  font-size: var(--font-size-base);
  white-space: nowrap;
}

.schedule-section-count {
  margin-left: auto;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 500;
}

/* Shift Cell */
.shift-cell {
  padding: var(--space-2);
  border-bottom: 1px solid var(--border-primary);
  border-right: 1px solid var(--border-primary);
  min-height: 70px;
  transition: background var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.shift-cell:last-child {
  border-right: none;
}

.shift-cell:hover {
  background: rgba(79, 124, 255, 0.04);
}

.shift-cell.today {
  background: rgba(79, 124, 255, 0.04);
}

/* Shift Chip inside cells */
.shift-chip {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  margin-bottom: var(--space-1);
  transition: all var(--transition-fast);
  cursor: pointer;
  border-left: 3px solid transparent;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.shift-chip:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: var(--shadow-md);
  filter: brightness(1.15);
}

.shift-chip-name {
  font-weight: 700;
  font-size: var(--font-size-xs);
  line-height: 1.2;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ffffff; /* Texto del nombre en blanco puro */
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.shift-chip-time {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.85); /* Hora en blanco ligeramente translúcido */
  font-weight: 600;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
  white-space: normal; /* Permite saltos de línea para el turno partido o rangos largos */
  line-height: 1.3;
  margin-top: 2px;
}

/* Shift Types - Estilo Dark Premium con fondos oscuros saturados y texto blanco */
.shift-chip.morning {
  background: #1e3a8a; /* Azul oscuro profundo */
  border-left: 3.5px solid #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-left-width: 3.5px;
}

.shift-chip.afternoon {
  background: #581c87; /* Púrpura oscuro vibrante */
  border-left: 3.5px solid #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-left-width: 3.5px;
}

.shift-chip.night {
  background: #115e59; /* Teal oscuro */
  border-left: 3.5px solid #14b8a6;
  border: 1px solid rgba(20, 184, 166, 0.3);
  border-left-width: 3.5px;
}

.shift-chip.split {
  background: #7c2d12; /* Ocre/Naranja oscuro quemado */
  border-left: 3.5px solid #f97316;
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-left-width: 3.5px;
}

/* Libre: Gris oscuro mate para no distraer pero distinguirse con claridad */
.shift-chip.off {
  background: #1e293b;
  border-left: 3.5px solid #64748b;
  border: 1px solid rgba(100, 116, 139, 0.2);
  border-left-width: 3.5px;
}

.shift-chip.off .shift-chip-name {
  color: #e2e8f0;
  font-weight: 600;
}

.shift-chip.off .shift-chip-time {
  color: #94a3b8;
}

.shift-chip.vacation {
  background: #831843; /* Magenta oscuro */
  border-left: 3.5px solid #ec4899;
  border: 1px solid rgba(236, 72, 153, 0.3);
  border-left-width: 3.5px;
}

/* Empty cell add button */
.shift-cell-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 40px;
  border: 1px dashed var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.shift-cell:hover .shift-cell-empty {
  opacity: 1;
}

.shift-cell-empty svg {
  width: 16px;
  height: 16px;
}

/* Schedule Legend */
.schedule-legend {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-weight: 600;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Colores de la leyenda alineados al estilo Dark */
.legend-color.morning {
  background: #1e3a8a;
  border-left: 3px solid #3b82f6;
}

.legend-color.afternoon {
  background: #581c87;
  border-left: 3px solid #a855f7;
}

.legend-color.night {
  background: #115e59;
  border-left: 3px solid #14b8a6;
}

.legend-color.split {
  background: #7c2d12;
  border-left: 3px solid #f97316;
}

.legend-color.off {
  background: #1e293b;
  border-left: 3px solid #64748b;
}

.legend-color.vacation {
  background: #831843;
  border-left: 3px solid #ec4899;
}

/* Edit Modal */
.shift-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.shift-modal-overlay.active {
  opacity: 1;
  visibility: visible;
  padding: 16px;
}

.shift-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.9);
  transition: transform var(--transition-spring);
}

.shift-modal-overlay.active .shift-modal {
  transform: scale(1);
}

.shift-modal-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  margin-bottom: var(--space-6);
  letter-spacing: -0.01em;
}

.shift-modal-field {
  margin-bottom: var(--space-4);
}

.shift-modal-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.shift-modal-input {
  width: 100%;
}

.shift-modal-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
  justify-content: flex-end;
}

/* Confirm publish modal */
.publish-modal-content {
  text-align: center;
}

.publish-modal-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--gradient-success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-5);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.3);
}

.publish-modal-icon svg {
  width: 28px;
  height: 28px;
  color: white;
}

.publish-modal-desc {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  margin-top: var(--space-2);
  line-height: 1.5;
}

/* Responsive */
@media (max-width: 768px) {
  .week-nav {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .schedule-grid {
    grid-template-columns: 100px repeat(7, minmax(90px, 1fr));
  }
}
