:root {
  --primary: #f97316;
  --primary-dark: #ea580c;
  --secondary: #0f172a;
  --success: #16a34a;
  --danger: #dc2626;
  --bg: #ffffff;
  --surface: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #e5e7eb;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, sans-serif;
}

.booking-history-page {
  padding: 24px 16px;
  min-height: 100vh;
  margin-top: 0;
}

.booking-history-page .container {
  max-width: 900px;
  margin: 0 auto;
}

.booking-history-header {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.back-button-wrapper {
  margin-bottom: 12px;
}

.btn-back-to-account {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.btn-back-to-account:hover {
  color: var(--primary);
  background: var(--surface);
}

.booking-history-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.booking-history-header h1 i {
  color: var(--primary);
}

.booking-history-header p {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

.booking-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: var(--surface);
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.booking-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.booking-tab i {
  font-size: 16px;
}

.booking-tab:hover {
  background: rgba(249, 115, 22, 0.1);
  color: var(--primary);
}

.booking-tab.active {
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.bookings-container {
  display: grid;
  gap: 16px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
  color: var(--muted);
  text-align: center;
  padding: 40px 24px;
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}

.booking-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s ease;
}

.booking-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: #cbd5e1;
}

.booking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.booking-id {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.booking-status {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: uppercase;
}

.booking-status.confirmed {
  background: #d1fae5;
  color: #059669;
}

.booking-status.cancelled {
  background: #fee2e2;
  color: #dc2626;
}

.booking-status.cancellation-pending {
  background: #fef3c7;
  color: #d97706;
}

.booking-status.cancellation-rejected {
  background: #fee2e2;
  color: #dc2626;
}

.booking-status.completed {
  background: #dbeafe;
  color: #2563eb;
}

.booking-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.booking-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.booking-date,
.booking-time,
.booking-mechanic {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

.booking-date i,
.booking-time i,
.booking-mechanic i {
  color: var(--muted);
  width: 16px;
}

.booking-services {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.booking-services h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 8px 0;
  text-transform: uppercase;
}

.services-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.service-tag {
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
}

.booking-products {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.booking-products h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 8px 0;
  text-transform: uppercase;
}

.products-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.product-tag {
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
}

.booking-notes {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
}

.booking-notes strong {
  color: var(--text);
}

.booking-notes .booking-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.cancellation-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fef3c7;
  border-radius: 8px;
  font-size: 13px;
  color: #d97706;
  font-weight: 600;
}

.cancellation-timer.expired {
  background: #fee2e2;
  color: #dc2626;
}

.cancellation-timer i {
  font-size: 14px;
}

.timer-text {
  font-size: 13px;
}

.timer-text.expired {
  font-weight: 700;
}

.btn-cancel-booking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cancel-booking:hover {
  background: #fecaca;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
}

.booking-cancel-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(3px);
}

.booking-cancel-content {
  width: min(480px, 100%);
  max-height: min(90vh, 680px);
  overflow-y: auto;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .24);
}

.booking-cancel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}

.booking-cancel-header h2 {
  margin: 0;
  font-size: 18px;
}

.booking-cancel-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
}

.booking-cancel-close:hover { background: rgba(255, 255, 255, .18); }

