/* ============================================================================
   Book View - Excel-like Calendar Grid for Reservations
   ============================================================================ */

/* Page header */
.book-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.book-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.book-quick-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.book-quick-links .btn {
  font-size: 0.8125rem;
  padding: 0.375rem 0.75rem;
}

/* Filter bar */
.book-filters {
  background: var(--bg-surface);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border-color);
}

.book-filters-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
}

.book-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.book-filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  color: var(--text-secondary);
}

.book-filter-group input[type="date"],
.book-filter-group select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.875rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  min-height: 40px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.book-filter-group input[type="date"]:focus,
.book-filter-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.book-nav-buttons {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.book-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
  cursor: pointer;
}

.book-nav-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}

.book-nav-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.book-nav-btn.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: white;
}

/* Room type card */
.book-room-type {
  background: var(--bg-surface);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.book-room-type-header {
  padding: 0.875rem 1rem;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.book-room-type-header h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.book-room-type-header .bed-count {
  font-size: 0.75rem;
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

/* Grid container */
.book-grid-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* The calendar grid table */
.book-grid {
  width: 100%;
  border-collapse: collapse;
  min-width: max-content;
  font-size: 0.8125rem;
}

/* Header cells */
.book-grid thead th {
  background: var(--bg-hover);
  border-bottom: 2px solid var(--border-color);
  padding: 0.5rem 0.25rem;
  text-align: center;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

.book-grid .bed-col {
  width: 50px;
  min-width: 50px;
  background: var(--bg-hover);
  position: sticky;
  left: 0;
  z-index: 11;
  border-right: 2px solid var(--border-color);
  text-align: center;
}

.book-grid .date-col {
  min-width: 80px;
  width: 80px;
}

/* Date header content */
.date-header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.date-day-name {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.date-day-number {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

.date-month {
  font-size: 0.625rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* Today column highlight */
.book-grid .date-col.today {
  background: rgba(37, 99, 235, 0.1);
}

.book-grid .date-col.today .date-day-number {
  color: var(--primary);
}

.book-grid td.today-col {
  background: rgba(37, 99, 235, 0.05);
}

/* Body cells */
.book-grid tbody td {
  border: 1px solid var(--border-light);
  padding: 0;
  vertical-align: middle;
  height: 36px;
}

.book-grid tbody tr:hover td:not(.bed-cell) {
  background-color: rgba(37, 99, 235, 0.03);
}

.book-grid .bed-cell {
  background: var(--bg-hover);
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  font-size: 0.75rem;
  position: sticky;
  left: 0;
  z-index: 5;
  border-right: 2px solid var(--border-color);
}

/* Empty cell */
.book-grid .empty-cell {
  background: var(--bg-surface);
}

/* Reservation cells */
.book-grid .reservation-cell {
  position: relative;
  overflow: hidden;
}

.book-grid .reservation-cell .cell-content {
  display: block;
  padding: 0.25rem 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  color: inherit;
  height: 100%;
  line-height: 1.8;
}

.book-grid .reservation-cell .cell-content:hover {
  text-decoration: none;
}

/* Status colors */
.book-grid .status-confirmed {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.book-grid .status-confirmed-by-guest {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  color: white;
}

.book-grid .status-not-confirmed {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
}

.book-grid .status-waiting {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
}

.book-grid .status-arrived {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

.book-grid .status-cancelled {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.book-grid .status-other {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  color: white;
}

.book-grid .guest-in-bed {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
}

/* Arrival indicator (first day of reservation shows small arrow) */
.book-grid .reservation-cell.arrival::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: rgba(255, 255, 255, 0.5);
}

/* Overbooked section */
.book-grid .overbooked-header td {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  font-weight: 600;
  text-align: left;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.book-grid .overbooked-row .bed-cell {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.book-grid .overbooked-row .reservation-cell {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

/* Waiting list section */
.book-grid .waiting-header td {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  font-weight: 600;
  text-align: left;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.book-grid .waiting-row .bed-cell {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.book-grid .waiting-row .reservation-cell {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #78350f;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .book-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .book-header h1 {
    font-size: 1.25rem;
  }

  .book-quick-links {
    width: 100%;
  }

  .book-quick-links .btn {
    flex: 1;
    justify-content: center;
    text-align: center;
  }

  .book-filters {
    padding: 1rem;
  }

  .book-filters-form {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .book-filter-group {
    width: 100%;
  }

  .book-filter-group input[type="date"],
  .book-filter-group select {
    width: 100%;
    min-height: 44px;
  }

  .book-nav-buttons {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 0.5rem;
  }

  .book-nav-btn {
    min-height: 44px;
  }

  .book-room-type {
    border-radius: 8px;
  }

  .book-grid .date-col {
    min-width: 60px;
    width: 60px;
  }

  .book-grid .bed-col {
    width: 40px;
    min-width: 40px;
  }

  .book-grid tbody td {
    height: 32px;
  }

  .book-grid .reservation-cell .cell-content {
    font-size: 0.6875rem;
    padding: 0.125rem 0.25rem;
  }

  .date-day-number {
    font-size: 1rem;
  }
}

/* Loading state */
.book-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.book-loading::after {
  content: '';
  width: 24px;
  height: 24px;
  margin-left: 0.5rem;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Empty state */
.book-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

/* Legend */
.book-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
  margin-top: 1rem;
  background: var(--bg-surface);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.book-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.book-legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

.book-legend-color.confirmed { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.book-legend-color.not-confirmed { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.book-legend-color.arrived { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }
.book-legend-color.guest { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); }
.book-legend-color.overbooked { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }
