/*
 * Bib1s Album widget. Mọi rule gắn với class bib1s-* để không ảnh hưởng theme; các thuộc tính
 * theme hay ghi đè (button, a, img, h2/h3) được đặt lại tường minh.
 * Đổi màu/kích thước trong theme (Giao diện → Tuỳ biến → CSS bổ sung), ví dụ:
 *   .bib1s-widget { --bib1s-primary: #e11d48; --bib1s-thumb-min: 200px; }
 */

.bib1s-widget,
.bib1s-lightbox {
  --bib1s-primary: #4f39f6;
  --bib1s-primary-contrast: #fff;
  --bib1s-radius: 12px;
  --bib1s-gap: 8px;
  --bib1s-thumb-min: 150px;
  --bib1s-muted: #64748b;
  --bib1s-border: #e2e8f0;
  --bib1s-surface: #f8fafc;
  --bib1s-error: #dc2626;
}

.bib1s-widget {
  box-sizing: border-box;
  margin: 1.5em 0;
  font-size: 15px;
  line-height: 1.5;
}

.bib1s-widget *,
.bib1s-widget *::before,
.bib1s-widget *::after {
  box-sizing: border-box;
}

.bib1s-widget [hidden],
.bib1s-lightbox [hidden] {
  display: none !important;
}

.bib1s-icon {
  display: inline-flex;
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
}

.bib1s-icon svg {
  width: 100%;
  height: 100%;
}

/* ---------- nút & input ---------- */

.bib1s-widget .bib1s-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  margin: 0;
  padding: 0.6em 1.2em;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  line-height: 1.4;
  text-transform: none;
  letter-spacing: normal;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
  transition: opacity 0.15s, background-color 0.15s;
}

.bib1s-widget .bib1s-btn:disabled,
.bib1s-widget .bib1s-btn.is-disabled {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

.bib1s-widget .bib1s-btn-primary {
  background: var(--bib1s-primary);
  color: var(--bib1s-primary-contrast);
}

.bib1s-widget .bib1s-btn-primary:hover {
  opacity: 0.9;
}

.bib1s-widget .bib1s-btn-secondary {
  border-color: var(--bib1s-border);
  background: #fff;
  color: #0f172a;
}

.bib1s-widget .bib1s-btn-secondary:hover {
  background: var(--bib1s-surface);
}

.bib1s-widget .bib1s-input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0.6em 1em;
  border: 1px solid var(--bib1s-border);
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  box-shadow: none;
}

.bib1s-widget .bib1s-input:focus {
  outline: 2px solid var(--bib1s-primary);
  outline-offset: 1px;
  border-color: transparent;
}

/* ---------- header album ---------- */

.bib1s-widget .bib1s-back {
  margin-bottom: 1em;
  padding: 0.3em 0;
  color: var(--bib1s-muted);
  font-weight: 500;
}

.bib1s-widget .bib1s-back:hover {
  color: inherit;
}

.bib1s-widget .bib1s-header {
  margin-bottom: 1.25em;
}

.bib1s-widget .bib1s-title {
  margin: 0 0 0.35em;
  padding: 0;
  font-size: 1.6em;
  line-height: 1.25;
}

.bib1s-widget .bib1s-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35em 1.1em;
  color: var(--bib1s-muted);
  font-size: 0.92em;
}

.bib1s-widget .bib1s-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}

.bib1s-widget .bib1s-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  margin-top: 0.6em;
  color: var(--bib1s-primary);
  font-size: 0.92em;
  font-weight: 600;
  text-decoration: none;
}

.bib1s-widget .bib1s-link:hover {
  text-decoration: underline;
}

/* ---------- tabs ---------- */

.bib1s-widget .bib1s-tabs {
  display: flex;
  gap: 0.25em;
  margin-bottom: 1.25em;
  border-bottom: 1px solid var(--bib1s-border);
  overflow-x: auto;
  scrollbar-width: none;
}

.bib1s-widget .bib1s-tab {
  flex-shrink: 0;
  margin: 0 0 -1px;
  padding: 0.7em 1em;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--bib1s-muted);
  font: inherit;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  box-shadow: none;
  cursor: pointer;
  white-space: nowrap;
}

.bib1s-widget .bib1s-tab:hover {
  color: #0f172a;
}

