/* ============================================================
   PRE-BOOKING CARDS - Complete UI Fix
   Fixes card layout, URGENT overlay, status badges, alignment
   ============================================================ */

/* ================================
   MISSING COLOR CLASSES
   Used by pre-booking cards
   ================================ */

/* --- Amber (for Pending) --- */
.bg-amber-100   { background-color: #fef3c7; }
.text-amber-700  { color: #b45309; }
.border-amber-200 { border-color: #fde68a; }

/* --- Blue (for Confirmed) - extend existing --- */
.text-blue-700   { color: #1d4ed8; }
.border-blue-200 { border-color: #bfdbfe; }

/* --- Green (for Completed) - extend existing --- */
.text-green-700  { color: #15803d; }
.border-green-200 { border-color: #bbf7d0; }

/* --- Red (for Cancelled + URGENT) --- */
.text-red-700    { color: #b91c1c; }
.text-red-400    { color: #f87171; }
.border-red-200  { border-color: #fecaca; }
.bg-red-50       { background-color: #fef2f2; }
.bg-blue-50      { background-color: #eff6ff; }

/* --- Opacity backgrounds for action hover --- */
.bg-blue-900\/20  { background-color: rgba(30, 58, 138, 0.2); }
.bg-red-900\/20   { background-color: rgba(127, 29, 29, 0.2); }
.bg-primary\/5    { background-color: rgba(136, 177, 201, 0.05); }
.bg-primary\/30   { background-color: rgba(136, 177, 201, 0.3); }
.text-primary\/30 { color: rgba(136, 177, 201, 0.3); }

/* --- Gray with slash opacity --- */
.bg-gray-700\/50  { background-color: rgba(55, 65, 81, 0.5); }

/* --- Bracket-based sizes --- */
.text-\[10px\]  { font-size: 10px; }
.text-\[11px\]  { font-size: 11px; }
.max-w-\[120px\] { max-width: 120px; }

/* --- Rounded corner variant --- */
.rounded-bl-lg { border-bottom-left-radius: 0.5rem; }

/* ================================
   BOOKING CARD - Core Styles
   ================================ */

.booking-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 1rem;
  border: 1px solid #e5e7eb;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s ease, transform 0.15s ease;
  position: relative;
  overflow: hidden !important;  /* CRITICAL: clip URGENT badge */
  min-height: 220px;
}

.booking-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.dark .booking-card {
  background: #1f2937;
  border-color: #374151;
}

/* ================================
   URGENT BADGE - Clean, non-destructive
   ================================ */

/* The URGENT badge is an absolutely positioned element inside the card.
   It should NOT have a huge area - just a small corner ribbon. */
.booking-card > .absolute.top-0.right-0 {
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  left: auto !important;           /* Override global icon centering */
  z-index: 5 !important;
  padding: 4px 12px !important;
  font-size: 10px !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  background: #ef4444 !important;
  color: #ffffff !important;
  border-bottom-left-radius: 0.5rem !important;
  border-radius: 0 0 0 0.5rem !important;
  line-height: 1.5 !important;
  min-height: auto !important;
  min-width: auto !important;
  width: auto !important;
  height: auto !important;
  pointer-events: auto !important; /* Override global icon centering */
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3) !important;
  animation: urgentPulse 2s ease-in-out infinite !important;
}

@keyframes urgentPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

/* ================================
   CARD HEADER - Customer + Status
   ================================ */

.booking-card > .flex.justify-between.items-start {
  display: flex !important;
  justify-content: space-between !important;
  align-items: flex-start !important;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

/* Customer avatar circle */
.booking-card .w-12.h-12 {
  width: 3rem !important;
  height: 3rem !important;
  min-width: 3rem !important;
  min-height: 3rem !important;
  border-radius: 0.75rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 1.25rem !important;
  font-weight: 700 !important;
  flex-shrink: 0 !important;
}

/* Customer name */
.booking-card h3 {
  font-size: 0.9375rem !important;
  font-weight: 700 !important;
  margin: 0 !important;
  line-height: 1.3 !important;
  color: #1f2937 !important;
}

.dark .booking-card h3 {
  color: #f3f4f6 !important;
}

/* Phone number */
.booking-card .text-xs.text-gray-500 {
  font-size: 0.75rem;
  color: #6b7280;
  line-height: 1.4;
}

/* ================================
   STATUS BADGES - Uniform design
   ================================ */

.booking-card .rounded-full[class*="font-bold"] {
  display: inline-flex !important;
  align-items: center !important;
  padding: 0.25rem 0.75rem !important;
  border-radius: 9999px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  line-height: 1.4 !important;
  border-width: 1px !important;
  border-style: solid !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  min-height: auto !important;
  height: auto !important;
  width: auto !important;
}

/* ================================
   CARD BODY - Details Section
   ================================ */

.booking-card > .space-y-3 {
  flex: 1;
  margin-bottom: 1rem !important;
}

/* Product & Delivery rows */
.booking-card > .space-y-3 > .flex.items-center.text-sm {
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.5;
  padding: 0 !important;
  min-height: auto !important;
}

.booking-card > .space-y-3 > .flex.items-center.text-sm i {
  width: 1.25rem !important;
  min-width: 1.25rem !important;
  text-align: center;
  color: #9ca3af !important;
  font-size: 0.875rem !important;
  flex-shrink: 0;
}

/* Balance Due card */
.booking-card .bg-gray-50 {
  background: #f9fafb !important;
  padding: 0.625rem 0.75rem !important;
  border-radius: 0.5rem !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  min-height: auto !important;
}

.dark .booking-card .bg-gray-50 {
  background: rgba(55, 65, 81, 0.5) !important;
}

.booking-card .bg-gray-50 .text-\[10px\] {
  font-size: 10px !important;
  text-transform: uppercase;
  font-weight: 700;
  color: #6b7280;
  letter-spacing: 0.05em;
}

.booking-card .bg-gray-50 .text-sm.font-bold {
  font-size: 0.9375rem !important;
  font-weight: 800 !important;
}

/* ================================
   CARD FOOTER - Action Buttons
   ================================ */

.booking-card > .flex.items-center.justify-between.pt-4 {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding-top: 0.75rem !important;
  border-top: 1px solid #f3f4f6 !important;
  margin-top: auto !important; /* Push to bottom for equal heights */
  gap: 0.5rem;
}

.dark .booking-card > .flex.items-center.justify-between.pt-4 {
  border-top-color: #374151 !important;
}

/* VIEW button */
.booking-card .view-booking-btn {
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  color: #6b7280 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.25rem !important;
  padding: 0.375rem 0.625rem !important;
  border-radius: 0.375rem !important;
  min-height: auto !important;
  width: auto !important;
  background: transparent !important;
  box-shadow: none !important;
  transition: color 0.15s ease !important;
}

.booking-card .view-booking-btn:hover {
  color: var(--color-primary) !important;
  background: rgba(136, 177, 201, 0.08) !important;
}

/* Edit + Delete buttons */
.booking-card .edit-booking-btn,
.booking-card .delete-booking-btn {
  padding: 0.375rem !important;
  border-radius: 0.5rem !important;
  min-height: auto !important;
  min-width: auto !important;
  width: auto !important;
  height: auto !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: transparent !important;
  box-shadow: none !important;
  transition: background-color 0.15s ease, color 0.15s ease !important;
  font-size: 0.875rem !important;
}

.booking-card .edit-booking-btn {
  color: #3b82f6 !important;
}

.booking-card .edit-booking-btn:hover {
  background: #eff6ff !important;
  color: #2563eb !important;
}

.booking-card .delete-booking-btn {
  color: #f87171 !important;
}

.booking-card .delete-booking-btn:hover {
  background: #fef2f2 !important;
  color: #dc2626 !important;
}

/* Footer action button group */
.booking-card .flex.space-x-2 {
  display: flex !important;
  gap: 0.25rem !important;
  flex-direction: row !important;
}

.booking-card .flex.space-x-2 button {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: auto !important;
}

/* ================================
   WHATSAPP BUTTON (small)
   ================================ */

.whatsapp-btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #25d366;
  color: white !important;
  font-size: 11px;
  text-decoration: none !important;
  flex-shrink: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 3px rgba(37, 211, 102, 0.3);
}

.whatsapp-btn-sm:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 6px rgba(37, 211, 102, 0.4);
  text-decoration: none !important;
}

/* ================================
   BOOKING GRID - Responsive Layout
   ================================ */

#bookings-list {
  display: grid !important;
  gap: 1.25rem;
}

/* Desktop: 3 columns */
@media (min-width: 1280px) {
  #bookings-list {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* Tablet: 2 columns */
@media (min-width: 768px) and (max-width: 1279px) {
  #bookings-list {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Mobile: 1 column */
@media (max-width: 767px) {
  #bookings-list {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }
  
  .booking-card {
    padding: 1rem !important;
    border-radius: 1rem !important;
    min-height: auto !important;
  }

  .booking-card h3 {
    font-size: 0.875rem !important;
    max-width: 140px !important;
  }

  .booking-card .w-12.h-12 {
    width: 2.5rem !important;
    height: 2.5rem !important;
    min-width: 2.5rem !important;
    min-height: 2.5rem !important;
    font-size: 1rem !important;
  }
}

/* ================================
   FIX: Prevent mobile-perfection.css from
   breaking overflow-hidden on booking cards
   ================================ */

@media (max-width: 640px) {
  .booking-card.overflow-hidden,
  .booking-card[class*="overflow-hidden"] {
    overflow: hidden !important;
  }

  /* Prevent booking buttons from stretching full width */
  .booking-card button,
  .booking-card .btn,
  .booking-card a.btn {
    width: auto !important;
    min-height: auto !important;
  }

  /* Prevent booking card content from changing to column */
  .booking-card > .flex.justify-between,
  .booking-card .flex.space-x-2,
  .booking-card .flex.items-center.space-x-3,
  .booking-card .flex.items-center.space-x-2 {
    flex-direction: row !important;
    width: auto !important;
  }

  .booking-card .flex.justify-between > *,
  .booking-card .flex.items-center.space-x-3 > * {
    width: auto !important;
  }
  
  /* Prevent the URGENT badge from being forced visible outside bounds */
  .booking-card > div.absolute {
    overflow: visible !important;
  }
}

/* ================================
   EMPTY STATE
   ================================ */

#bookings-list .col-span-full {
  grid-column: 1 / -1;
}

/* ================================
   DARK MODE ENHANCEMENTS
   ================================ */

.dark .booking-card .bg-gray-50.dark\:bg-gray-700\/50 {
  background: rgba(55, 65, 81, 0.5) !important;
}

.dark .booking-card .text-gray-700 {
  color: #d1d5db;
}

.dark .booking-card .text-gray-600 {
  color: #9ca3af;
}

.dark .booking-card .text-gray-800 {
  color: #f3f4f6;
}

/* ============================================================
   DASHBOARD - Delivery Cards (HIGH SPECIFICITY OVERRIDES)
   Double-class selectors guarantee these beat mobile-perfection.css
   ============================================================ */

.delivery-card.delivery-card {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 1rem !important;
  padding: 1rem 1.25rem !important;
  border-radius: 0.75rem !important;
  border: 1px solid #e5e7eb !important;
  background: #ffffff !important;
  transition: box-shadow 0.2s ease, transform 0.15s ease !important;
  width: 100% !important;
  box-sizing: border-box !important;
  position: relative !important;
  overflow: visible !important;
  margin-bottom: 0.75rem !important;
}

.delivery-card.delivery-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
  transform: translateY(-1px) !important;
}

.dark .delivery-card.delivery-card {
  background: #1f2937 !important;
  border-color: #374151 !important;
}

.delivery-card.delivery-card-urgent {
  border-left: 4px solid #ef4444 !important;
  background: #fffcfc !important;
}

.dark .delivery-card.delivery-card-urgent {
  background: #271c1c !important;
}

/* AVATAR & URGENT LABEL */
.delivery-card .delivery-card-avatar {
  flex: 0 0 auto !important;
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.delivery-card-avatar .w-11.h-11 {
  width: 3rem !important;
  height: 3rem !important;
  min-width: 3rem !important;
  min-height: 3rem !important;
  border-radius: 0.75rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 1.25rem !important;
  font-weight: 700 !important;
  background: #eff6ff !important;
  color: #3b82f6 !important;
  padding: 0 !important;
}

.dark .delivery-card-avatar .w-11.h-11 {
  background: rgba(59, 130, 246, 0.2) !important;
  color: #60a5fa !important;
}

.delivery-urgent-label {
  position: absolute !important;
  top: -8px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  background: #ef4444 !important;
  color: #ffffff !important;
  font-size: 9px !important;
  font-weight: 800 !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  z-index: 10 !important;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3) !important;
  animation: none !important;
  white-space: nowrap !important;
}

/* DETAILS SECTION */
.delivery-card .delivery-card-details {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.375rem !important;
  justify-content: center !important;
}

/* HEADER: NAME & BADGE */
.delivery-card .delivery-card-header {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 0.625rem !important;
  margin: 0 !important;
  width: auto !important;
  flex-wrap: wrap !important;
}

.delivery-customer-name {
  font-weight: 700 !important;
  font-size: 1.0625rem !important;
  color: #111827 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100% !important;
}

.dark .delivery-customer-name { 
  color: #f3f4f6 !important; 
}

span.delivery-status-badge.delivery-status-badge {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0.125rem 0.5rem !important;
  border-radius: 9999px !important;
  font-size: 0.6875rem !important;
  font-weight: 700 !important;
  line-height: 1.5 !important;
  white-space: nowrap !important;
  letter-spacing: 0.025em !important;
  text-transform: uppercase !important;
  box-shadow: none !important;
}

/* PRODUCT ROW */
.delivery-product-name {
  font-weight: 500 !important;
  font-size: 0.875rem !important;
  color: #4b5563 !important;
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.375rem !important;
}

.dark .delivery-product-name {
  color: #9ca3af !important;
}

.delivery-product-name i {
  color: #9ca3af !important;
  font-size: 0.75rem !important;
}

/* INFO ROW (TIME, ADVANCE, DUE) */
.delivery-card .delivery-info-row {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 0.5rem 1rem !important;
  width: 100% !important;
  margin-top: 0.125rem !important;
}

span.delivery-info-item.delivery-info-item {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.375rem !important;
  white-space: nowrap !important;
  font-size: 0.8125rem !important;
  font-weight: 500 !important;
  color: #6b7280 !important;
  padding: 0 !important;
  background: transparent !important;
}

.dark span.delivery-info-item.delivery-info-item {
  color: #9ca3af !important;
}

.delivery-info-item i { 
  color: #9ca3af !important; 
  font-size: 0.75rem !important; 
}

.delivery-info-item strong { 
  font-weight: 700 !important; 
  font-size: 0.875rem !important;
}

/* COLOR UTILITIES FOR AMOUNTS */
.text-green-600 { color: #16a34a !important; }
.text-red-500 { color: #ef4444 !important; }
.dark .text-green-600 { color: #4ade80 !important; }
.dark .text-red-500 { color: #f87171 !important; }

/* WHATSAPP ACTION BUTTON */
.delivery-card .delivery-card-action {
  flex: 0 0 auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  margin-left: 0.5rem !important;
}

a.dashboard-wa-btn.dashboard-wa-btn {
  width: 2.75rem !important;
  height: 2.75rem !important;
  min-width: 2.75rem !important;
  min-height: 2.75rem !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #25d366 !important;
  color: #ffffff !important;
  font-size: 1.375rem !important;
  text-decoration: none !important;
  box-shadow: 0 2px 5px rgba(37, 211, 102, 0.4) !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease !important;
}

a.dashboard-wa-btn.dashboard-wa-btn:hover {
  background: #1ebc59 !important;
  transform: scale(1.08) !important;
  box-shadow: 0 4px 8px rgba(37, 211, 102, 0.5) !important;
}

/* TABS FIX (Unrelated to cards, but was here before) */
button.delivery-tab-btn.delivery-tab-btn {
  min-height: auto !important;
  height: auto !important;
  padding: 0.875rem 1.25rem !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 0.875rem !important;
  font-weight: 700 !important;
  width: auto !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.375rem !important;
}

.settle-order-btn {
  width: 2.75rem !important;
  height: 2.75rem !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #4361ee !important;
  color: #ffffff !important;
  font-size: 1.125rem !important;
  border: none !important;
  cursor: pointer !important;
  box-shadow: 0 2px 5px rgba(67, 97, 238, 0.3) !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease !important;
}

.settle-order-btn:hover {
  background: #3751d4 !important;
  transform: scale(1.08) !important;
  box-shadow: 0 4px 8px rgba(67, 97, 238, 0.4) !important;
}

.delivery-card-action {
  display: flex !important;
  flex-direction: row !important;
  gap: 0.75rem !important;
  align-items: center !important;
}

/* MOBILE RESPONSIVE TWEAKS */
@media (max-width: 640px) {
  .delivery-card.delivery-card {
    padding: 0.875rem 1rem !important;
    gap: 0.75rem !important;
  }
  .delivery-card-avatar .w-11.h-11 {
    width: 2.5rem !important; 
    height: 2.5rem !important;
    min-width: 2.5rem !important; 
    min-height: 2.5rem !important;
    font-size: 1rem !important;
  }
  .delivery-customer-name { 
    font-size: 0.9375rem !important; 
  }
  .delivery-product-name { 
    font-size: 0.8125rem !important; 
  }
  span.delivery-info-item.delivery-info-item { 
    font-size: 0.75rem !important; 
  }
  .delivery-info-item strong {
    font-size: 0.8125rem !important;
  }
  .delivery-card .delivery-info-row { 
    gap: 0.375rem 0.75rem !important; 
  }
  a.dashboard-wa-btn.dashboard-wa-btn {
    width: 2.25rem !important; 
    height: 2.25rem !important;
    min-width: 2.25rem !important; 
    min-height: 2.25rem !important;
    font-size: 1.125rem !important;
  }
}

/* ============================================================
   DASHBOARD SECTION HEADER & ICON FIX
   Ensures the header icon is perfectly aligned and never overlaps
   ============================================================ */

.dashboard-section-header {
  position: relative !important;
  z-index: 10 !important;
}

.dashboard-header-icon-container {
  width: 42px !important;
  height: 42px !important;
  min-width: 42px !important;
  min-height: 42px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 12px !important;
  background-color: rgba(76, 201, 240, 0.12) !important; /* info-light with transparency */
  color: #4cc9f0 !important; /* info color */
  position: static !important;
  margin: 0 !important;
  transform: none !important;
  flex-shrink: 0 !important;
  box-shadow: inset 0 0 0 1px rgba(76, 201, 240, 0.1) !important;
}

.dark .dashboard-header-icon-container {
  background-color: rgba(76, 201, 240, 0.2) !important;
  box-shadow: inset 0 0 0 1px rgba(76, 201, 240, 0.2) !important;
}

.dashboard-header-icon-container i {
  font-size: 1.25rem !important;
  position: static !important;
  display: block !important;
  margin: 0 !important;
  transform: none !important;
  line-height: 1 !important;
}

/* Ensure gap utility works on desktop */
.dashboard-section-header .gap-4 {
  gap: 1rem !important;
}

/* Tab refinements for premium feel */
.delivery-tab-btn {
  letter-spacing: 0.02em !important;
  opacity: 0.7;
}

.delivery-tab-btn.active {
  opacity: 1;
}

.delivery-tab-btn i {
  font-size: 0.9rem !important;
}

/* Mobile refinements */
@media (max-width: 640px) {
  .dashboard-header-icon-container {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-radius: 10px !important;
  }
  
  .dashboard-header-icon-container i {
    font-size: 1rem !important;
  }
  
  .dashboard-section-header .gap-4 {
    gap: 0.75rem !important;
  }
}
