/* ============================================================================
   Availability Grid - Mobile-First Responsive Design
   ============================================================================ */

/* Date Navigation */
.availability-date-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  padding: 1rem;
  background: var(--bg-surface);
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
}

.date-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.date-nav-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.date-nav-group .date-picker {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.875rem;
  background: var(--bg-surface);
  color: var(--text-primary);
}

.date-nav-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.date-nav-prev {
  margin-left: auto;
}

/* Legend */
.availability-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.legend-high {
  background: rgba(22, 163, 74, 0.5);
}
.legend-medium {
  background: rgba(217, 119, 6, 0.5);
}
.legend-low {
  background: rgba(220, 38, 38, 0.5);
}
.legend-overbook {
  background: #1f2937;
  border: 2px solid #dc2626;
}

.legend-indicator.override-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 0 1px var(--primary);
}

/* Grid Wrapper - enables horizontal scroll */
.availability-grid-wrapper {
  background: var(--bg-surface);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.availability-grid {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.availability-grid table {
  border-collapse: collapse;
  min-width: 100%;
}

/* Sticky first column */
.sticky-col {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--bg-surface);
  border-right: 2px solid var(--border-color);
}

/* Header cells */
.availability-grid th {
  padding: 0.5rem 0.25rem;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--border-light);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  min-width: 50px;
}

.room-type-header {
  text-align: left;
  padding: 0.5rem 0.75rem;
  min-width: 120px;
}

.date-header {
  vertical-align: middle;
}

.date-header .date-month {
  display: block;
  font-size: 0.5625rem;
  text-transform: uppercase;
}

