/* ============================================================
   BS Hours — Frontend Stylesheet
   ============================================================ */

:root {
  --bs-open:       #22c55e;
  --bs-closed:     #ef4444;
  --bs-soft-close: #f59e0b;
  --bs-event:      #8b5cf6;
  --bs-special:    #3b82f6;
  --bs-radius:     6px;
  --bs-font:       inherit;
}

/* ── Wrapper ─────────────────────────────────────────── */
.bs-hours { font-family: var(--bs-font); }

/* ── Badge ───────────────────────────────────────────── */
.bs-hours__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bs-badge-color, var(--bs-open)) 15%, transparent);
  color: color-mix(in srgb, var(--bs-badge-color, var(--bs-open)) 80%, #000);
  font-size: .82em;
  font-weight: 600;
  line-height: 1.4;
  vertical-align: middle;
  transition: background .2s;
}

.bs-hours__badge-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--bs-badge-color, var(--bs-open));
  flex-shrink: 0;
}

/* Badge style variants */
.bs-hours__badge--dot { background: transparent; padding: 0; }
.bs-hours__badge--dot .bs-hours__badge-dot { width: 10px; height: 10px; }
.bs-hours__badge--dot .bs-hours__badge-label { display: none; }
.bs-hours__badge--text { background: transparent; padding: 0; color: var(--bs-badge-color, var(--bs-open)); }
.bs-hours__badge--text .bs-hours__badge-dot { display: none; }

/* State colors via CSS custom property set inline */
.bs-hours--open    .bs-hours__badge { --bs-badge-color: var(--bs-open); }
.bs-hours--closed  .bs-hours__badge { --bs-badge-color: var(--bs-closed); }
.bs-hours--soft-close .bs-hours__badge { --bs-badge-color: var(--bs-soft-close); }

/* ── Message ─────────────────────────────────────────── */
.bs-hours__message { margin-left: 4px; }
.bs-hours__next    { color: #6b7280; font-size: .9em; }

/* ── Hours Table ─────────────────────────────────────── */
.bs-hours__table {
  border-collapse: collapse;
  width: 100%;
  font-size: .95em;
}

.bs-hours__table th,
.bs-hours__table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(0,0,0,.07);
}

.bs-hours__table th { font-weight: 600; white-space: nowrap; }

