/* ================================================================
   Simple GDrive Embed v2  — Public Styles
   ================================================================ */

/* ── Outer wrapper ───────────────────────────────────────────────── */
.sgde-browser {
    display: flex;
    flex-direction: column;
    font-family: "Google Sans", Roboto, Arial, sans-serif;
    font-size: 14px;
    color: #3c4043;
    background: #fff;
    border: 1px solid #dadce0;
    box-shadow: 0 1px 6px rgba(60, 64, 67, .12);
    overflow: hidden;
    box-sizing: border-box;
    margin: 1.25em 0;
    position: relative;
}

/* ── Optional title bar ──────────────────────────────────────────── */
.sgde-title-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #dadce0;
    font-weight: 500;
    font-size: 0.95rem;
    color: #3c4043;
}
.sgde-title-icon { color: #fbbc04; display: flex; align-items: center; }
.sgde-title-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ── Toolbar (back + breadcrumb) ─────────────────────────────────── */
.sgde-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-bottom: 1px solid #e8eaed;
    background: #f8f9fa;
    min-height: 38px;
}

.sgde-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    background: #fff;
    color: #444;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}
.sgde-back-btn:hover:not(:disabled) {
    background: #e8f0fe;
    border-color: #1a73e8;
    color: #1a73e8;
}
.sgde-back-btn:disabled {
    opacity: 0.38;
    cursor: default;
}

.sgde-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    font-size: 13px;
    color: #5f6368;
    overflow: hidden;
    min-width: 0;
}
.sgde-crumb {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.sgde-crumb:last-child { color: #3c4043; font-weight: 500; }
.sgde-sep { padding: 0 2px; color: #9aa0a6; }

/* ── Listing area ────────────────────────────────────────────────── */
.sgde-listing {
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* ── Items ───────────────────────────────────────────────────────── */
.sgde-items {
    list-style: none;
    margin: 0;
    padding: 4px 0;
}

.sgde-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid transparent;
    user-select: none;
}
.sgde-item:hover { background: #f1f3f4; }
.sgde-item:active { background: #e8f0fe; }

.sgde-item-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* Icon colours by type */
.sgde-item-folder .sgde-item-icon { color: #5f6368; }
.sgde-item-folder .sgde-item-icon svg path { fill: #fbbc04; }
.sgde-item-doc    .sgde-item-icon { color: #4285f4; }
.sgde-item-sheet  .sgde-item-icon { color: #34a853; }
.sgde-item-slides .sgde-item-icon { color: #ea4335; }
.sgde-item-file   .sgde-item-icon { color: #5f6368; }

.sgde-item-name {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13.5px;
}

.sgde-item-meta {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-shrink: 0;
}

.sgde-meta {
    font-size: 12px;
    color: #80868b;
    white-space: nowrap;
}

/* ── States ──────────────────────────────────────────────────────── */
.sgde-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px;
    color: #5f6368;
    font-size: 14px;
}

.sgde-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #e8eaed;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: sgde-spin 0.8s linear infinite;
}
@keyframes sgde-spin { to { transform: rotate(360deg); } }

.sgde-empty, .sgde-error-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    color: #5f6368;
    font-size: 14px;
    text-align: center;
}
.sgde-error-msg { color: #c5221f; }

/* ── Credit link ─────────────────────────────────────────────────── */
.sgde-credit {
    margin: 0;
    padding: 6px 14px;
    background: #f8f9fa;
    border-top: 1px solid #e8eaed;
    font-size: 12px;
    text-align: right;
}
.sgde-credit a {
    color: #5f6368;
    text-decoration: none;
}
.sgde-credit a:hover {
    color: #1a73e8;
    text-decoration: underline;
}

/* ── Modal ───────────────────────────────────────────────────────── */
.sgde-modal {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}
.sgde-modal[hidden] { display: none; }

.sgde-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
}

.sgde-modal-box {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    width: min(90vw, 1024px);
    height: min(85vh, 800px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sgde-modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
    cursor: pointer;
    color: #444;
    transition: background 0.15s;
}
.sgde-modal-close:hover { background: #f1f3f4; color: #c5221f; }

.sgde-modal-iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* ── Admin error ─────────────────────────────────────────────────── */
.sgde-error {
    border-left: 4px solid #d93025;
    background: #fce8e6;
    padding: 10px 14px;
    font-size: 0.875rem;
    color: #c5221f;
    border-radius: 4px;
    margin: 1em 0;
}

/* ── Dark mode ───────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .sgde-browser {
        background: #202124;
        border-color: #3c4043;
        color: #e8eaed;
    }
    .sgde-title-bar, .sgde-toolbar {
        background: #292a2d;
        border-color: #3c4043;
    }
    .sgde-item:hover  { background: #2d2f31; }
    .sgde-item:active { background: #35363a; }
    .sgde-back-btn {
        background: #292a2d;
        border-color: #5f6368;
        color: #e8eaed;
    }
    .sgde-back-btn:hover:not(:disabled) {
        background: #1a3551;
        border-color: #8ab4f8;
        color: #8ab4f8;
    }
    .sgde-crumb:last-child { color: #e8eaed; }
    .sgde-credit {
        background: #292a2d;
        border-color: #3c4043;
    }
    .sgde-credit a { color: #9aa0a6; }
    .sgde-credit a:hover { color: #8ab4f8; }
    .sgde-modal-box { background: #292a2d; }
    .sgde-modal-close {
        background: rgba(41, 42, 45, 0.9);
        color: #e8eaed;
    }
    .sgde-modal-close:hover { background: #3c4043; color: #f28b82; }
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 560px) {
    .sgde-item-meta { display: none; }

    .sgde-browser {
        border-left: none;
        border-right: none;
        border-radius: 0 !important;
        margin-left: calc(-1 * var(--wp--style--block-gap, 1em));
        margin-right: calc(-1 * var(--wp--style--block-gap, 1em));
    }

    .sgde-modal-box {
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
    }
}
