/* Sub-Hire Deliveries - Scoped under #subhire */

#subhire {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#subhire .sh-wrapper {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: 40px;
}

/* Stats Bar */
#subhire .sh-stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

#subhire .sh-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  flex: 1;
  min-width: 120px;
}

#subhire .sh-stat:hover {
  border-color: #1a5490;
  background: #f0f5ff;
}

#subhire .sh-stat.active {
  border-color: #1a5490;
  background: #e8f0fe;
}

#subhire .sh-stat-count {
  font-size: 24px;
  font-weight: 700;
  color: #0c3368;
  line-height: 1;
}

#subhire .sh-stat-label {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#subhire .sh-stat--expected .sh-stat-count { color: #e67e22; }
#subhire .sh-stat--delivered .sh-stat-count { color: #2196F3; }
#subhire .sh-stat--checked .sh-stat-count { color: #9c27b0; }
#subhire .sh-stat--complete .sh-stat-count { color: #28a745; }
#subhire .sh-stat--courier .sh-stat-count { color: #dc3545; }

/* Toolbar */
#subhire .sh-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

#subhire .sh-filters select {
  padding: 8px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  cursor: pointer;
}

/* Columns layout */
#subhire .sh-columns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  align-items: start;
}

#subhire .sh-column {
  min-width: 0;
}

#subhire .sh-column-header {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  padding: 10px 14px;
  border-radius: 8px 8px 0 0;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#subhire .sh-column--postal { background: #e8eaf6; color: #3949ab; }
#subhire .sh-column--subhire { background: #fff8e1; color: #f57f17; }
#subhire .sh-column--collection { background: #ede7f6; color: #6a1b9a; }

#subhire .sh-column-count {
  background: rgba(0,0,0,0.1);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

/* Cards */
#subhire .sh-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#subhire .sh-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.15s, border-color 0.15s;
  cursor: pointer;
}

#subhire .sh-card:hover {
  border-color: #1a5490;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

#subhire .sh-card-main {
  flex: 1;
  min-width: 0;
}

#subhire .sh-card-supplier {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 4px;
}

#subhire .sh-card-items {
  font-size: 13px;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

#subhire .sh-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#subhire .sh-card-date {
  font-size: 12px;
  color: #888;
}

#subhire .sh-card-date.sh-overdue {
  color: #dc3545;
  font-weight: 600;
}

#subhire .sh-card-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Status badges */
#subhire .sh-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

#subhire .sh-badge--expected {
  background: #fff3e0;
  color: #e67e22;
}

#subhire .sh-badge--delivered {
  background: #e3f2fd;
  color: #1976d2;
}

#subhire .sh-badge--checked {
  background: #f3e5f5;
  color: #7b1fa2;
}

#subhire .sh-badge--complete,
#subhire .sh-badge--returned {
  background: #e8f5e9;
  color: #2e7d32;
}

#subhire .sh-badge--booked {
  background: #fff3e0;
  color: #e67e22;
}

#subhire .sh-badge--return_check {
  background: #fff8e1;
  color: #f57f17;
}

#subhire .sh-badge--ready_for_return {
  background: #e0f2f1;
  color: #00695c;
}

#subhire .sh-badge--courier {
  background: #fce4ec;
  color: #c62828;
}

#subhire .sh-badge--collection {
  background: #ede7f6;
  color: #6a1b9a;
}

#subhire .sh-card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

#subhire .sh-card-actions .btn {
  white-space: nowrap;
  font-size: 12px;
}

#subhire .sh-card-file-counts {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: #999;
}

#subhire .sh-column-empty {
  text-align: center;
  padding: 20px;
  color: #bbb;
  font-size: 13px;
  font-style: italic;
}

/* Empty state */
#subhire .sh-empty {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

#subhire .sh-empty p {
  font-size: 16px;
}

/* Detail View */
#subhire .sh-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

#subhire .sh-detail-header h2 {
  flex: 1;
  margin: 0;
  font-size: 22px;
  color: #1a1a1a;
}

#subhire .sh-detail-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

#subhire .sh-detail-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 20px;
}

#subhire .sh-detail-card h3 {
  margin: 0 0 16px 0;
  font-size: 15px;
  color: #333;
  font-weight: 600;
}

#subhire .sh-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