.date-header .date-day {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.date-header .date-dow {
  display: block;
  font-size: 0.5625rem;
}

.date-header.weekend {
  background: rgba(217, 119, 6, 0.1);
}

.date-header.today {
  background: rgba(37, 99, 235, 0.15);
}

.date-header.today .date-day {
  color: var(--primary);
}

/* Room type cell */
.room-type-cell {
  padding: 0.5rem 0.75rem;
  vertical-align: middle;
  background: var(--bg-surface);
}

.room-type-name {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.room-type-meta {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  display: flex;
  gap: 0.5rem;
}

/* Availability cells */
.availability-cell {
  padding: 0.25rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  position: relative;
  min-width: 50px;
  vertical-align: top;
}

.availability-cell:hover {
  border-color: var(--primary);
  z-index: 5;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.availability-cell.today {
  background: rgba(37, 99, 235, 0.08) !important;
}

.availability-cell.weekend {
  background: rgba(217, 119, 6, 0.05);
}

/* Color coding based on availability percentage */
.availability-cell.avail-high {
  background: rgba(22, 163, 74, 0.2);
}

.availability-cell.avail-medium {
  background: rgba(217, 119, 6, 0.2);
}

.availability-cell.avail-low {
  background: rgba(220, 38, 38, 0.2);
}

/* Override indicators */
.availability-cell.has-override {
  border-left: 3px solid var(--primary);
}

.availability-cell.has-rate-override {
  border-right: 3px solid var(--warning);
}

/* Potential overbooking warning - set availability exceeds actual empty beds */
.availability-cell.potential-overbook {
  background: #1f2937 !important;
}

.availability-cell.potential-overbook .cell-beds {
  color: #fca5a5;
  font-weight: 800;
}

.availability-cell.potential-overbook .cell-empty-beds {
  color: #fca5a5;
  font-weight: 600;
  opacity: 1;
}

/* Cell content layout */
.cell-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.cell-beds {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  position: relative;
}

.override-dot {
  position: absolute;
  top: -2px;
  right: -6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.cell-min-stay {
  font-size: 0.625rem;
  color: var(--text-secondary);
}

.cell-rate {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  padding: 1px 4px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.05);
}

.cell-rate.rate-override {
  background: rgba(217, 119, 6, 0.2);
  color: var(--warning);
}

.cell-empty-beds {
  font-size: 0.5625rem;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Row alternating colors */
.availability-row.odd .room-type-cell {
  background-color: var(--bg-surface);
}

.availability-row.even .room-type-cell {
  background-color: var(--border-light);
}

/* ============================================================================
   Popover Styles
   ============================================================================ */

.availability-popover-container {
  position: fixed;
  z-index: 100;
}

.availability-popover {
  position: fixed;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  z-index: 100;
}

.popover-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--border-light);
  border-radius: 8px 8px 0 0;
}

.popover-title {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.popover-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.popover-close:hover {
  color: var(--text-primary);
}

/* Content wrapper with side nav buttons */
.popover-content-wrapper {
  display: flex;
  align-items: stretch;
}

/* Side navigation buttons - large touch-friendly */
.popover-nav-side {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  min-height: 100%;
  background: var(--border-light);
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.popover-nav-side:hover {
  background: var(--primary);
  color: white;
}

.popover-nav-side:active {
  background: var(--primary-dark, #1d4ed8);
}

.popover-nav-prev {
  border-radius: 0 0 0 8px;
  border-right: 1px solid var(--border-color);
}

.popover-nav-next {
  border-radius: 0 0 8px 0;
  border-left: 1px solid var(--border-color);
}

.nav-arrow {
  font-size: 1.5rem;
  font-weight: bold;
  line-height: 1;
}

.popover-body {
  padding: 1rem;
  min-width: 240px;
  max-width: 280px;
}

.popover-section {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.popover-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.popover-section h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.popover-field {
  margin-bottom: 0.75rem;
}

.popover-field:last-child {
  margin-bottom: 0;
}

.popover-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.popover-field .form-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.875rem;
  background: var(--bg-surface);
  color: var(--text-primary);
}

.popover-field .form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.popover-field.checkbox {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.popover-field .checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.popover-field .checkbox-label input[type="checkbox"] {
  width: auto;
}

.field-hint {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  font-style: italic;
}

.popover-actions {
  margin-top: 0.75rem;
}

.popover-info dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.popover-info dt {
  color: var(--text-secondary);
}

.popover-info dd {
  font-weight: 500;
  color: var(--text-primary);
  text-align: right;
}

/* ============================================================================
   Bulk Update Modal Additions
   ============================================================================ */

.date-range-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-range-inputs input[type="date"] {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.875rem;
  background: var(--bg-surface);
  color: var(--text-primary);
}

.date-range-separator {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.select-all-item {
  width: 100%;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 0.5rem;
}

/* ============================================================================
   Responsive Breakpoints
   ============================================================================ */

/* Mobile: Show 7 days */
@media (max-width: 640px) {
  .availability-grid th:nth-child(n + 9),
  .availability-grid td:nth-child(n + 9) {
    display: none;
  }

  .availability-cell {
    min-width: 42px;
    padding: 0.125rem;
  }

  .cell-beds {
    font-size: 0.875rem;
  }

  /* Show full info on mobile - room type name takes multiple lines anyway */
  .cell-rate {
    font-size: 0.625rem;
    padding: 1px 2px;
  }

  .cell-empty-beds {
    font-size: 0.5rem;
  }

  .room-type-name {
    font-size: 0.75rem;
  }

  .room-type-meta {
    display: none;
  }

  .availability-date-nav {
    flex-direction: column;
    gap: 0.75rem;
  }

  .date-nav-buttons {
    width: 100%;
    justify-content: space-between;
  }

  .date-nav-prev {
    margin-left: 0;
  }

  .availability-legend {
    gap: 0.5rem;
    font-size: 0.6875rem;
  }
}

/* Tablet: Show 14 days */
@media (min-width: 641px) and (max-width: 1024px) {
  .availability-grid th:nth-child(n + 16),
  .availability-grid td:nth-child(n + 16) {
    display: none;
  }
}

/* Desktop: Show all 31 days */
@media (min-width: 1025px) {
  .availability-grid th,
  .availability-grid td {
    display: table-cell;
  }
}

/* ============================================================================
   Dark Mode Adjustments
   ============================================================================ */

[data-theme="dark"] .availability-cell.avail-high {
  background: rgba(22, 163, 74, 0.3);
}

[data-theme="dark"] .availability-cell.avail-medium {
  background: rgba(217, 119, 6, 0.3);
}

[data-theme="dark"] .availability-cell.avail-low {
  background: rgba(220, 38, 38, 0.3);
}

[data-theme="dark"] .cell-rate {
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .date-header.weekend {
  background: rgba(217, 119, 6, 0.15);
}

[data-theme="dark"] .date-header.today {
  background: rgba(37, 99, 235, 0.25);
}

[data-theme="dark"] .availability-cell.potential-overbook {
  background: #fff !important;
}

[data-theme="dark"] .availability-cell.potential-overbook .cell-beds,
[data-theme="dark"] .availability-cell.potential-overbook .cell-empty-beds {
  color: var(--danger, #dc2626);
}

/* ============================================================================
   Bulk Edit Page Styles
   ============================================================================ */

.bulk-edit-container {
  max-width: 900px;
}

.bulk-edit-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.bulk-edit-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.bulk-edit-form .form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.bulk-edit-form .form-group {
  flex: 1;
  min-width: 150px;
}

.bulk-edit-form .form-group-btn {
  flex: 0 0 auto;
}

.bulk-edit-form .form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.bulk-edit-form .form-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.875rem;
  background: var(--bg-surface);
  color: var(--text-primary);
}

.bulk-edit-form .form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.bulk-edit-form .form-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
}

/* Bulk edit table */
.bulk-edit-table-wrapper {
  overflow-x: auto;
  margin-top: 0.5rem;
}

.bulk-edit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.bulk-edit-table th,
.bulk-edit-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.bulk-edit-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--border-light);
  text-transform: uppercase;
}

.bulk-edit-table tr.subheader th {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: none;
  background: var(--bg-surface);
}

.bulk-edit-table tbody tr:hover {
  background: rgba(37, 99, 235, 0.05);
}

.bulk-edit-table tbody tr.weekend {
  background: rgba(217, 119, 6, 0.05);
}

.bulk-edit-table tbody tr.weekend:hover {
  background: rgba(217, 119, 6, 0.1);
}

.bulk-edit-table .text-right {
  text-align: right;
}

.bulk-edit-table .text-center {
  text-align: center;
}

.bulk-edit-table .changed {
  background: rgba(22, 163, 74, 0.15);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  font-size: 0.625rem;
  font-weight: 600;
  border-radius: 3px;
  text-transform: uppercase;
}

.badge-warning {
  background: rgba(217, 119, 6, 0.2);
  color: var(--warning);
}

.badge-info {
  background: rgba(37, 99, 235, 0.2);
  color: var(--primary);
}

/* Results section */
.bulk-edit-results .alert {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.bulk-edit-results .alert-success {
  background: rgba(22, 163, 74, 0.15);
  color: #166534;
  border: 1px solid rgba(22, 163, 74, 0.3);
}

.results-table th[colspan] {
  text-align: center;
  border-left: 1px solid var(--border-color);
}

.results-table th[colspan]:first-child {
  border-left: none;
}

/* Responsive */
@media (max-width: 640px) {
  .bulk-edit-form .form-row {
    flex-direction: column;
  }

  .bulk-edit-form .form-group {
    width: 100%;
    min-width: auto;
  }
}
