/*Gallery*/

/* Album grid fills the full card width */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  width: 100%;
  margin-top: 12px;
}

/* Individual tiles */
.album-grid .gallery-item {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.album-grid .gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45);
}

/* Image fit */
.album-grid .gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 4 / 3; /* uniform rows */
}

/* Action bar on hover (kept if you already use it) */
.gallery-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 0.2s,
    transform 0.2s;
}
.gallery-item:hover .gallery-actions {
  opacity: 1;
  transform: translateY(0);
}
.gallery-actions a,
.gallery-actions button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.gallery-actions a:hover,
.gallery-actions button:hover {
  background: var(--btn-primary);
}
.gallery-actions img {
  width: 22px;
  height: 22px;
  filter: invert(1);
  pointer-events: none;
}

/* Empty state centered nicely */
.hidden {
  display: none !important;
}
.album-empty {
  min-height: 30vh;
  display: grid;
  place-items: center;
}

.gallery-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  position: relative;
  margin-bottom: 20px;
}

.gallery-title {
  font-size: 1.6rem;
  margin: 0;
}

/* ---------- Storage Meter ---------- */
.storage-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 350px;
}

.storage-bar {
  flex: 1;
  background: #2c2c2c;
  border-radius: 6px;
  height: 12px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

.storage-bar span {
  display: block;
  height: 100%;
  background: var(--brand-2);
  border-radius: 6px;
  transition: width 0.3s ease;
}

#storageText {
  font-size: 0.85rem;
  color: #ccc;
  min-width: 90px;
}

.gallery-tools {
  position: absolute;
  right: 0;
  top: 0;
  display: flex;
  gap: 10px;
}

/* ----------- Mobile Fix ----------- */
@media (max-width: 768px) {
  .gallery-head {
    align-items: stretch;
  }

  .gallery-tools {
    position: static;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .gallery-tools .btn {
    flex: 1;
    min-width: 120px;
  }

  .storage-meter {
    max-width: 100%;
  }
}

.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.2s ease;
}
.icon-btn img {
  width: 33px;
  height: 33px;
}
.icon-btn.danger img {
  filter: invert(27%) sepia(97%) saturate(7483%) hue-rotate(356deg)
    brightness(96%) contrast(112%);
}
.icon-btn:hover {
  background: rgba(255, 0, 0, 0.08);
}

/* ---------- Gallery toolbar ---------- */
.gallery-toolbar .toolbar-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.gallery-toolbar .input {
  background: #1c1f26;
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 140px;
  outline: none;
}
.gallery-toolbar .input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px #00eaff33;
}
.gallery-toolbar .toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}
.gallery-toolbar .bulk-wrap {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ---------- Selection mode ---------- */
.select-mode .gallery-item {
  outline: 2px dashed rgba(0, 149, 255, 0.25);
}
.select-check {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 3;
  display: none;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  align-items: center;
  justify-content: center;
}
.select-mode .select-check {
  display: flex;
}
.select-check input {
  width: 18px;
  height: 18px;
}

/* ---------- Viewer ---------- */
.viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  z-index: 1200;
}
.viewer[hidden] {
  display: none;
}
.viewer-inner {
  position: relative;
  width: min(1000px, 94vw);
  max-height: 92vh;
  background: #121418;
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 12px;
}
.viewer-close {
  position: absolute;
  right: 10px;
  top: 10px;
  border: 0;
  background: #222;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 8px;
}
.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: #222;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
.viewer-nav.prev {
  left: 10px;
}
.viewer-nav.next {
  right: 10px;
}

#viewerImg {
  width: 100%;
  height: calc(92vh - 120px);
  object-fit: contain;
  background: #0d0f12;
  border-radius: 10px;
}
.viewer-meta {
  display: grid;
  gap: 10px;
}
.viewer-meta .input {
  background: #1c1f26;
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
.viewer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.btn-danger {
  background: var(--danger);
  color: #fff;
  border: 0;
}
.btn-danger:hover {
  filter: brightness(1.1);
}
