/* filters.css — room picker (select + fuzzy search), specific stay-date
   chips, and the mobile collapsible filter panel.
   Loaded after styles.css (see index.html); styles.css itself is left
   alone — everything new lives here. */

.filter-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filter-summary {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

#filter-toggle {
  flex: 0 0 auto;
  display: inline-flex;
}

.filter-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

/* The toggle + collapse behavior only matters on narrow screens — desktop
   always shows the full filter panel regardless of `filterCollapsed`. */
@media (min-width: 600px) {
  #filter-toggle {
    display: none;
  }
}

@media (max-width: 599px) {
  .filter-body.is-collapsed {
    display: none;
  }

  /* styles.css makes .filter-bar `position: sticky`. Once expanded on a
     narrow screen the panel is taller than the viewport, so staying glued
     to the top blocks all the tab content below it for as long as it's
     open — from the user's perspective indistinguishable from the page
     being frozen. Let the open panel scroll with the page like normal
     content instead; the collapsed summary bar keeps the sticky behavior
     from styles.css untouched. */
  .filter-bar:has(.filter-body:not(.is-collapsed)) {
    position: static;
  }
}

/* ---- room select + fuzzy search ---- */

.fuzzy-results {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  max-height: 260px;
  overflow-y: auto;
}

.fuzzy-hitall {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
}

.fuzzy-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.fuzzy-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.fuzzy-item:last-child {
  border-bottom: none;
}
.fuzzy-item:hover,
.fuzzy-item:focus-visible {
  background: var(--bg-sunken);
  outline: none;
}
.fuzzy-item.is-selected {
  background: var(--accent-soft);
}

.fuzzy-room-name mark {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  border-radius: 2px;
  padding: 0 1px;
}

.fuzzy-room-meta {
  color: var(--text-faint);
  font-size: 11px;
}

.fuzzy-empty {
  padding: 10px;
  color: var(--text-faint);
  font-size: 12px;
}

/* ---- specific stay-date chips ---- */

.chip-removable {
  padding: 8px 12px;
}

@media (max-width: 599px) {
  .fuzzy-results {
    max-height: 220px;
  }
  /* 16px avoids iOS Safari's automatic zoom-on-focus for form controls. */
  #room-select,
  #room-fuzzy {
    font-size: 16px;
  }
}

/* ---- multi-date calendar picker (宿泊日 個別指定) ---- */
/* Built entirely in JS by app.js's initUseDatePicker(); see that function
   for why. A collapsible inline block (not a floating popover) so it can
   never cause horizontal overflow — it just grows the filter panel's
   height, like the rest of the collapsible filter body already does. */

.use-date-toggle {
  align-self: flex-start;
  min-height: 36px;
}

/* The calendar needs more width than this filter-group's normal flex-basis
   allows inside its wrapping .filter-row, especially on narrow screens —
   give it the full row once open instead of letting flex-wrap squeeze it. */
.filter-group:has(.use-date-calendar:not([hidden])) {
  flex: 1 1 100%;
}

.use-date-calendar {
  margin-top: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  max-width: 320px;
  box-sizing: border-box;
}

.use-date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.use-date-nav-title {
  font-size: 13px;
  font-weight: 700;
}

.use-date-nav-btn {
  min-width: 36px;
  min-height: 36px;
}

.use-date-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 4px;
  font-size: 10.5px;
  color: var(--text-faint);
  text-align: center;
}

.use-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.use-date-cell {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.use-date-cell.is-empty {
  visibility: hidden;
  cursor: default;
  border: none;
  background: none;
}

/* Past days stay tappable (a bookmarked link may still want them) but read
   as de-emphasized. */
.use-date-cell.is-past {
  color: var(--text-faint);
  opacity: 0.7;
}

.use-date-cell.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
  opacity: 1;
}

.use-date-cell:hover {
  border-color: var(--text-faint);
}

.use-date-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}
