/* App-specific tweaks on top of Pico v2 (classless) */

/* Layout helpers */
.container {
  max-width: 960px;
  margin-inline: auto;
  padding-inline: 1rem;
}

.scroll-x {
  overflow-x: auto;
}

.actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* Thumbnails */
.thumb-img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
}

.thumb-img-lg {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 6px;
}

/* Wider landscape thumbnail for list view */
.thumb-img-wide {
  width: 144px; /* ~50% wider than 96px */
  height: 96px;
  object-fit: cover;
  border-radius: 6px;
}

.thumb-img-xl {
  width: 128px;
  height: 128px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  margin-inline: auto;
}

.primary-image {
  max-width: 360px;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.thumb-grid {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.thumb-card {
  border: 1px solid var(--muted-border-color, #e5e7eb);
  padding: 8px;
  text-align: center;
  width: 180px;
  border-radius: 8px;
}

.media-section { margin-top: 1rem; }

/* List view: table on desktop, cards on mobile */
.item-table { width: 100%; }
.item-cards { display: grid; gap: 0.75rem; }

.item-card {
  padding: 0.75rem 1rem;
  border: 1px solid var(--muted-border-color, #e5e7eb);
  border-radius: 10px;
}

.item-card__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
}

.item-card__title { margin: 0; }
.item-card__sub { margin: 0; color: var(--muted-color, #6b7280); }

.item-card__footer { margin-top: 0.5rem; }

/* Responsive toggle: mobile-first shows cards, hides table */
.item-table { display: none; }
.item-cards { grid-template-columns: 1fr; }

@media (min-width: 768px) {
  .item-table { display: table; }
  .item-cards { display: none; }
}

/* Filter bar */
.filter-bar {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr;
  align-items: end;
  margin-bottom: 0.75rem;
}

.filter-bar .actions {
  justify-content: flex-start;
}

@media (min-width: 640px) {
  .filter-bar {
    grid-template-columns: 1fr 180px 160px 120px auto;
  }
}

/* Pager */
.pager ul {
  list-style: none;
  display: flex;
  gap: 0.75rem;
  padding: 0;
  justify-content: center;
  align-items: center;
}

/* Small buttons + inline action group */
.btn-sm {
  font-size: 0.85rem;
  line-height: 1.1;
  padding: 0.25rem 0.5rem;
}

.inline-actions {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
}
.inline-actions form { margin: 0; display: inline; }

/* Muted helper */
.muted { color: var(--muted-color, #6b7280); }

/* Tag row inside the table */
.item-tags-row .tag-cell {
  font-size: 0.9em;
  padding-top: 0.25rem;
  padding-bottom: 0.5rem;
}

/* Collapse separator between main + tag rows; keep only after the pair */
.item-table tbody tr.item-main-row.has-tags > td:not(.photo-cell) {
  border-bottom: 0 !important;
}
.item-table tbody tr.item-tags-row > td {
  border-top: 0 !important;
}

/* Align photo cell nicely when spanning rows */
.item-table td.photo-cell { vertical-align: top; }

/* Flash messages (styled to complement Pico Classless) */
.flash-stack { display: grid; gap: 0.5rem; margin: 0.75rem 0; }
.flash {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--muted-border-color, #e5e7eb);
  background: var(--card-background-color, #f9fafb);
}
.flash.success {
  background: #ecfdf5;
  border-color: #10b981;
  color: #065f46;
}
.flash.info {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1e40af;
}
.flash.warning {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #7c2d12;
}
.flash.error {
  background: #fef2f2;
  border-color: #ef4444;
  color: #7f1d1d;
}
.flash.debug {
  background: #f3f4f6;
  border-color: #9ca3af;
  color: #374151;
}

/* Filter bar: compact sizing + alignment */
.filter-bar { align-items: end; }
.filter-bar :is(input[type="search"], select, button) {
  font-size: 0.95rem;
  padding-block: 0.45rem;
  padding-inline: 0.75rem;
  min-block-size: 2.5rem;
  border-radius: 10px;
}
.filter-bar input[type="search"] {
  border-radius: 10px;
  /* Space for built-in search icon so placeholder doesn't overlap */
  padding-inline-start: 2.25rem;
}
.filter-bar .actions {
  margin-top: 0;
  align-items: center;
  gap: 0.5rem;
}
/* Ghost-style link button for Clear */
.filter-bar .actions a {
  align-self: center;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.75rem;
  min-block-size: 2.5rem;
  border: 1px solid transparent;
  border-radius: 10px;
  text-decoration: none;
  background: transparent;
}
.filter-bar .actions a:hover {
  border-color: var(--muted-border-color, #e5e7eb);
  background: var(--card-background-color, #f9fafb);
}
.filter-bar .actions a:focus-visible {
  outline: 2px solid var(--primary, #3b82f6);
  outline-offset: 2px;
}
/* Ensure Apply button aligns with ghost Clear */
.filter-bar .actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 2.5rem;
  line-height: 1;
  padding: 0.45rem 0.75rem;
  border-radius: 10px;
  margin: 0;
}

/* Room for select labels at md+ */
@media (min-width: 640px) {
  .filter-bar { grid-template-columns: 1fr 220px 140px 110px auto; }
}
.filter-bar select[name="availability"] { min-width: 200px; }
.filter-bar select[name="sort"] { min-width: 130px; }
.filter-bar select[name="dir"] { min-width: 110px; }
