/* ═══════════════════════════════════════════════════════════════
   EDSS Google Drive Folder Browser
   ═══════════════════════════════════════════════════════════════ */

/* ── iframe wrapper ──────────────────────────────────────────── */
.edss-drive-iframe-wrap {
    width: 100%;
    overflow: hidden;
    border-radius: 4px;
}

/* ── Browser shell ───────────────────────────────────────────── */
.edss-drive-browser {
    font-size: 0.875rem;
    color: #202124;
    box-sizing: border-box;
    /* Folder color theme variables (override per [data-theme]) */
    --edb-folder-color:    #f6a623;
    --edb-folder-hover-bg: #fff8e1;
    --edb-folder-shadow:   rgba(246, 166, 35, 0.18);
}

.edss-drive-browser *,
.edss-drive-browser *::before,
.edss-drive-browser *::after {
    box-sizing: inherit;
}

/* ── Breadcrumb ──────────────────────────────────────────────── */
.edb-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 4px;
    padding: 0 0 12px;
    font-size: 0.8125rem;
}

.edb-bc-item {
    display: inline-flex;
    align-items: center;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edb-bc-link {
    background: none;
    border: none;
    padding: 3px 6px;
    border-radius: 4px;
    color: #1a73e8;
    cursor: pointer;
    font-size: inherit;
    transition: background 0.15s;
    text-align: left;
}

.edb-bc-link:hover {
    background: #e8f0fe;
    text-decoration: underline;
}

.edb-bc-sep {
    color: #888;
    pointer-events: none;
    user-select: none;
}

.edb-bc-current {
    color: #202124;
    font-weight: 500;
    padding: 3px 6px;
}

/* ── Loading / Error / Empty ─────────────────────────────────── */
.edb-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 40px 16px;
    color: #5f6368;
}

.edb-spinner {
    display: inline-block;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: 3px solid #e0e0e0;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: edb-spin 0.8s linear infinite;
}

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

.edb-error {
    padding: 16px;
    color: #c62828;
    background: #ffebee;
    border-radius: 6px;
    margin: 8px 0;
}

.edb-empty {
    padding: 24px 16px;
    color: #5f6368;
    font-style: italic;
}

/* ── Items container ─────────────────────────────────────────── */
.edb-items {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* ── Grid layout ─────────────────────────────────────────────── */
.edb-grid {
    display: grid;
    grid-template-columns: repeat(var(--edb-cols, 3), 1fr);
    gap: 16px;
}

@media (max-width: 768px) {
    .edb-grid {
        grid-template-columns: repeat(var(--edb-cols-mobile, 2), 1fr);
    }
}

/* ── List layout ─────────────────────────────────────────────── */
.edb-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.edb-list .edb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.edb-list .edb-item:hover,
.edb-list .edb-item:focus-visible {
    background: #f1f3f4;
    outline: none;
}

.edb-list .edb-thumb {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 4px;
    background-size: cover;
    background-position: center;
}

/* ── Shared item styles (grid) ───────────────────────────────── */
.edb-grid .edb-item {
    cursor: pointer;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.15s, transform 0.15s;
}

.edb-grid .edb-item:hover,
.edb-grid .edb-item:focus-visible {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
    outline: none;
}

/* ── Thumbnail (square aspect, grid) ─────────────────────────── */
.edb-grid .edb-thumb {
    width: 100%;
    padding-bottom: 100%;
    position: relative;
    background: #f8f9fa center / cover no-repeat;
}

/* ── Folders section (grid, same columns as files) ──────────── */
.edb-folders-section {
    margin-bottom: 14px;
}

/* Folder item and back button share identical base styles */
.edb-folder-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    background: #fff;
    text-align: center;
    min-height: 80px;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.edb-folder-item:hover,
.edb-folder-item:focus-visible {
    background: var(--edb-folder-hover-bg, #fff8e1);
    border-color: var(--edb-folder-color, #f6a623);
    box-shadow: 0 2px 8px var(--edb-folder-shadow, rgba(246,166,35,0.18));
    outline: none;
}

.edb-folder-item svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    color: var(--edb-folder-color, #f6a623);
}

.edb-folder-item-name {
    font-weight: 700;
    font-size: 0.825rem;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
    width: 100%;
}

/* Back button overrides */
.edb-back-item {
    border-color: #bbb;
    border-width: 2.5px;
    background: #f5f5f5;
}

.edb-back-item:hover,
.edb-back-item:focus-visible {
    background: #ebebeb;
    border-color: #888;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.edb-back-item svg {
    color: #555;
}

.edb-back-item .edb-folder-item-name {
    font-weight: 700;
    color: #444;
}

/* Folder meta (date) in folder items */
.edb-folder-item .edb-meta {
    padding: 0;
    background: transparent;
    font-size: 0.7rem;
    color: #999;
    white-space: nowrap;
}

/* ── File thumbnail ──────────────────────────────────────────── */
.edb-file-thumb {
    background: #e8f0fe !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.edb-grid .edb-file-thumb img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.edb-grid .edb-file-icon,
.edb-photo-no-thumb {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.4rem;
}

/* ── Item name ───────────────────────────────────────────────── */
.edb-grid .edb-name {
    padding: 7px 10px 8px;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-top: 1px solid #f1f3f4;
    background: #fff;
}

.edb-list .edb-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.875rem;
}

/* ══════════════════════════════════════════════════════════════
   Lightbox
   ══════════════════════════════════════════════════════════════ */

.edss-lb {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}

.edss-lb.edss-lb-open {
    display: flex;
}

/* overlay */
.edss-lb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    cursor: zoom-out;
}

/* dialog */
.edss-lb-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 96vw;
    max-width: 1200px;
    max-height: 96vh;
    background: #181818;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* ── Toolbar ─────────────────────────────────────────────────── */
.edss-lb-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.45);
    flex-shrink: 0;
}