#subhire .sh-card-header h3 {
  margin: 0;
}

/* Info grid */
#subhire .sh-info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: 14px;
}

#subhire .sh-info-label {
  color: #888;
  font-weight: 500;
}

#subhire .sh-info-value {
  color: #333;
  word-break: break-word;
}

#subhire .sh-info-value.sh-items-text {
  white-space: pre-line;
}

/* Status actions */
#subhire .sh-status-actions {
  margin-top: 20px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#subhire .sh-status-actions .btn {
  flex: 1;
  min-width: 140px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
}

#subhire .btn-deliver {
  background: #28a745;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

#subhire .btn-deliver:hover { background: #218838; }

#subhire .btn-check {
  background: #2196F3;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

#subhire .btn-check:hover { background: #1976d2; }

#subhire .btn-complete {
  background: #6c757d;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

#subhire .btn-complete:hover { background: #5a6268; }

#subhire .btn-reopen {
  background: #ffc107;
  color: #333;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

#subhire .btn-reopen:hover { background: #e0a800; }

/* Courier info */
#subhire .sh-courier-info {
  font-size: 14px;
}

#subhire .sh-courier-info .sh-info-grid {
  margin-bottom: 0;
}

#subhire .sh-courier-none {
  color: #999;
  font-style: italic;
}

/* File list */
#subhire .sh-file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#subhire .sh-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 6px;
  font-size: 13px;
}

#subhire .sh-file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #333;
}

#subhire .sh-file-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

#subhire .sh-file-actions a,
#subhire .sh-file-actions button {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
}

#subhire .sh-file-actions a {
  background: #e3f2fd;
  color: #1976d2;
}

#subhire .sh-file-actions a:hover {
  background: #bbdefb;
}

#subhire .sh-file-btn-delete {
  background: #fce4ec;
  color: #c62828;
  border: none;
}

#subhire .sh-file-btn-delete:hover {
  background: #f8bbd0;
}

#subhire .sh-file-empty {
  color: #999;
  font-size: 13px;
  font-style: italic;
  padding: 8px 0;
}

/* Photo gallery */
#subhire .sh-photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

#subhire .sh-photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #f0f0f0;
}

#subhire .sh-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.15s;
}

#subhire .sh-photo-thumb:hover img {
  transform: scale(1.05);
}

#subhire .sh-photo-thumb .sh-photo-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(220, 53, 69, 0.85);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

#subhire .sh-photo-thumb:hover .sh-photo-delete {
  display: flex;
}

/* Upload button styling */
#subhire .sh-upload-btn {
  cursor: pointer;
}

/* Lightbox */
#subhire ~ .sh-lightbox,
.sh-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sh-lightbox img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 4px;
}

.sh-lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
  line-height: 1;
}

/* Modal overrides */
#sh-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sh-modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  #sh-modal-overlay {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
  }
  .sh-modal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .sh-modal .modal-header {
    padding: 14px 16px;
    flex-shrink: 0;
  }
  .sh-modal .modal-body {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .sh-modal .modal-footer {
    padding: 12px 16px;
    flex-shrink: 0;
    border-top: 1px solid #e0e0e0;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .sh-modal input[type="text"],
  .sh-modal input[type="date"],
  .sh-modal input[type="time"],
  .sh-modal textarea,
  .sh-modal select {
    min-height: 44px;
    font-size: 16px;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 6px;
    border: 1px solid #d0d0d0;
    padding: 8px 10px;
  }
  .sh-modal .form-group {
    margin-bottom: 14px;
  }
  .sh-modal .form-group label {
    font-size: 0.875rem;
    margin-bottom: 4px;
    display: block;
  }
  .sh-modal .sh-form-divider {
    margin: 12px 0;
  }
  .sh-modal .sh-form-section-title {
    font-size: 15px;
  }
  .sh-type-toggle {
    margin-bottom: 4px;
  }
  .sh-type-btn {
    padding: 10px 16px;
    font-size: 14px;
  }
  .sh-time-row {
    flex-direction: column;
    gap: 0;
  }
}

.sh-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
}

.sh-modal .modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.sh-modal .modal-body {
  padding: 20px;
}

.sh-modal .modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.sh-modal .modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  line-height: 1;
}

.sh-modal textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}