.booking-cancel-body { padding: 22px; }
.booking-cancel-prompt { margin: 0 0 12px; font-weight: 600; color: #374151; }
.booking-reason-options { display: flex; flex-direction: column; gap: 9px; }

.booking-reason-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.booking-reason-option:hover,
.booking-reason-option:has(input:checked) { background: #fff7ed; border-color: #f97316; }
.booking-reason-option input { width: 17px; height: 17px; accent-color: #f97316; }
.booking-reason-option span { color: #374151; font-size: 14px; }
.booking-custom-reason { margin-top: 16px; }
.booking-custom-reason[hidden] { display: none; }
.booking-custom-reason label { display: block; margin-bottom: 7px; font-weight: 600; color: #374151; }
.booking-custom-reason textarea { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; resize: vertical; }
.booking-custom-reason textarea:focus { outline: 2px solid rgba(249, 115, 22, .2); border-color: #f97316; }

.booking-cancel-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid #e5e7eb;
}

.booking-cancel-footer button { min-height: 40px; padding: 9px 14px; border: 0; border-radius: 7px; font-weight: 700; cursor: pointer; }
.booking-cancel-secondary { background: #f3f4f6; color: #374151; }
.booking-cancel-submit { background: #ef4444; color: #fff; }
.booking-cancel-submit:hover { background: #dc2626; }
.refund-form-field { display: block; margin: 12px 0 6px; color: #374151; font-size: 13px; font-weight: 700; }
#serviceRefundForm select,
#serviceRefundForm input { display: block; width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: #111827; font: inherit; }
#serviceRefundForm select:focus,
#serviceRefundForm input:focus { outline: 2px solid rgba(249, 115, 22, .2); border-color: #f97316; }
.booking-cancel-submit:disabled { cursor: wait; opacity: .65; }

.booking-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.booking-actions .booking-btn {
  flex: 1;
}

.booking-time-remaining {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 12px;
  background: #fef3c7;
  border-radius: 8px;
  font-size: 12px;
  color: #d97706;
  font-weight: 500;
}

.booking-time-remaining i {
  font-size: 14px;
}

.booking-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.booking-btn.cancel {
  background: #fee2e2;
  color: #dc2626;
  padding: 6px 12px;
  font-size: 12px;
  flex: 0 0 auto;
  width: 200px;
}

.booking-btn.cancel:hover {
  background: #fecaca;
}

.booking-btn.confirm {
  background: #d1fae5;
  color: #059669;
}

.booking-btn.confirm:hover {
  background: #a7f3d0;
}

/* Booking Badges */
.booking-badges {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.booking-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.booking-badge.cancellation-approved {
  background: linear-gradient(135deg, rgba(34,197,94,0.15), rgba(22,163,74,0.15));
  color: #16a34a;
  border: 1px solid rgba(34,197,94,0.3);
}

.booking-badge.ongoing-refund {
  background: linear-gradient(135deg, rgba(251,191,36,0.15), rgba(245,158,11,0.15));
  color: #d97706;
  border: 1px solid rgba(251,191,36,0.3);
}

.booking-badge.cancellation-pending {
  background: linear-gradient(135deg, rgba(251,191,36,0.15), rgba(245,158,11,0.15));
  color: #d97706;
  border: 1px solid rgba(251,191,36,0.3);
}

.booking-badge.cancellation-rejected {
  background: linear-gradient(135deg, rgba(254,226,226,0.15), rgba(220,38,38,0.15));
  color: #dc2626;
  border: 1px solid rgba(254,226,226,0.3);
}

.booking-badge.refunded {
  background: linear-gradient(135deg, rgba(34,197,94,0.2), rgba(16,185,129,0.2));
  color: #059669;
  border: 1px solid rgba(34,197,94,0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
  .booking-history-page {
    padding: 16px 12px;
  }
  
  .booking-history-page .container {
    max-width: 100%;
  }
  
  .booking-history-header h1 {
    font-size: 22px;
  }
  
  .booking-history-header p {
    font-size: 13px;
  }
  
  .booking-card {
    border-radius: 10px;
  }
  
  .booking-header {
    padding: 12px;
    gap: 12px 8px;
  }
  
  .booking-number {
    font-size: 14px;
  }
  
  .booking-date {
    font-size: 11px;
  }
  
  .booking-status-badge {
    font-size: 11px;
    padding: 3px 10px;
  }
  
  .booking-details {
    padding: 10px 12px;
  }
  
  .booking-detail-row {
    gap: 10px;
  }
  
  .booking-detail-label {
    font-size: 12px;
  }
  
  .booking-detail-value {
    font-size: 13px;
  }
  
  .booking-footer {
    padding: 12px;
  }
  
  .booking-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .booking-btn {
    width: 100%;
    justify-content: center;
  }
  
  .booking-btn.cancel {
    width: 100%;
    flex: 1;
  }
}

@media (max-width: 480px) {
  .booking-history-page {
    padding: 12px 8px;
  }
  
  .booking-history-header h1 {
    font-size: 18px;
  }
  
  .booking-history-header p {
    font-size: 12px;
  }
  
  .btn-back-to-account {
    position: static;
    margin-bottom: 8px;
  }
  
  .booking-header {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 8px;
  }
  
  .booking-number {
    grid-column: 1;
    grid-row: 1;
  }
  
  .booking-date {
    grid-column: 1;
    grid-row: 2;
  }
  
  .booking-status-badge {
    grid-column: 1;
    grid-row: 3;
    align-self: flex-start;
  }
  
  .booking-detail-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .booking-detail-value {
    align-self: flex-start;
  }
  
  .booking-footer {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  
  .booking-actions {
    flex-direction: column;
  }
  
  .modal-content {
    max-width: calc(100% - 32px);
  }
}

@media (max-width: 360px) {
  .booking-history-page {
    padding: 10px 6px;
  }
  
  .booking-history-header h1 {
    font-size: 16px;
  }
  
  .booking-history-header p {
    font-size: 11px;
  }
  
  .booking-card {
    border-radius: 8px;
  }
  
  .booking-header {
    padding: 10px;
  }
  
  .booking-details {
    padding: 8px 10px;
  }
  
  .booking-footer {
    padding: 10px;
  }
  
  .modal-header {
    padding: 16px 20px;
  }
  
  .modal-header h2 {
    font-size: 16px;
  }
  
  .modal-body {
    padding: 16px 20px;
  }
  
  .modal-footer {
    padding: 12px 20px;
  }
}
