/* ══════════════════════════════════════════
   Gallery Page
   ══════════════════════════════════════════ */

.gallery-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ── Header row ── */
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.gallery-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}
.gallery-header p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 4px 0 0;
}
.gallery-upload-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 11px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.gallery-upload-btn:hover { background: #4f46e5; transform: translateY(-1px); }

/* ── Upload modal ── */
.gallery-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.gallery-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.gallery-modal h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}
.gallery-drop-zone {
  border: 2px dashed var(--border);
  border-radius: 13px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}
.gallery-drop-zone:hover,
.gallery-drop-zone.dragover {
  border-color: #6366f1;
  background: #6366f108;
}
.gallery-drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.gallery-drop-icon { font-size: 2rem; margin-bottom: 8px; }
.gallery-drop-text { font-size: 0.88rem; color: var(--text-muted); }
.gallery-drop-text strong { color: var(--text); }
.gallery-preview-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
  display: none;
}
.gallery-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
}
.gallery-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text);
  resize: none;
  font-family: inherit;
}
.gallery-input:focus { outline: none; border-color: #6366f1; }
.gallery-modal-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.gallery-btn-cancel {
  background: var(--border);
  color: var(--text);
  border: none;
  border-radius: 9px;
  padding: 9px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.gallery-btn-save {
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 9px 20px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  min-width: 100px;
}
.gallery-btn-save:disabled { opacity: .6; cursor: not-allowed; }
.gallery-size-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
}
.gallery-error {
  font-size: 0.8rem;
  color: #ef4444;
  background: #ef444415;
  border-radius: 8px;
  padding: 8px 12px;
  display: none;
}

/* ── Gallery grid ── */
.gallery-grid {
  columns: 3;
  column-gap: 14px;
}
@media (max-width: 680px) { .gallery-grid { columns: 2; } }
@media (max-width: 400px) { .gallery-grid { columns: 1; } }

.gallery-item {
  break-inside: avoid;
  margin-bottom: 14px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.gallery-item img {
  width: 100%;
  display: block;
  object-fit: cover;
}
.gallery-item-info {
  padding: 10px 12px 12px;
}
.gallery-item-caption {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}
.gallery-item-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.gallery-item-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.gallery-item-delete {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0;
  display: none;
}
.gallery-item:hover .gallery-item-delete { display: inline; }

/* ── Lightbox ── */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 24px;
  gap: 16px;
}
.gallery-lightbox img {
  max-width: 90vw;
  max-height: 72vh;
  border-radius: 12px;
  object-fit: contain;
}
.gallery-lightbox-caption {
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}
.gallery-lightbox-desc {
  color: rgba(255,255,255,.7);
  font-size: 0.85rem;
  text-align: center;
  max-width: 500px;
}
.gallery-lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  font-size: 1.4rem;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Empty state ── */
.gallery-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.gallery-empty-icon { font-size: 3rem; margin-bottom: 12px; }
.gallery-empty-text { font-size: 0.95rem; }

/* ── Loading skeleton ── */
.gallery-skeleton {
  columns: 3;
  column-gap: 14px;
}
@media (max-width: 680px) { .gallery-skeleton { columns: 2; } }
.gallery-skel-item {
  break-inside: avoid;
  margin-bottom: 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.gallery-skel-img {
  width: 100%;
  height: 160px;
  background: var(--border);
  animation: gallerySkelPulse 1.4s ease-in-out infinite;
}
.gallery-skel-text {
  height: 12px;
  border-radius: 6px;
  background: var(--border);
  margin: 12px;
  animation: gallerySkelPulse 1.4s ease-in-out infinite;
}
.gallery-skel-text.short { width: 55%; }
@keyframes gallerySkelPulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