/* Time slot row */
.sh-time-row {
  display: flex;
  gap: 12px;
}

.sh-time-row .form-group {
  flex: 1;
}

.sh-modal input[type="time"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

.sh-modal input[type="text"],
.sh-modal input[type="date"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

/* Type toggle */
.sh-type-toggle {
  display: flex;
  gap: 0;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  overflow: hidden;
}

.sh-type-btn {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: #f8f9fa;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: #555;
}

.sh-type-btn + .sh-type-btn {
  border-left: 1px solid #d0d0d0;
}

.sh-type-btn.active {
  background: #0c3368;
  color: #fff;
}

.sh-type-btn:hover:not(.active) {
  background: #e8f0fe;
}

/* Type badges */
#subhire .sh-badge--postal {
  background: #e8eaf6;
  color: #3949ab;
}

#subhire .sh-badge--subhire {
  background: #fff8e1;
  color: #f57f17;
}

/* Form section titles */
.sh-form-section-title {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

#subhire .sh-form-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 16px 0;
}

/* Return date highlight */
#subhire .sh-return-date-warning {
  color: #e67e22;
  font-weight: 600;
}

#subhire .sh-return-date-overdue {
  color: #dc3545;
  font-weight: 600;
}

/* Delete confirmation in card */
#subhire .sh-delete-btn {
  background: none;
  border: none;
  color: #dc3545;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
}

#subhire .sh-delete-btn:hover {
  text-decoration: underline;
}

/* Photo prompt modal */
.sh-photo-prompt-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.sh-photo-prompt {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.sh-photo-prompt h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  color: #333;
}

.sh-photo-prompt p {
  margin: 0 0 20px 0;
  font-size: 14px;
  color: #666;
}

.sh-photo-prompt-btn {
  width: 100%;
  cursor: pointer;
  min-height: 48px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Responsive */
@media (max-width: 768px) {
  #subhire .sh-wrapper { padding: 12px; }

  /* Stats - 2 column grid */
  #subhire .sh-stats-bar { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
  #subhire .sh-stat { padding: 10px 12px; min-width: unset; flex: unset; }
  #subhire .sh-stat-count { font-size: 20px; }
  #subhire .sh-stat-label { font-size: 11px; }

  /* Cards */
  #subhire .sh-card { flex-direction: column; align-items: stretch; padding: 14px; }
  #subhire .sh-card-supplier { font-size: 15px; }
  #subhire .sh-card-items { white-space: normal; }
  #subhire .sh-card-actions { flex-direction: column; margin-top: 10px; gap: 6px; }
  #subhire .sh-card-actions .btn { text-align: center; min-height: 44px; }

  /* Detail view */
  #subhire .sh-detail-body { grid-template-columns: 1fr; }
  #subhire .sh-detail-header { flex-wrap: wrap; gap: 8px; }
  #subhire .sh-detail-header h2 { font-size: 18px; width: 100%; order: -1; }
  #subhire .sh-detail-header .btn { flex: 1; }
  #subhire .sh-detail-card { padding: 14px; }
  #subhire .sh-detail-card h3 { font-size: 14px; }
  #subhire .sh-info-grid { font-size: 13px; gap: 6px 12px; }

  /* Status buttons - big and tappable */
  #subhire .sh-status-actions { flex-direction: column; }
  #subhire .sh-status-actions .btn { min-width: unset; min-height: 48px; font-size: 15px; }

  /* Files */
  #subhire .sh-file-item { padding: 10px 12px; }
  #subhire .sh-file-actions a, #subhire .sh-file-actions button { padding: 6px 10px; font-size: 12px; min-height: 36px; }

  /* Photos - always show delete on touch */
  #subhire .sh-photo-gallery { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  #subhire .sh-photo-thumb .sh-photo-delete { display: flex !important; width: 28px; height: 28px; font-size: 16px; }

  /* Toolbar */
  #subhire .sh-toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  #subhire .sh-toolbar .btn { width: 100%; }
  #subhire .sh-filters { display: flex; gap: 8px; width: 100%; }
  #subhire .sh-filters select { flex: 1; min-height: 44px; font-size: 0.9375rem; }
  #subhire .sh-upload-btn { min-height: 44px; display: inline-flex; align-items: center; }

  /* Stack columns on mobile */
  #subhire .sh-columns {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}
