/* =============================================================================
   WPCafe Table Layout — Frontend Selector CSS
   Warm restaurant theme, smooth animations, fully responsive
   ============================================================================= */

/* ── Import font ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── CSS variables ───────────────────────────────────────────────────────── */
.wtl-selector {
  --bg          : #faf6f1;
  --bg-card     : #ffffff;
  --border      : #e8dfd4;
  --border-dark : #c9b89e;
  --text-hi     : #2d1f0f;
  --text-md     : #6b5240;
  --text-lo     : #a08060;
  --available   : #16a34a;
  --avail-bg    : #dcfce7;
  --avail-border: #86efac;
  --booked      : #dc2626;
  --booked-bg   : #fee2e2;
  --booked-bord : #fca5a5;
  --selected    : #b45309;
  --sel-bg      : #fef3c7;
  --sel-border  : #fcd34d;
  --accent      : #b45309;
  --shadow-sm   : 0 1px 4px rgba(45,31,15,.08);
  --shadow-md   : 0 4px 24px rgba(45,31,15,.12);
  --shadow-lg   : 0 12px 48px rgba(45,31,15,.16);
  --radius      : 16px;
  --font        : 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Outer wrapper ───────────────────────────────────────────────────────── */
.wtl-selector {
  font-family: var(--font);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  margin-bottom: 28px;
  position: relative;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.wtl-sel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 18px;
  background: linear-gradient(135deg, #fff7ed, #fef3c7 80%);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
  z-index: 10;
  position: relative;
}
.wtl-sel-header__left { display: flex; align-items: center; gap: 14px; }
.wtl-sel-icon {
  width: 46px; height: 46px;
  background: linear-gradient(135deg, #b45309, #d97706);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(180,83,9,.3);
  flex-shrink: 0;
}

.wtl-sel-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-hi);
  margin: 0;
  line-height: 1.2;
}
.wtl-sel-sub {
  font-size: 13px;
  color: var(--text-md);
  margin: 2px 0 0;
}

/* ── Legend & Filters ────────────────────────────────────────────────────── */
.wtl-sel-datetime-slot {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 250px;
}

/* Base form display becomes a flex/grid container to receive the elements */
.wtl-form-in-header {
  display: flex !important;
  flex-direction: row;
  flex-wrap: nowrap; /* Forces one single line */
  gap: 12px 20px;
  align-items: center;
  background: var(--bg-card);
  padding: 16px 24px;
  border-radius: 12px;
  border: 1px solid rgba(180, 83, 9, 0.2);
  box-shadow: 0 4px 12px -2px rgba(45, 31, 15, 0.05);
  margin-bottom: 0 !important;
  width: auto !important;
  min-height: 0 !important;
  max-width: 100%; /* Prevent horizontal overflow */
  overflow-x: auto; /* Allow horizontal scroll if squeezed too much on tiny mobile screens */
}

/* Force all wrappers to act as if they are not there, passing children up to the grid */
.wtl-form-in-header .wtl-keep-path {
  display: contents !important;
}

/* Safely hide everything else, protecting SVGs/spans inside our valid buttons */
.wtl-form-in-header *:not(.wtl-keep-path):not(.wtl-keep-visible):not(.wtl-keep-visible *):not([class*="popover"]):not([class*="popover"] *):not([class*="calendar"]):not([class*="calendar"] *):not(.rdp):not(.rdp *):not([data-radix-popper-content-wrapper]):not([data-radix-popper-content-wrapper] *) {
  display: none !important;
}

/* Style the visible labels */
.wtl-form-in-header label.wtl-keep-visible {
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  color: var(--text-lo) !important;
  letter-spacing: 0.05em !important;
  line-height: 1 !important;
  margin: 0 8px 0 0 !important; /* Space between label and input */
  padding: 0 !important;
  display: block; /* Flex item behaves as block within flex row */
  flex: 0 0 auto; /* Prevent label from shrinking */
  white-space: nowrap; /* Keep label text on one line */
}

/* Style the visible buttons (Allow native WPCafe styling!) */
.wtl-form-in-header button.wtl-keep-visible,
.wtl-form-in-header select.wtl-keep-visible,
.wtl-form-in-header .wtl-dt-btn {
  margin: 0 16px 0 0 !important; /* Extra space after the input before the next label */
  position: relative; 
  flex: 0 1 auto; /* Prevent overly greedy stretching */
  width: auto !important; /* Override aggressive WPCafe 100% block widths */
  max-width: 250px;
}

/* Legacy fallback block styling */
.wtl-form-in-header .wtl-dt-fallback-block {
  display: flex !important;
  flex-direction: column;
  gap: 4px;
}
.wtl-form-in-header .wtl-dt-fallback-block label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-lo);
  margin: 0;
}
.wtl-form-in-header .wtl-dt-fallback-block input {
  font-family: var(--font);
  font-size: 14px;
  border: none;
  background: transparent;
  padding: 0;
}

