/* ---------- Gallery (Masonry, no-crop) ---------- */
.gdrive-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    grid-auto-rows: 6px;
    grid-auto-flow: dense;
    gap: 12px;
    margin: 10px 0;
    justify-items: stretch;
}

/* Items */
.gdrive-gallery-item {
    position: relative;
    overflow: visible;
    border-radius: 2px;
    cursor: pointer;
    transition: box-shadow 0.1s ease;
    width: 100%;
    background: transparent;
    padding: 0;
}

.gdrive-gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 3px;
}

/* ----- Folder thumbnail wrapper (keeps icon size sane) ----- */
.gdrive-folder-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;          /* consistent box for the folder icon */
    display: grid;
    place-items: center;
}

/* Folder icon sizing (overrides generic img rule above for folder icons only) */
.gdrive-folder-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;             /* no crop */
    max-width: 220px;                /* desktop cap to avoid giant icons */
    border-radius: 0;                /* folder svg is flat */
}

/* ----- Folder label below the icon ----- */
.gdrive-folder-name {
    margin: 5px;
    font-size: 12px;
    font-weight: bold;
    line-height: 1.35;
    text-align: left;
    color: #222;
    padding: 0 10px;
    word-break: break-word;
}

/* ----- Count badge (rendered inside .gdrive-folder-thumb by JS) ----- */
/* Reset legacy blocky label styles… */
.gdrive-count-name {
    font-size: 11px;
    font-weight: normal;
    line-height: 1.35;
    color: #fff;
    word-break: break-word;
}
/* …and place it as a small badge on the icon */
.gdrive-folder-thumb .gdrive-count-name {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: rgba(0,0,0,.65);
    border-radius: 999px;
    padding: 3px 8px;
    margin: 0;           /* override previous margin */
    width: auto;         /* override previous width */
    text-align: left;
}

/* (Kept for backward compatibility; not used by current JS) */
.gdrive-folder-count-badge {
    position: absolute;
    right: 8px; bottom: 8px;
    color: #000;
    padding: 2px 10px;
    font-size: 12px;
    border-radius: 10px;
    line-height: 1.2;
    pointer-events: none;
}

/* ---------- Lightbox ---------- */
.gdrive-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999999;
}
.gdrive-lightbox img { max-width: 90%; max-height: 90%; position: relative; z-index: 10; }
.gdrive-lightbox .close-btn {
    position: absolute; top: 20px; right: 20px; font-size: 28px; color: #fff; cursor: pointer;
}
.gdrive-lightbox .download-btn {
    position: absolute; top: 20px; right: 110px;
    background: rgba(255, 0, 0, 0.85); color: #fff;
    padding: 2px 5px; font-size: 12px; border-radius: 5px; font-weight: 700;
    box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
.gdrive-lightbox .prev-btn, .gdrive-lightbox .next-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    font-size: 40px; color: #fff; cursor: pointer; padding: 10px;
    z-index: 99999999 !important;
}
.gdrive-lightbox .prev-btn { left: 10px; }
.gdrive-lightbox .next-btn { right: 10px; }
@supports(padding: max(0px)) {
  .gdrive-lightbox .prev-btn { left: max(10px, env(safe-area-inset-left)) !important; }
  .gdrive-lightbox .next-btn { right: max(10px, env(safe-area-inset-right)) !important; }
}

/* ---------- Lazyload ---------- */
.lazyload  { opacity: 0; transition: opacity 0.4s; }
.lazyloaded { opacity: 1; transition: opacity 0.4s ease-in; }

/* ---------- Spinner ---------- */
.gdrive-spinner {
    border: 6px solid #f3f3f3;
    border-top: 6px solid #555;
    border-radius: 50%;
    width: 60px; height: 60px;
    animation: spin 1s linear infinite;
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999; display: none;
}
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* ---------- Image overlay Download ---------- */
.gdrive-download-btn {
    position: absolute; top: 8px; right: 8px;
    background: rgba(255, 0, 0, 0.85); color: #fff;
    padding: 2px 5px; border-radius: 5px; font-size: 12px; font-weight: 700;
    text-decoration: none; opacity: 0; transition: opacity .2s, transform .15s; z-index: 10;
}
.gdrive-gallery-item:hover .gdrive-download-btn { opacity: 1; transform: scale(1.06); }

/* --- Lightbox share bar --- */
.gd-share-bar{
  position:absolute;
  top:20px; left:20px;
  display:flex; gap:8px;
  z-index:9999999 !important;
}
.gd-share{
  width:34px; height:34px;
  border-radius:50%; border:none;
  display:inline-flex; align-items:center; justify-content:center;
  cursor:pointer; box-shadow:0 2px 8px rgba(0,0,0,.25);
}
.gd-share svg { width:18px; height:18px; }
/* brand colors */
.gd-wa{ background:#25D366; }
.gd-fb{ background:#1877F2; }
.gd-ig{ background:#E1306C; }

/* small toast */
.gd-toast{
  position:absolute; bottom:24px; left:50%; transform:translateX(-50%);
  background:rgba(0,0,0,.8); color:#fff; font-size:12px;
  padding:6px 10px; border-radius:6px; opacity:0; pointer-events:none;
  transition:opacity .2s ease; z-index:999999;
}
.gd-toast.show{ opacity:1; }

/* ---------- Responsive tweaks (mobile folder icon size) ---------- */
@media (max-width: 640px) {
  .gdrive-gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    grid-auto-rows: 6px;
  }

  .gdrive-folder-thumb {
    aspect-ratio: 4 / 3;          /* a bit taller on phones */
  }

  .gdrive-folder-thumb img {
    max-width: 160px;             /* cap icon size on mobile */
  }

  .gdrive-count-name,
  .gdrive-folder-thumb .gdrive-count-name {
    font-size: 11px;
    padding: 3px 7px;
    right: 6px;
    bottom: 6px;
  }

  .gdrive-folder-name {
    font-size: 13px;
  }
}

@media (max-width: 400px) {
  .gdrive-gallery {
    grid-template-columns: repeat(2, 1fr);
  }
  .gdrive-folder-thumb img {
    max-width: 140px;             /* extra small phones */
  }
}

.gdrive-load-more-btn {
    display: block;
    margin: 30px auto;
    padding: 12px 30px;
    background: #e60000; /* Matching your red download button */
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    clear: both;
}
.gdrive-load-more-btn:hover { background: #cc0000; }
.gdrive-load-more-btn:disabled { background: #999; cursor: not-allowed; }