.bib1s-widget .bib1s-tab.is-active {
  border-bottom-color: var(--bib1s-primary);
  color: var(--bib1s-primary);
}

.bib1s-widget .bib1s-tab-short {
  display: none;
}

/* ---------- tìm kiếm ---------- */

.bib1s-widget .bib1s-search {
  display: flex;
  gap: 0.5em;
  max-width: 480px;
  margin-bottom: 1em;
}

.bib1s-widget .bib1s-face {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75em;
  margin-bottom: 1em;
}

.bib1s-widget .bib1s-face-picker {
  position: relative;
  overflow: hidden;
}

/* Ẩn input file nhưng vẫn bấm được qua label (và vẫn focus được bằng bàn phím) */
.bib1s-widget .bib1s-face-picker input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.bib1s-widget .bib1s-face-preview {
  width: 88px;
  height: 88px;
  max-width: none;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bib1s-border);
}

.bib1s-widget .bib1s-hint {
  margin: 0;
  color: var(--bib1s-muted);
  font-size: 0.88em;
}

.bib1s-widget .bib1s-password {
  max-width: 480px;
  padding: 1.5em;
  border: 1px solid var(--bib1s-border);
  border-radius: var(--bib1s-radius);
  background: var(--bib1s-surface);
}

.bib1s-widget .bib1s-password-title {
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin-bottom: 0.25em;
  font-size: 1.1em;
  font-weight: 700;
}

.bib1s-widget .bib1s-password .bib1s-hint {
  margin-bottom: 1em;
}

.bib1s-widget .bib1s-password .bib1s-search {
  margin-bottom: 0;
}

/* ---------- trạng thái ---------- */

.bib1s-widget .bib1s-status {
  display: flex;
  align-items: center;
  gap: 0.6em;
  margin: 1em 0;
  color: var(--bib1s-muted);
  font-size: 0.95em;
}

.bib1s-widget .bib1s-status.is-error {
  color: var(--bib1s-error);
}

.bib1s-widget .bib1s-spinner {
  width: 1.1em;
  height: 1.1em;
  border: 2px solid var(--bib1s-border);
  border-top-color: var(--bib1s-primary);
  border-radius: 50%;
  animation: bib1s-spin 0.8s linear infinite;
}

@keyframes bib1s-spin {
  to { transform: rotate(360deg); }
}

/* ---------- lưới ảnh ---------- */

.bib1s-widget .bib1s-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--bib1s-thumb-min), 1fr));
  gap: var(--bib1s-gap);
}

.bib1s-widget .bib1s-grid:empty {
  display: none;
}

.bib1s-widget .bib1s-thumb {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  aspect-ratio: 1;
  border: 0;
  border-radius: calc(var(--bib1s-radius) * 0.7);
  background: var(--bib1s-surface);
  box-shadow: none;
  overflow: hidden;
  cursor: zoom-in;
}

.bib1s-widget .bib1s-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  object-fit: cover;
  transition: transform 0.3s;
}

.bib1s-widget .bib1s-thumb:hover img {
  transform: scale(1.04);
}

.bib1s-widget .bib1s-thumb.is-broken img {
  visibility: hidden;
}

.bib1s-widget .bib1s-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 0.1em 0.5em;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 0.75em;
  font-weight: 600;
}

.bib1s-widget .bib1s-grid.is-loading,
.bib1s-widget .bib1s-event-grid.is-loading {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.2s;
}

/* ---------- phân trang ---------- */

/* Cuộn về đầu lưới khi đổi trang — chừa chỗ cho header dính của theme + thanh admin WordPress */
.bib1s-widget,
.bib1s-widget .bib1s-body {
  scroll-margin-top: 80px;
}

.bib1s-widget .bib1s-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75em;
  margin-top: 1.5em;
  padding-top: 1em;
  border-top: 1px solid var(--bib1s-border);
}

.bib1s-widget .bib1s-pagination.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

.bib1s-widget .bib1s-page-info {
  color: var(--bib1s-muted);
  font-size: 0.9em;
}

.bib1s-widget .bib1s-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bib1s-widget .bib1s-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25em;
  height: 2.25em;
  margin: 0;
  padding: 0 0.5em;
  border: 1px solid var(--bib1s-border);
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: 0.9em;
  font-weight: 600;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  box-shadow: none;
  cursor: pointer;
}

.bib1s-widget .bib1s-page:hover {
  background: var(--bib1s-surface);
}