.wtl-sel-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.wtl-leg {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 99px;
  border: 1.5px solid transparent;
}
.wtl-leg::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  display: block;
  flex-shrink: 0;
}
.wtl-leg--available { background: var(--avail-bg); color: var(--available); border-color: var(--avail-border); }
.wtl-leg--available::before { background: var(--available); }
.wtl-leg--booked    { background: var(--booked-bg); color: var(--booked);    border-color: var(--booked-bord); }
.wtl-leg--booked::before    { background: var(--booked); }
.wtl-leg--selected  { background: var(--sel-bg);   color: var(--selected);  border-color: var(--sel-border); }
.wtl-leg--selected::before  { background: var(--selected); }

/* ── Canvas wrap ─────────────────────────────────────────────────────────── */
.wtl-sel-canvas-wrap {
  padding: 20px;
  background: var(--bg);
}
#wtl-sel-canvas {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  /* Default warm floor gradient — replaced by the floor plan photo in SVG when uploaded */
  background:
    radial-gradient(ellipse at center, #f5ece0 0%, #ede0cc 100%);
  border: 1px solid var(--border-dark);
  box-shadow: inset 0 2px 12px rgba(45,31,15,.08), var(--shadow-sm);
  transition: background .3s;
}
/* When a background photo is set, the SVG image element covers everything */
#wtl-sel-canvas.wtl-has-bg-image {
  background: #1a1209;
}

/* ── SVG floor plan ──────────────────────────────────────────────────────── */
.wtl-floor-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Chair dots ──────────────────────────────────────────────────────────── */
.wtl-chair {
  fill: #c4a47c;
  stroke: #a08060;
  stroke-width: 1.5;
  transition: fill .2s;
}
.wtl-state--booked   .wtl-chair { fill: #fca5a5; stroke: #dc2626; }
.wtl-state--selected .wtl-chair { fill: #fcd34d; stroke: #b45309; }

/* ── Table shapes ────────────────────────────────────────────────────────── */
.wtl-table-shape {
  fill: #fff8f0;
  stroke: #c9b89e;
  stroke-width: 2.5;
  transition: fill .2s, stroke .2s, filter .2s;
  filter: drop-shadow(0 2px 6px rgba(45,31,15,.12));
}
.wtl-map-table { transition: transform .15s; }
.wtl-map-table:hover .wtl-table-shape {
  fill: #fff3e0;
  stroke: #b45309;
  filter: drop-shadow(0 4px 14px rgba(180,83,9,.2));
}

/* Available */
.wtl-state--available .wtl-table-shape {
  fill: #f0fdf4;
  stroke: #86efac;
}
.wtl-state--available:hover .wtl-table-shape {
  fill: #dcfce7;
  stroke: var(--available);
  filter: drop-shadow(0 4px 16px rgba(22,163,74,.28));
}
.wtl-state--available { cursor: pointer; }

/* Booked */
.wtl-state--booked .wtl-table-shape {
  fill: #fff1f2;
  stroke: #fca5a5;
  stroke-dasharray: 6 3;
}
.wtl-state--booked { cursor: not-allowed; opacity: .7; }

/* Selected */
.wtl-state--selected .wtl-table-shape {
  fill: #fef3c7;
  stroke: var(--selected);
  stroke-width: 3;
  filter: drop-shadow(0 0 12px rgba(180,83,9,.45)) drop-shadow(0 4px 12px rgba(180,83,9,.2));
  animation: wtl-pulse-border 2s ease-in-out infinite;
}

@keyframes wtl-pulse-border {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(180,83,9,.4)); }
  50%       { filter: drop-shadow(0 0 20px rgba(180,83,9,.65)); }
}

/* ── Table labels ────────────────────────────────────────────────────────── */
.wtl-table-label {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  fill: var(--text-hi);
  pointer-events: none;
  paint-order: stroke fill;
  stroke: rgba(255,255,255,0.9);
  stroke-width: 3;
  stroke-linejoin: round;
}
.wtl-table-seats {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 500;
  fill: var(--text-md);
  pointer-events: none;
  paint-order: stroke fill;
  stroke: rgba(255,255,255,0.85);
  stroke-width: 2.5;
  stroke-linejoin: round;
}
.wtl-state--available .wtl-table-label { fill: var(--available); }
.wtl-state--booked    .wtl-table-label { fill: var(--booked); }
.wtl-state--selected  .wtl-table-label { fill: var(--selected); }