.bs-hours__row--today th,
.bs-hours__row--today td {
  background: color-mix(in srgb, var(--bs-open) 8%, transparent);
  font-weight: 700;
  color: color-mix(in srgb, var(--bs-open) 60%, #000);
}

.bs-hours__row--closed th,
.bs-hours__row--closed td { color: #9ca3af; }

.bs-hours__row--special th,
.bs-hours__row--special td {
  background: color-mix(in srgb, var(--bs-special) 6%, transparent);
}

.bs-hours__row--sub-header th {
  background: #f9fafb;
  font-size: .8em;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  padding: 4px 10px;
}

.bs-hours__closed { color: #9ca3af; }
.bs-hours__note   { color: #6b7280; font-size: .85em; font-style: italic; }

/* Sub-period rows */
.bs-hours__period--kitchen    td { color: #b45309; }
.bs-hours__period--happy-hour td { color: #15803d; }
.bs-hours__period--brunch     td { color: #7c3aed; }

/* ── List layout ─────────────────────────────────────── */
.bs-hours__list {
  list-style: none;
  margin: 0; padding: 0;
  font-size: .95em;
}
.bs-hours__list .bs-hours__row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.bs-hours__list .bs-hours__day { font-weight: 600; }
.bs-hours__list .bs-hours__row--today { color: var(--bs-open); font-weight: 700; }

/* ── Countdown ───────────────────────────────────────── */
.bs-hours__countdown {
  display: inline-block;
  font-variant-numeric: tabular-nums;
}
.bs-hours__countdown-prefix,
.bs-hours__countdown-suffix { font-style: italic; }

/* ── Transitions / animation ─────────────────────────── */
.bs-hours__badge,
.bs-hours__message,
.bs-hours__countdown-time {
  transition: opacity .25s;
}
.bs-hours--refreshing .bs-hours__badge,
.bs-hours--refreshing .bs-hours__message {
  opacity: .5;
}

/* ── v1.3.0 additions ─────────────────────────────────── */

/* Inline sub-period rows (show_sub_inline=true) */
.bs-hours__row--sub-inline th,
.bs-hours__row--sub-inline td {
  padding-left: 24px;
  font-size: .85em;
  color: #6b7280;
  border-left: 2px solid #e5e7eb;
}
.bs-hours__day--sub {
  font-weight: 400;
  font-style: italic;
}

/* Upcoming special date rows */
.bs-hours__row--upcoming-special th,
.bs-hours__row--upcoming-special td {
  background: color-mix(in srgb, var(--bs-special) 5%, transparent);
  font-style: italic;
  color: #1e40af;
  font-size: .9em;
}

/* Badge size modifiers */
.bs-hours__badge--small {
  font-size: .72em;
  padding: 2px 7px 2px 6px;
}
.bs-hours__badge--small .bs-hours__badge-dot {
  width: 6px;
  height: 6px;
}
.bs-hours__badge--large {
  font-size: .96em;
  padding: 5px 14px 5px 11px;
}
.bs-hours__badge--large .bs-hours__badge-dot {
  width: 10px;
  height: 10px;
}

/* Badge typography modifiers */
.bs-hours__badge--bold   { font-weight: 700; }
.bs-hours__badge--italic { font-style: italic; }
.bs-hours__badge--no-bold { font-weight: 400; }

/* ── v1.5.0 — Info Box ─────────────────────────────────── */
.bs-hours__infobox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1.5px solid #bae6fd;
  background: #f0f9ff;
  color: #0c4a6e;
  font-size: .95em;
  line-height: 1.5;
}
.bs-hours__infobox-icon {
  flex-shrink: 0;
  font-size: 1.1em;
  line-height: 1.4;
}
.bs-hours__infobox-text { flex: 1; }
.bs-hours__infobox--small  { font-size: .82em; padding: 7px 11px; }
.bs-hours__infobox--large  { font-size: 1.05em; padding: 13px 18px; }

/* ── v1.6.0 — Table sub-period same-cell display ── */
.bs-hours__sub-sep {
  opacity: .55;
  margin: 0 .25em;
}
.bs-hours__sub-list {
  display: block;
  margin-top: .25em;
}
.bs-hours__sub-list .bs-hours__sub-item {
  display: block;
  font-size: .9em;
  color: inherit;
  opacity: .82;
}
.bs-hours__sub-item .bs-hours__sub-label {
  font-weight: 600;
  margin-right: .25em;
}
/* Inline mode: keep items inline */
.bs-hours__times .bs-hours__sub-item { display: inline; }
.bs-hours__times .bs-hours__sub-list .bs-hours__sub-item { display: block; }

/* ── v1.6.0 — Tooltip infobox ── */
.bs-hours__tooltip-wrap {
  position: relative;
  display: inline-block;
}
.bs-hours__tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #bae6fd;
  color: #0c4a6e;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  vertical-align: middle;
  line-height: 1;
  /* default (medium) size */
  width: 1.15em;
  height: 1.15em;
  font-size: .88em;
}
.bs-hours__tooltip-icon--small  { width: 14px; height: 14px; font-size: 10px; line-height: 14px; }
.bs-hours__tooltip-icon--medium { width: 20px; height: 20px; font-size: 14px; line-height: 20px; }
.bs-hours__tooltip-icon--large  { width: 28px; height: 28px; font-size: 18px; line-height: 28px; }

.bs-hours__tooltip-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  /* colors driven by CSS custom properties set inline from PHP */
  background: var(--bs-tt-bg, #1e293b);
  color: var(--bs-tt-color, #f1f5f9);
  border: 1px solid var(--bs-tt-border, #334155);
  border-radius: 6px;
  line-height: 1.4;
  min-width: 160px;
  max-width: min(280px, calc(100vw - 24px));
  pointer-events: none;
  opacity: 0;
  transition: opacity .17s;
  z-index: 9999;
  white-space: normal;
  /* default (medium) size */
  padding: 7px 10px;
  font-size: .85em;
}
.bs-hours__tooltip-popup--small  { padding: 5px 8px;   font-size: .75em; max-width: 200px; }
.bs-hours__tooltip-popup--medium { padding: 7px 10px;  font-size: .85em; }
.bs-hours__tooltip-popup--large  { padding: 9px 13px;  font-size: .95em; max-width: 320px; }

.bs-hours__tooltip-wrap:hover .bs-hours__tooltip-popup,
.bs-hours__tooltip-wrap:focus-within .bs-hours__tooltip-popup,
.bs-hours__tooltip-wrap.bs-tooltip-open .bs-hours__tooltip-popup {
  opacity: 1;
  pointer-events: auto;
}

/* sub_display="row" — dedicated sub-period rows */
.bs-hours__row--sub-row th.bs-hours__day--sub {
  font-weight: 500;
  font-size: .88em;
  opacity: .75;
  padding-left: 1.4em;
}
.bs-hours__row--sub-row td.bs-hours__times {
  font-size: .88em;
  opacity: .82;
}

/* ── v1.7.3 — Sub-Period Status ─────────────────────────── */
@keyframes bs-sub-pulse-active {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.55; transform: scale(0.82); }
}
@keyframes bs-sub-pulse-soon {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.88); }
}

.bs-sub-status { line-height: 1.5; }

.bs-sub-status__row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}
.bs-sub-status__row:last-child { margin-bottom: 0; }

.bs-sub-status__msg { font-size: inherit; }

.bs-sub-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bs-sub-dot-color, #22c55e);
  flex-shrink: 0;
}
.bs-sub-dot--active {
  animation: bs-sub-pulse-active 1.6s ease-in-out infinite;
}
.bs-sub-dot--soon {
  animation: bs-sub-pulse-soon 0.9s ease-in-out infinite;
}

.bs-sub-status__state--not-today { color: #6b7280; font-size: .9em; }
.bs-sub-status__state--before    { color: #6b7280; }
.bs-sub-status__state--after     { color: #9ca3af; font-style: italic; }

.bs-sub-status__weekly-label    { font-weight: 600; margin-right: .3em; }
.bs-sub-status__weekly-schedule { color: #6b7280; font-size: .9em; }
