/* Timeline Grid View for Schedule Slots */

.timeline-view {
  margin-bottom: 1.5rem;
}

.timeline-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.timeline-navigation {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.timeline-time-range {
  font-weight: 500;
  color: var(--bs-body-color);
  min-width: 120px;
  text-align: center;
}

.timeline-grid-wrapper {
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  border-radius: 0.375rem;
  border: 1px solid var(--bs-border-color);
  background: white;
}

.timeline-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 0;
}

.timeline-grid thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: white;
}

.timeline-grid th {
  background: var(--bs-light);
  padding: 0.75rem 0.5rem;
  text-align: center;
  font-weight: 600;
  border: 1px solid var(--bs-border-color);
  white-space: nowrap;
  font-size: 0.875rem;
  color: var(--bs-body-color);
  min-width: 100px;
}

.timeline-grid th.resource-header {
  background: var(--bs-light);
  position: sticky;
  left: 0;
  z-index: 11;
  min-width: 140px;
  max-width: 140px;
  text-align: left;
  padding-left: 1rem;
}

.timeline-grid td {
  border: 1px solid var(--bs-border-color);
  padding: 0;
  vertical-align: top;
}

.timeline-grid td.resource-name {
  font-weight: 500;
  padding: 0.75rem 0.5rem;
  background: var(--bs-light);
  position: sticky;
  left: 0;
  z-index: 9;
  min-width: 140px;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 2px solid var(--bs-border-color);
}

.timeline-grid td.time-block {
  padding: 0.25rem;
  background: white;
  min-width: 100px;
}

.timeline-grid td.time-block.has-slots {
  background: #f8f9fa;
}

.slots-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 40px;
}

.slot {
  border: none;
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  text-align: center;
  font-weight: 500;
  border: 1px solid transparent;
  width: 100%;
}

.slot.available {
  background: #d1e7dd;
  color: #0a3622;
  border-color: #a3cfbb;
}

.slot.available:hover {
  background: #198754;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.slot.available:active {
  transform: translateY(0);
}

.slot.unavailable {
  background: #e9ecef;
  color: #6c757d;
  cursor: not-allowed;
  opacity: 0.6;
  border-color: #dee2e6;
}

.slot.low-capacity {
  background: #fff3cd;
  color: #664d03;
  border-color: #ffe69c;
}

.slot.low-capacity:hover {
  background: #ffc107;
  color: #000;
}

.slot-capacity {
  font-size: 0.65rem;
  opacity: 0.8;
  margin-left: 0.25rem;
}

.timeline-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bs-secondary);
}

.timeline-loading {
  text-align: center;
  padding: 2rem;
  color: var(--bs-secondary);
}

/* Компактный режим для маленьких экранов */
@media (max-width: 992px) {
  .timeline-grid {
    font-size: 0.8rem;
  }

  .timeline-grid th,
  .timeline-grid td.resource-name {
    min-width: 100px;
    max-width: 100px;
    padding: 0.5rem 0.35rem;
    font-size: 0.8rem;
  }

  .timeline-grid td.time-block {
    min-width: 85px;
  }

  .slot {
    font-size: 0.7rem;
    padding: 0.3rem 0.4rem;
  }

  .slot-capacity {
    font-size: 0.6rem;
  }
}

@media (max-width: 768px) {
  .timeline-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .timeline-navigation {
    justify-content: space-between;
    width: 100%;
  }

  .timeline-grid th,
  .timeline-grid td.resource-name {
    min-width: 80px;
    max-width: 80px;
    font-size: 0.75rem;
    padding: 0.4rem 0.25rem;
  }

  .timeline-grid td.time-block {
    min-width: 70px;
  }

  .slot {
    font-size: 0.65rem;
    padding: 0.25rem 0.3rem;
  }
}

/* Scroll hint для горизонтального скролла */
.timeline-grid-wrapper::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(to left, rgba(255,255,255,0.9), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.timeline-grid-wrapper.has-scroll::after {
  opacity: 1;
}

/* Accessibility */
.slot:focus {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
  z-index: 1;
}

.slot:disabled {
  pointer-events: none;
}

/* Print styles */
@media print {
  .timeline-controls {
    display: none;
  }

  .timeline-grid-wrapper {
    overflow: visible;
    border: none;
  }

  .slot {
    border: 1px solid #000;
  }
}

/* Extras Timeline for Booking Page */
.extra-timeline-wrapper {
  margin-top: 0.5rem;
}

.extra-resource-timeline {
  margin-bottom: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  background: var(--bs-light);
}

.extra-resource-timeline:last-child {
  margin-bottom: 0;
}

.extra-resource-name {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  color: var(--bs-body-color);
}

.extra-slots-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.extra-slot-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid #dee2e6;
  border-radius: 0.25rem;
  background: white;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.875rem;
  user-select: none;
}

.extra-slot-item:hover:not(:has(input:disabled)) {
  background: #f8f9fa;
  border-color: #0d6efd;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.extra-slot-item.selected {
  background: #d1e7dd;
  border-color: #198754;
  color: #0a3622;
}

.extra-slot-item:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.6;
}

.extra-slot-checkbox {
  cursor: pointer;
  margin: 0;
}

.extra-slot-checkbox:disabled {
  cursor: not-allowed;
}

.extra-slot-time {
  font-weight: 500;
  white-space: nowrap;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .extra-resource-timeline {
    padding: 0.5rem;
  }

  .extra-slots-grid {
    gap: 0.35rem;
  }

  .extra-slot-item {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
  }
}