.bib1s-widget .bib1s-page.is-active {
  border-color: var(--bib1s-primary);
  background: var(--bib1s-primary);
  color: var(--bib1s-primary-contrast);
  cursor: default;
}

.bib1s-widget .bib1s-page:disabled {
  opacity: 0.4;
  cursor: default;
}

.bib1s-widget .bib1s-page-gap {
  padding: 0 0.2em;
  color: var(--bib1s-muted);
}

/* ---------- danh sách sự kiện ---------- */

.bib1s-widget .bib1s-event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25em;
}

.bib1s-widget .bib1s-event-card {
  display: block;
  border: 1px solid var(--bib1s-border);
  border-radius: var(--bib1s-radius);
  background: #fff;
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.bib1s-widget .bib1s-event-card:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
  transform: translateY(-2px);
}

.bib1s-widget .bib1s-event-cover {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, var(--bib1s-primary), #312e81);
  color: rgba(255, 255, 255, 0.5);
  font-size: 2em;
}

.bib1s-widget .bib1s-event-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  object-fit: cover;
}

.bib1s-widget .bib1s-event-lock {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  padding: 0.35em;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  font-size: 0.45em;
}

.bib1s-widget .bib1s-event-info {
  padding: 0.9em 1em 1em;
}

.bib1s-widget .bib1s-event-name {
  margin: 0 0 0.4em;
  padding: 0;
  font-size: 1.05em;
  line-height: 1.35;
}

.bib1s-widget .bib1s-event-info .bib1s-meta {
  flex-direction: column;
  gap: 0.2em;
  font-size: 0.85em;
}

/* ---------- lightbox ---------- */

.bib1s-noscroll {
  overflow: hidden !important;
}

.bib1s-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: none;
  background: rgba(2, 6, 23, 0.97);
  color: #fff;
  font-size: 15px;
}

.bib1s-lightbox.is-open {
  display: block;
}

.bib1s-lightbox .bib1s-lb-stage {
  position: absolute;
  inset: 56px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px 16px;
}

.bib1s-lightbox .bib1s-lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
}

.bib1s-lightbox .bib1s-lb-bar {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  height: 56px;
  padding: 0 12px;
}

.bib1s-lightbox .bib1s-lb-counter {
  margin-right: auto;
  padding-left: 6px;
  opacity: 0.8;
  font-size: 0.9em;
}

.bib1s-lightbox .bib1s-lb-action,
.bib1s-lightbox .bib1s-lb-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  text-transform: none;
  box-shadow: none;
  cursor: pointer;
}

.bib1s-lightbox .bib1s-lb-action {
  height: 38px;
  padding: 0 14px;
}

.bib1s-lightbox .bib1s-lb-close {
  width: 38px;
  padding: 0;
}

.bib1s-lightbox .bib1s-lb-action:hover,
.bib1s-lightbox .bib1s-lb-nav:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.bib1s-lightbox .bib1s-lb-nav {
  position: absolute;
  top: 50%;
  width: 46px;
  height: 46px;
  padding: 0;
  font-size: 1.3em;
  transform: translateY(-50%);
}

.bib1s-lightbox .bib1s-lb-nav:disabled {
  opacity: 0.25;
  cursor: default;
}

.bib1s-lightbox .bib1s-lb-prev {
  left: 12px;
}

.bib1s-lightbox .bib1s-lb-next {
  right: 12px;
}

/* ---------- điện thoại ---------- */

@media (max-width: 600px) {
  .bib1s-widget {
    --bib1s-thumb-min: 105px;
    --bib1s-gap: 4px;
  }

  .bib1s-widget .bib1s-title {
    font-size: 1.35em;
  }

  .bib1s-widget .bib1s-tab {
    flex: 1;
    padding: 0.7em 0.5em;
  }

  .bib1s-widget .bib1s-pagination {
    flex-direction: column;
  }

  .bib1s-widget .bib1s-tab-full {
    display: none;
  }

  .bib1s-widget .bib1s-tab-short {
    display: inline;
  }

  /* Vuốt để chuyển ảnh, ẩn nút mũi tên cho khỏi che ảnh */
  .bib1s-lightbox .bib1s-lb-nav {
    display: none;
  }

  .bib1s-lightbox .bib1s-lb-stage {
    padding: 0 0 16px;
  }
}