.edss-lb-counter {
    flex: 1;
    font-size: 0.8rem;
    color: #bbb;
}

.edss-lb-download {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    background: #1a73e8;
    color: #fff !important;
    border-radius: 5px;
    font-size: 0.8rem;
    text-decoration: none !important;
    transition: background 0.15s;
    white-space: nowrap;
}

.edss-lb-download:hover {
    background: #1557b0;
}

.edss-lb-close {
    background: none;
    border: none;
    color: #ccc;
    font-size: 1.5rem;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.edss-lb-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* ── Stage ───────────────────────────────────────────────────── */
.edss-lb-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: stretch;
}

.edss-lb-imgwrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    overflow: hidden;
}

.edss-lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 3px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
}

/* ── Prev / Next ─────────────────────────────────────────────── */
.edss-lb-prev,
.edss-lb-next {
    flex-shrink: 0;
    width: 52px;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: #fff;
    font-size: 2.2rem;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.edss-lb-prev:hover,
.edss-lb-next:hover {
    background: rgba(255, 255, 255, 0.18);
}

.edss-lb-prev:disabled,
.edss-lb-next:disabled {
    opacity: 0.2;
    cursor: default;
}

@media (max-width: 600px) {
    .edss-lb-prev,
    .edss-lb-next {
        width: 38px;
        font-size: 1.6rem;
    }
}

/* ── Caption ─────────────────────────────────────────────────── */
.edss-lb-caption {
    flex-shrink: 0;
    padding: 5px 16px;
    font-size: 0.78rem;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(0, 0, 0, 0.3);
}

/* ── Filmstrip ───────────────────────────────────────────────── */
.edss-lb-strip {
    display: flex;
    gap: 5px;
    padding: 8px 12px;
    overflow-x: auto;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.35);
    scrollbar-width: thin;
    scrollbar-color: #555 transparent;
}

.edss-lb-strip::-webkit-scrollbar {
    height: 4px;
}

.edss-lb-strip::-webkit-scrollbar-track {
    background: transparent;
}

.edss-lb-strip::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 2px;
}

.edss-lb-strip-item {
    flex-shrink: 0;
    width: 62px;
    height: 62px;
    border: 2px solid transparent;
    border-radius: 5px;
    background: #333 center / cover no-repeat;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.15s, border-color 0.15s;
    padding: 0;
}

.edss-lb-strip-item:hover {
    opacity: 0.85;
}

.edss-lb-strip-item.edss-lb-strip-active {
    border-color: #1a73e8;
    opacity: 1;
}

/* ── Body scroll lock ────────────────────────────────────────── */
body.edss-lb-body-open {
    overflow: hidden;
}

/* ── Item metadata (date / size) ─────────────────────────────── */
.edb-meta {
    padding: 2px 10px 7px;
    font-size: 0.7rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #fff;
}

.edb-list .edb-meta {
    padding: 0;
    font-size: 0.75rem;
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 8px;
}

.edb-meta-date,
.edb-meta-size {
    display: inline;
}

.edb-meta-sep {
    color: #bbb;
}

/* ══════════════════════════════════════════════════════════════
   Color Themes  [data-theme="..."]
   Applies to: folder icon, folder hover bg/border/shadow
   Usage: [edss_drive_folder theme="blue"]
   ══════════════════════════════════════════════════════════════ */

/* blue ──────────────────────────────────────────────────────── */
.edss-drive-browser[data-theme="blue"] {
    --edb-folder-color:    #1a73e8;
    --edb-folder-hover-bg: #e8f0fe;
    --edb-folder-shadow:   rgba(26, 115, 232, 0.18);
}

/* green ─────────────────────────────────────────────────────── */
.edss-drive-browser[data-theme="green"] {
    --edb-folder-color:    #34a853;
    --edb-folder-hover-bg: #e6f4ea;
    --edb-folder-shadow:   rgba(52, 168, 83, 0.18);
}

/* purple ────────────────────────────────────────────────────── */
.edss-drive-browser[data-theme="purple"] {
    --edb-folder-color:    #7c3aed;
    --edb-folder-hover-bg: #ede9fe;
    --edb-folder-shadow:   rgba(124, 58, 237, 0.18);
}

/* red ───────────────────────────────────────────────────────── */
.edss-drive-browser[data-theme="red"] {
    --edb-folder-color:    #e53935;
    --edb-folder-hover-bg: #ffebee;
    --edb-folder-shadow:   rgba(229, 57, 53, 0.18);
}

/* gray ──────────────────────────────────────────────────────── */
.edss-drive-browser[data-theme="gray"] {
    --edb-folder-color:    #5f6368;
    --edb-folder-hover-bg: #f1f3f4;
    --edb-folder-shadow:   rgba(95, 99, 104, 0.18);
}