/* ── Footer bar ──────────────────────────────────────────────────────────── */
.wtl-sel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 24px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}

.wtl-sel-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-md);
}
.wtl-sel-status--selected {
  color: var(--selected);
}
.wtl-sel-status--selected svg { stroke: var(--selected); }
.wtl-sel-status--loading { color: var(--text-lo); }

/* Slot-found status (date picked, no time yet) */
.wtl-sel-status--slots {
  color: #0369a1;
}
.wtl-sel-status--slots svg { stroke: #0369a1; }
.wtl-sel-status--slots strong { font-weight: 700; }

.wtl-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border-dark);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: wtl-spin .7s linear infinite;
  flex-shrink: 0;
  display: inline-block;
}
@keyframes wtl-spin { to { transform: rotate(360deg); } }

.wtl-refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg);
  border: 1.5px solid var(--border-dark);
  border-radius: 8px;
  color: var(--text-md);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all .18s;
}
.wtl-refresh-btn:hover {
  background: var(--sel-bg);
  border-color: var(--selected);
  color: var(--selected);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .wtl-sel-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .wtl-sel-legend {
    width: 100%;
  }
  .wtl-sel-footer {
    flex-direction: column;
    align-items: flex-start;
  }
  .wtl-sel-canvas-wrap {
    padding: 12px;
  }
}

/* ── Accessible focus ────────────────────────────────────────────────────── */
.wtl-map-table:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   STEP 2 BANNER — appears above the WPCafe form after a table is chosen
   ═══════════════════════════════════════════════════════════════════════════ */
.wtl-step-banner {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  border-radius: 14px;
  margin-bottom: 20px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity .45s cubic-bezier(.16,1,.3,1), transform .45s cubic-bezier(.16,1,.3,1);
  /* hidden until JS adds --visible class */
  pointer-events: none;
}
.wtl-step-banner--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.wtl-step-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  border: 2px solid #fcd34d;
  border-radius: 14px;
  position: relative;
  overflow: hidden;
}

/* Gold shimmer sweep on reveal */
.wtl-step-inner::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent);
  animation: wtl-shimmer .75s .1s ease-out forwards;
}
@keyframes wtl-shimmer {
  to { left: 160%; }
}

.wtl-step-badge {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #b45309, #d97706);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(180,83,9,.35);
}

.wtl-step-text {
  flex: 1;
  min-width: 0;
}
.wtl-step-text strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #92400e;
  line-height: 1.2;
  margin-bottom: 3px;
}
.wtl-step-text span {
  font-size: 13px;
  color: #b45309;
  font-weight: 500;
}
.wtl-step-text em {
  font-style: normal;
  font-weight: 700;
  color: #7c2d12;
}

.wtl-step-table-icon {
  color: #d97706;
  opacity: .55;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   WPCafe FORM REVEAL ANIMATION
   ═══════════════════════════════════════════════════════════════════════════ */
@keyframes wtl-form-intro {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.wtl-form-revealed {
  animation: wtl-form-intro .55s cubic-bezier(.16,1,.3,1) both;
}

/* ── Status: scroll-hint arrow after table selection ─────────────────────── */
.wtl-sel-status--selected::after {
  content: '↓ Scroll to form';
  display: inline-block;
  margin-left: 12px;
  padding: 3px 10px;
  background: var(--sel-bg);
  border: 1px solid var(--sel-border);
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  color: var(--selected);
  letter-spacing: .02em;
  animation: wtl-pulse-hint 2s ease-in-out infinite;
}
@keyframes wtl-pulse-hint {
  0%,100% { opacity: 1; }
  50%      { opacity: .55; }
}

/* ── Responsive adjustments ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .wtl-step-inner { flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
  .wtl-step-table-icon { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESERVATION MODAL — shown when a table is clicked on the floor map
   ═══════════════════════════════════════════════════════════════════════════ */

/* Backdrop overlay */
.wtl-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(20, 10, 0, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  /* Hidden by default */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
  overflow-y: auto;
}

/* Visible state (toggled by JS) */
.wtl-modal-overlay.wtl-modal--open {
  opacity: 1;
  pointer-events: auto;
}

/* Dialog box */
.wtl-modal-dialog {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  outline: none;
  transform: translateY(28px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  opacity: 0;
}

.wtl-modal--open .wtl-modal-dialog {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* ── Modal header */
.wtl-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 18px;
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  border-bottom: 1px solid #e8dfd4;
  flex-shrink: 0;
}

.wtl-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.wtl-modal-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #b45309, #d97706);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(180, 83, 9, 0.3);
  flex-shrink: 0;
}

.wtl-modal-title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #2d1f0f;
  margin: 0 0 2px;
  line-height: 1.2;
}

.wtl-modal-sub {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12px;
  color: #b45309;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Close button */
.wtl-modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(180, 83, 9, 0.08);
  color: #92400e;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s, color 0.18s, transform 0.18s;
  padding: 0;
  font-family: sans-serif;
}

.wtl-modal-close:hover {
  background: rgba(180, 83, 9, 0.18);
  color: #7c2d12;
  transform: rotate(90deg) scale(1.05);
}

.wtl-modal-close:focus-visible {
  outline: 2px solid #b45309;
  outline-offset: 2px;
}

/* ── Modal body (scrollable) */
.wtl-modal-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 28px 32px;
  background: #faf6f1;
}

