:root {
  --gallery-backdrop: rgba(15, 23, 42, 0.55);
}

.hidden {
  display: none !important;
}

.gallery-auth {
  position: fixed;
  top: 1.05rem;
  right: 1.05rem;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.gallery-auth-email {
  font-size: 0.88rem;
  color: var(--text-muted);
  max-width: min(60vw, 340px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.galerie {
  width: 100%;
  max-width: 1300px;
  margin: 0.75rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.gallery-wall-container {
  max-width: 1380px;
}

.gallery-toolbar {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.gallery-filters {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.gallery-filters .btn-secondary.is-active {
  background: rgba(252, 222, 2, 0.92);
  border-color: rgba(252, 222, 2, 0.92);
  color: #111827;
}

.gallery-filters .btn-secondary.is-active:hover {
  background: rgba(252, 222, 2, 0.98);
  border-color: rgba(252, 222, 2, 0.98);
}

.item {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  box-shadow: none;
}

.gallery-badges {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 2;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.gallery-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.55);
  color: rgba(226, 232, 240, 0.95);
  backdrop-filter: blur(10px);
}

.gallery-badge-locked {
  border-color: rgba(249, 115, 22, 0.35);
  background: rgba(249, 115, 22, 0.14);
  color: #fdba74;
}

.gallery-badge-video {
  border-color: rgba(252, 222, 2, 0.35);
  background: rgba(252, 222, 2, 0.14);
  color: rgba(252, 222, 2, 0.92);
}

.modal-link {
  display: block;
  width: 100%;
  height: 100%;
}

.item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1);
  transition: transform var(--transition-fast);
  -webkit-user-drag: none;
  user-select: none;
}

.item:hover img {
  transform: scale(1.02);
}

@media (max-width: 520px) {
  .galerie {
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 7px;
  }
}

#modal {
  display: none;
  position: fixed;
  z-index: 9999;
  inset: 0;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.9);
}

#modal:not(.hidden) {
  display: block;
}

.modal-image-wrap {
  position: relative;
  width: min(1200px, 92vw);
  margin: 100px auto 0;
  animation: gallery-modal-in 180ms ease-out;
}

.modal-actions {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 2;
}

.modal-actions-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.85rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(10px);
}

.modal-content {
  display: block;
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: #000000;
}

.close {
  color: #f1f1f1;
  position: absolute;
  top: 15px;
  right: 35px;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
  cursor: pointer;
  user-select: none;
}

.close:hover,
.close:focus {
  color: #bbb;
  text-decoration: none;
  cursor: pointer;
}

.gallery-protect-layer {
  position: absolute;
  inset: 0;
  background: transparent;
}

@keyframes gallery-modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.admin-gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.admin-gallery-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.admin-gallery-form input[type="file"] {
  background: var(--bg-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem;
  color: var(--text-main);
}

.admin-gallery-item {
  cursor: grab;
}

.admin-gallery-item.is-dragging {
  opacity: 0.75;
  cursor: grabbing;
  box-shadow: 0 0 0 2px rgba(252, 222, 2, 0.25);
}

.admin-reorder-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.admin-caption-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.admin-caption-input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.65rem;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-soft);
  color: var(--text-main);
}

.admin-gallery-item .btn-ghost {
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
}

.admin-gallery-item .thumbnail-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.admin-gallery-item .thumbnail-actions > form {
  margin-left: auto;
}

.admin-caption-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(252, 222, 2, 0.25);
  border-color: rgba(252, 222, 2, 0.65);
}

.badge-success {
  background: rgba(34, 197, 94, 0.18);
  color: #bbf7d0;
}

.badge-warning {
  background: rgba(249, 115, 22, 0.16);
  color: #fdba74;
}

.admin-table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

.admin-table thead th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
}

.admin-table tbody td {
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid rgba(55, 65, 81, 0.65);
  color: var(--text-main);
  font-size: 0.88rem;
}

.admin-table tbody tr:hover {
  background: rgba(252, 222, 2, 0.05);
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

/* Admin Users Management */
.admin-search-input {
  width: 100%;
  max-width: 400px;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-soft);
  color: var(--text-main);
  font-size: 0.9rem;
}

.admin-search-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(252, 222, 2, 0.25);
  border-color: rgba(252, 222, 2, 0.65);
}

.btn-toggle-access {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(249, 115, 22, 0.12);
  color: #fdba74;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-toggle-access:hover {
  background: rgba(249, 115, 22, 0.22);
}

.btn-toggle-access.is-granted {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
}

.btn-toggle-access.is-granted:hover {
  background: rgba(34, 197, 94, 0.25);
}

.btn-toggle-access:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-small {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

/* Media Access Modal */
.media-access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.media-access-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  overflow: hidden;
}

.media-access-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem;
  cursor: pointer;
  gap: 0.5rem;
}

.media-access-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.media-access-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.media-access-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Access Info Box */
.access-info-box {
  text-align: center;
  padding: 1.5rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
}

.access-denied-text {
  font-size: 1.1rem;
  color: #fdba74;
  margin: 0.5rem 0;
}

.panel-help {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
