/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-muted);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.08);
}

.btn-danger {
  color: var(--danger);
}

.btn-small {
  padding: 4px 12px;
  font-size: 0.875rem;
}

.btn-link {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.row-between {
  justify-content: space-between;
}

/* Tabs (list switcher): folder tabs whose selected tab merges into the panel below */
.tabs-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.tabs-bar .tabs {
  flex: 1;
  min-width: 0;
}

.tabs-bar > .btn {
  margin-bottom: 8px;
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  /* the selected tab overlaps the panel's top border */
  position: relative;
  z-index: 1;
  margin-bottom: -1px;
}

.tab {
  flex: none;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: none;
  color: var(--ink-muted);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.tab:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 55%, transparent);
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tab[aria-selected="true"] {
  background: var(--panel);
  border-color: var(--border);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 3px 0 var(--accent);
  /* covers the panel's top border under the tab */
  padding-bottom: 11px;
  margin-bottom: -1px;
}

.tab-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

/* the first tab sits flush on the panel's left edge: square that corner */
:is(.tabs, .tabs-bar):has(.tab:first-child[aria-selected="true"]) + .tab-panel {
  border-top-left-radius: 0;
}

.tab-panel-alone {
  background: none;
  border: none;
  padding: 0;
}

@media (max-width: 560px) {
  .tab-panel:not(.tab-panel-alone) {
    padding: 16px 12px;
  }

  .tab {
    padding: 8px 14px;
  }

  .tab[aria-selected="true"] {
    padding-bottom: 9px;
  }
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label,
.field .label {
  font-weight: 500;
  font-size: 0.9rem;
}

.field .hint {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}

input:focus-visible,
textarea:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

@media (max-width: 560px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0;
}

/* Dialogs */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 24px;
  width: min(560px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}

dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

dialog h2 {
  margin-bottom: 16px;
  font-size: 1.4rem;
}

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

/* Gift grid */
.gift-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: start;
  gap: 16px;
}

.gift-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

/* Image gallery on gift cards */
.gallery {
  position: relative;
}

.gallery-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.gallery-track::-webkit-scrollbar {
  display: none;
}

.gift-card .gift-image {
  flex: 0 0 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  width: 100%;
  scroll-snap-align: start;
  background: var(--surface-muted);
}

.gift-card .gift-image.is-broken {
  visibility: hidden;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgb(255 255 255 / 85%);
  color: #2a2420;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.15s;
}

.gallery-prev {
  left: 8px;
}

.gallery-next {
  right: 8px;
}

.gallery:hover .gallery-nav,
.gallery-nav:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .gallery-nav {
    display: none;
  }
}

.gallery-dots {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}

.gallery-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgb(255 255 255 / 55%);
  box-shadow: 0 0 2px rgb(0 0 0 / 40%);
}

.gallery-dot.is-active {
  background: #fff;
}

.gift-card .gift-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  flex: 1;
}

.gift-card h3 {
  font-size: 1.15rem;
}

.gift-card .gift-description {
  margin: 0;
  color: var(--ink-muted);
  white-space: pre-line;
}

.gift-card .gift-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gift-card.is-unavailable .gallery {
  filter: grayscale(0.7);
  opacity: 0.7;
}

.price {
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--surface-muted);
  color: var(--ink-muted);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.reservers {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--ink-muted);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 10;
  max-width: calc(100vw - 32px);
}

.toast.is-error {
  background: var(--danger);
  color: #fff;
}

.btn-confirm-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