.wtl-modal-body::-webkit-scrollbar {
  width: 6px;
}
.wtl-modal-body::-webkit-scrollbar-thumb {
  background: #c9b89e;
  border-radius: 3px;
}

/* Ensure the WPCafe form displays properly inside the modal */
.wtl-modal-body .wpcafe-reservation-wrapper,
.wtl-modal-body [class*="wpcafe-reservation"],
.wtl-modal-body [class*="wpc-reservation"] {
  display: block !important;
  margin: 0 !important;
}

/* ── Responsive */
@media (max-width: 600px) {
  .wtl-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .wtl-modal-dialog {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    transform: translateY(100%);
  }

  .wtl-modal--open .wtl-modal-dialog {
    transform: translateY(0);
  }

  .wtl-modal-header {
    padding: 16px 18px 14px;
  }

  .wtl-modal-body {
    padding: 18px 18px 28px;
  }
}

/* Ensure React portals (like Radix UI select dropdowns and date pickers) appear above the modal overlay */
[data-radix-popper-content-wrapper] {
  z-index: 100000 !important;
}

/* Ensure flatpickr dropdowns (Date & Time pickers for legacy form) appear above the modal overlay */
.flatpickr-calendar,
.flatpickr-calendar.open {
  z-index: 100000 !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TIME SLOT CHIPS on the floor map SVG
   ═══════════════════════════════════════════════════════════════════════════ */

/* Pulse animation for the "loading slots…" text inside each table */
@keyframes wtl-slot-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}
.wtl-slot-loading-text {
  animation: wtl-slot-pulse 1.4s ease-in-out infinite;
}

/* Fade-in for the slot overlay group once chips are rendered */
@keyframes wtl-slot-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.wtl-slot-overlay {
  animation: wtl-slot-fade-in 0.3s ease-out both;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORM FIELD OVERRIDES
   ═══════════════════════════════════════════════════════════════════════════ */

/* Completely hide the 'Until?' / End time field everywhere */
.wtl-hide-always {
  display: none !important;
}

/* Disable interaction with Date and Start Time fields when inside the modal */
.wtl-modal-body .wtl-disable-in-modal,
.wtl-modal-body .wtl-disable-in-modal-el {
  pointer-events: none !important;
  opacity: 0.8;
}

/* Specific override for legacy inputs within the flagged wrappers */
.wtl-modal-body .wtl-disable-in-modal input,
.wtl-modal-body .wtl-disable-in-modal select,
.wtl-modal-body .wtl-disable-in-modal button {
  pointer-events: none !important;
  background-color: #f3ede6 !important; /* Visual read-only hint */
}

/* ───────────────────────────────────────────────────────────────────────────
   HIDE SEARCH INPUTS IN WPCAFE TIME DROPDOWNS
   ─────────────────────────────────────────────────────────────────────────── */
.wcf-popover input[type="search"],
.wcf-select-dropdown input[type="search"],
.ant-select-dropdown input[type="search"],
.select2-search--dropdown,
.rc-virtual-list input[type="search"],
input.wcf-search-input,
div[class*="search-wrapper"] > input[placeholder*="Search"],
div[class*="search"] > input[placeholder*="Search"],
div[class*="Search"] > input[placeholder*="Search"] {
  display: none !important;
}

/* Also hide the container box padding if possible */
.wcf-popover .wcf-search-box,
.wcf-select-dropdown .wcf-search-wrap,
.select2-search.select2-search--dropdown,
div:has(> input[placeholder*="Search"]) {
  display: none !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
}

