/* ============================================================
   Launchpad Document Library – Frontend Styles
   Brand palette: #1487cb blue / #c4e9f3 light blue
                  #CA1A76 pink / #fad3e9 light pink
   Fonts: inherited from theme globals
   ============================================================ */

:root {
    /* ── Brand colours ───────────────────────────────────────── */
    --ldl-blue:      #1487cb;
    --ldl-blue-lt:   #c4e9f3;
    --ldl-blue-dk:   #0f6ba3;
    --ldl-pink:      #CA1A76;
    --ldl-pink-lt:   #fad3e9;
    --ldl-pink-dk:   #a3155e;

    /* ── Neutrals ────────────────────────────────────────────── */
    --ldl-dark:      #1a2744;
    --ldl-slate:     #4a5568;
    --ldl-mid:       #6b7280;
    --ldl-border:    #d1d9e0;
    --ldl-bg:        #f4fafd;
    --ldl-white:     #ffffff;

    /* ── Shadows ─────────────────────────────────────────────── */
    --ldl-shadow:    0 2px 8px rgba(20,135,203,.12);
    --ldl-shadow-md: 0 4px 16px rgba(20,135,203,.18);

    /* ── Misc ────────────────────────────────────────────────── */
    --ldl-radius:    10px;
    --ldl-red:       #c0392b;
}

/* ── Wrapper ──────────────────────────────────────────────── */
.ldl-library {
    color: var(--ldl-dark);
    max-width: 1100px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* ── Header ───────────────────────────────────────────────── */
.ldl-library-header {
    margin-bottom: 28px;
}
.ldl-library-title {
    
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--ldl-blue);
    margin: 0 0 8px;
}
.ldl-library-description {
    color: var(--ldl-slate);
    font-size: .95rem;
    margin-bottom: 20px;
}
.ldl-library-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* ── Search ───────────────────────────────────────────────── */
.ldl-search-wrap {
    flex: 1;
    min-width: 200px;
}
.ldl-search-input {
    width: 100%;
    padding: 10px 16px;
    border: 2px solid var(--ldl-border);
    border-radius: 8px;
    
    font-size: .95rem;
    color: var(--ldl-dark);
    background: var(--ldl-white);
    transition: border-color .2s;
}
.ldl-search-input:focus {
    outline: none;
    border-color: var(--ldl-blue);
    box-shadow: 0 0 0 3px var(--ldl-blue-lt);
}

/* ── View switcher ────────────────────────────────────────── */
.ldl-view-switcher {
    display: flex;
    gap: 4px;
    background: var(--ldl-bg);
    border: 1px solid var(--ldl-border);
    border-radius: 8px;
    padding: 3px;
}
.ldl-view-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--ldl-mid);
    transition: background .15s, color .15s;
}
.ldl-view-btn:hover,
.ldl-view-btn.active {
    background: var(--ldl-white);
    color: var(--ldl-blue);
    box-shadow: var(--ldl-shadow);
}

/* ── Collapse / expand all controls bar ───────────────────── */
.ldl-collapse-controls {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--ldl-blue-lt);
}
.ldl-collapse-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    background: none;
    border: 1.5px solid var(--ldl-border);
    border-radius: 6px;
    font-size: .8rem;
    color: var(--ldl-mid);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.ldl-collapse-btn .dashicons {
    font-size: 13px;
    width: 13px;
    height: 13px;
}
.ldl-collapse-btn:hover {
    border-color: #333333;
    background: #333333;
    color: var(--ldl-white);
}

/* ── Folder sections ──────────────────────────────────────── */
.ldl-folder-section {
    margin-bottom: 4px;
}

/* Shared heading button base */
.ldl-folder-heading {
    all: unset;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 10px;
    padding: 9px 14px;
    border-radius: var(--ldl-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    transition: background .15s;
    user-select: none;
    margin-bottom: 2px;
}

/* Depth-based colours */
.ldl-folder-heading.ldl-depth-0 { background: #333333; }
.ldl-folder-heading.ldl-depth-0:hover { background: #444444; }

.ldl-folder-heading.ldl-depth-1 { background: var(--ldl-blue); }
.ldl-folder-heading.ldl-depth-1:hover { background: var(--ldl-blue-dk); }

.ldl-folder-heading.ldl-depth-2 { background: var(--ldl-pink); }
.ldl-folder-heading.ldl-depth-2:hover { background: var(--ldl-pink-dk); }

.ldl-folder-heading.ldl-depth-3,
.ldl-folder-heading.ldl-depth-4 {
    background: var(--ldl-blue-lt);
    color: var(--ldl-dark);
}
.ldl-folder-heading.ldl-depth-3:hover,
.ldl-folder-heading.ldl-depth-4:hover { background: #b5e2f0; }
.ldl-folder-heading.ldl-depth-3 .dashicons,
.ldl-folder-heading.ldl-depth-4 .dashicons,
.ldl-folder-heading.ldl-depth-3 .ldl-folder-chevron .dashicons,
.ldl-folder-heading.ldl-depth-4 .ldl-folder-chevron .dashicons { color: var(--ldl-blue); }
.ldl-folder-heading.ldl-depth-3 .ldl-folder-count,
.ldl-folder-heading.ldl-depth-4 .ldl-folder-count {
    background: var(--ldl-pink-lt);
    color: var(--ldl-pink);
}

.ldl-folder-heading-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}
.ldl-folder-heading .dashicons {
    color: #ffffff;
    font-size: 16px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.ldl-folder-chevron .dashicons {
    color: #ffffff;
    font-size: 14px;
    width: 14px;
    height: 14px;
    transition: transform .2s ease;
    flex-shrink: 0;
}
.ldl-folder-toggle[aria-expanded="false"] .ldl-folder-chevron .dashicons {
    transform: rotate(-90deg);
}
.ldl-folder-count {
    background: rgba(255,255,255,.25);
    color: #ffffff;
    font-size: .7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    flex-shrink: 0;
}
.ldl-depth-indent {
    display: inline-block;
    width: 14px;
    flex-shrink: 0;
}

/* Collapsible folder contents panel */
.ldl-folder-contents {
    padding: 8px 12px 12px 16px;
    border-left: 2px solid var(--ldl-blue-lt);
    border-bottom: 2px solid var(--ldl-blue-lt);
    border-right: 2px solid var(--ldl-blue-lt);
    border-bottom-left-radius: var(--ldl-radius);
    border-bottom-right-radius: var(--ldl-radius);
    margin-left: 10px;
    margin-right: 2px;
    margin-bottom: 8px;
}

/* Depth-matched border colours — light version of the header colour */
.ldl-depth-0 > .ldl-folder-contents {
    border-color: #cccccc;
}
.ldl-depth-1 > .ldl-folder-contents {
    border-color: var(--ldl-blue-lt);
}
.ldl-depth-2 > .ldl-folder-contents {
    border-color: var(--ldl-pink-lt);
}
.ldl-depth-3 > .ldl-folder-contents,
.ldl-depth-4 > .ldl-folder-contents {
    border-color: #b5e2f0;
}

/* Plain heading for uncategorised */
.ldl-folder-heading--plain {
    background: var(--ldl-bg);
    color: var(--ldl-slate);
    border: 1px dashed var(--ldl-border);
    cursor: default;
    font-weight: 500;
}
.ldl-folder-heading--plain .dashicons { color: var(--ldl-mid); }

/* Empty folder message */
.ldl-folder-empty {
    color: var(--ldl-mid);
    font-size: .875rem;
    font-style: italic;
    padding: 10px 0;
    margin: 0;
}

/* ── Files grid / list base ───────────────────────────────── */
.ldl-files-grid {
    display: grid;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 0 6px;
}

/* ============================================================
   LIST VIEW
   ============================================================ */
.ldl-view-active-list .ldl-files-grid {
    grid-template-columns: 1fr;
}
.ldl-view-active-list .ldl-file-card {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    align-items: center;
    gap: 16px;
    background: var(--ldl-white);
    border: 1px solid var(--ldl-border);
    border-left: 3px solid var(--ldl-blue-lt);
    border-radius: var(--ldl-radius);
    padding: 14px 18px;
    transition: box-shadow .15s, border-color .15s;
}
.ldl-view-active-list .ldl-file-card:hover {
    box-shadow: var(--ldl-shadow-md);
    border-left-color: var(--ldl-blue);
}
.ldl-view-active-list .ldl-file-description { display: none; }
.ldl-view-active-list .ldl-file-actions { display: flex; gap: 8px; flex-shrink: 0; }
.ldl-view-active-list .ldl-inline-preview { display: none !important; }

/* ============================================================
   GRID VIEW
   ============================================================ */
.ldl-view-active-grid .ldl-files-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
}
.ldl-view-active-grid .ldl-file-card {
    background: var(--ldl-white);
    border: 1px solid var(--ldl-border);
    border-top: 3px solid var(--ldl-blue-lt);
    border-radius: var(--ldl-radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: box-shadow .15s, transform .15s, border-color .15s;
}
.ldl-view-active-grid .ldl-file-card:hover {
    box-shadow: var(--ldl-shadow-md);
    transform: translateY(-2px);
    border-top-color: var(--ldl-blue);
}
.ldl-view-active-grid .ldl-file-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    flex-wrap: wrap;
}
.ldl-view-active-grid .ldl-inline-preview { display: none !important; }

/* ============================================================
   PREVIEW VIEW
   ============================================================ */
.ldl-view-active-preview .ldl-files-grid {
    grid-template-columns: 1fr;
}
.ldl-view-active-preview .ldl-file-card {
    background: var(--ldl-white);
    border: 1px solid var(--ldl-border);
    border-radius: var(--ldl-radius);
    padding: 0;
    overflow: hidden;
    transition: box-shadow .2s;
}
.ldl-view-active-preview .ldl-file-card:hover {
    box-shadow: var(--ldl-shadow-md);
}
.ldl-view-active-preview .ldl-file-card .ldl-file-icon-wrap,
.ldl-view-active-preview .ldl-file-card .ldl-file-body,
.ldl-view-active-preview .ldl-file-card .ldl-file-actions {
    padding: 16px 20px;
}
.ldl-view-active-preview .ldl-file-card .ldl-file-icon-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 0;
}
.ldl-view-active-preview .ldl-file-actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--ldl-border);
    background: var(--ldl-bg);
}
.ldl-view-active-preview .ldl-inline-preview {
    border-top: 1px solid var(--ldl-blue-lt);
}
.ldl-view-active-preview .ldl-pdf-iframe {
    width: 100%;
    height: 500px;
    border: none;
    display: block;
}

/* ── File card sub-elements ───────────────────────────────── */
.ldl-file-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
}
.ldl-file-ext-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .05em;
    color: var(--ldl-white);
    background: var(--ldl-mid);
    flex-shrink: 0;
}

/* ── File type badge colours — kept as original ──────────── */
.ldl-badge-pdf  { background: #c0392b; }
.ldl-badge-doc,
.ldl-badge-docx { background: #2b5fbd; }
.ldl-badge-xls,
.ldl-badge-xlsx { background: #1e7e34; }
.ldl-badge-ppt,
.ldl-badge-pptx { background: #d35400; }
.ldl-badge-jpg,
.ldl-badge-jpeg,
.ldl-badge-png  { background: #6c3483; }

.ldl-file-title {
    
    font-size: 1rem;
    font-weight: 600;
    color: var(--ldl-dark);
    margin: 0 0 4px;
}
.ldl-file-description {
    font-size: .875rem;
    color: var(--ldl-mid);
    margin: 0 0 8px;
    line-height: 1.5;
}
.ldl-file-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.ldl-meta-item {
    font-size: .75rem;
    color: var(--ldl-mid);
    background: var(--ldl-bg);
    padding: 2px 8px;
    border-radius: 4px;
}
/* Version badge uses pink as a distinct accent */
.ldl-version {
    color: var(--ldl-pink);
    background: var(--ldl-pink-lt);
    font-weight: 600;
}

/* ── Buttons ──────────────────────────────────────────────── */
.ldl-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 6px;
    
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.ldl-btn .dashicons { font-size: 14px; width: 14px; height: 14px; }

/* Preview button — pink */
.ldl-btn-view {
    background: var(--ldl-pink-lt);
    color: var(--ldl-pink);
}
.ldl-btn-view:hover {
    background: var(--ldl-pink);
    color: var(--ldl-white);
}

/* Download button — blue */
.ldl-btn-download {
    background: var(--ldl-blue);
    color: var(--ldl-white);
}
.ldl-btn-download:hover {
    background: var(--ldl-blue-dk);
    color: var(--ldl-white);
}

.ldl-btn-locked {
    background: var(--ldl-bg);
    color: var(--ldl-mid);
    cursor: default;
}

/* ── Modal ────────────────────────────────────────────────── */
.ldl-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20,135,203,.25);
    backdrop-filter: blur(4px);
    /* Divi 5 header sits at up to 999999 — go above it */
    z-index: 1000100;
    display: flex;
    /* Align to top so we can control exact top offset */
    align-items: flex-start;
    justify-content: center;
    /* Top padding clears the Divi fixed header (~80px) + breathing room */
    padding: 90px 20px 20px;
    opacity: 0;
    transition: opacity .2s;
    /* Allow scrolling if content is very tall on small screens */
    overflow-y: auto;
}
.ldl-modal-overlay.ldl-modal-open { opacity: 1; }
.ldl-modal {
    background: var(--ldl-white);
    border-radius: 12px;
    width: 100%;
    max-width: 900px;
    /* Leave room for the header offset above */
    max-height: calc(100vh - 110px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(20,135,203,.25);
    transform: scale(.95);
    transition: transform .2s;
    border-top: 4px solid var(--ldl-blue);
}
.ldl-modal-overlay.ldl-modal-open .ldl-modal { transform: scale(1); }
.ldl-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--ldl-blue-lt);
    flex-shrink: 0;
}
.ldl-modal-title {
    
    font-size: 1rem;
    font-weight: 600;
    color: var(--ldl-blue);
    margin: 0;
}
.ldl-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ldl-mid);
    font-size: 20px;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
    transition: color .15s, background .15s;
}
.ldl-modal-close:hover {
    color: var(--ldl-pink);
    background: var(--ldl-pink-lt);
}
.ldl-modal-body {
    flex: 1;
    overflow: hidden;
}
.ldl-modal-iframe {
    width: 100%;
    height: 75vh;
    border: none;
    display: block;
}

/* ── Modal loading spinner ────────────────────────────────── */
.ldl-modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--ldl-mid);
    gap: 16px;
}
.ldl-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--ldl-blue-lt);
    border-top-color: var(--ldl-blue);
    border-radius: 50%;
    animation: ldl-spin 0.7s linear infinite;
}
@keyframes ldl-spin {
    to { transform: rotate(360deg); }
}
.ldl-modal-error {
    color: var(--ldl-red);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .95rem;
}
.ldl-modal-error .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* ── Office placeholder (preview view) ───────────────────── */
.ldl-office-preview-placeholder {
    background: var(--ldl-blue-lt);
    border-top: 1px solid var(--ldl-border);
}
.ldl-office-placeholder-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    gap: 16px;
    text-align: center;
    color: var(--ldl-slate);
}
.ldl-badge-lg {
    width: 64px !important;
    height: 64px !important;
    font-size: 1rem !important;
    border-radius: 12px !important;
}
.ldl-office-placeholder-inner p {
    margin: 0;
    font-size: .9rem;
    max-width: 280px;
}

/* ── No results ───────────────────────────────────────────── */
.ldl-no-results {
    text-align: center;
    padding: 48px;
    color: var(--ldl-mid);
    font-size: 1rem;
}

/* ── Error message ────────────────────────────────────────── */
.ldl-error {
    background: #fdf2f2;
    border: 1px solid #fca5a5;
    color: var(--ldl-red);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: .9rem;
}

/* ── Responsive ───────────────────────────────────────────── */

/* Tablet (max 768px) */
@media (max-width: 768px) {

    /* Collapse controls: full width on tablet */
    .ldl-collapse-controls {
        justify-content: flex-start;
    }

    /* Folder contents: tighter indent on tablet */
    .ldl-folder-contents {
        padding: 6px 8px 10px 12px;
        margin-left: 6px;
        margin-right: 1px;
    }

    /* List view: drop actions below title on tablet */
    .ldl-view-active-list .ldl-file-card {
        grid-template-columns: 52px 1fr;
        grid-template-rows: auto auto;
    }
    .ldl-view-active-list .ldl-file-actions {
        grid-column: 1 / -1;
        padding-top: 4px;
    }

    /* Grid: two columns on tablet */
    .ldl-view-active-grid .ldl-files-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile (max 480px) */
@media (max-width: 480px) {

    /* Library title smaller on mobile */
    .ldl-library-title {
        font-size: 1.35rem;
    }

    /* Search + view switcher stack vertically */
    .ldl-library-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .ldl-search-wrap {
        min-width: unset;
        width: 100%;
    }
    .ldl-view-switcher {
        align-self: flex-start;
    }

    /* Collapse buttons: full width and centred on mobile */
    .ldl-collapse-controls {
        justify-content: stretch;
        gap: 6px;
    }
    .ldl-collapse-btn {
        flex: 1;
        justify-content: center;
        font-size: .8rem;
        padding: 6px 8px;
    }

    /* Folder contents: minimal indent on mobile */
    .ldl-folder-contents {
        padding: 4px 6px 8px 8px;
        margin-left: 4px;
        margin-right: 1px;
    }

    /* List view: single column, compact */
    .ldl-view-active-list .ldl-file-card {
        grid-template-columns: 44px 1fr;
        padding: 12px 14px;
        gap: 12px;
    }
    .ldl-view-active-list .ldl-file-actions {
        grid-column: 1 / -1;
        flex-wrap: wrap;
    }

    /* Grid: single column on mobile */
    .ldl-view-active-grid .ldl-files-grid {
        grid-template-columns: 1fr;
    }

    /* Folder heading: slightly smaller text */
    .ldl-folder-heading {
        font-size: .95rem;
        padding: 9px 12px;
    }

    /* Buttons: shrink slightly */
    .ldl-btn {
        font-size: .8rem;
        padding: 6px 10px;
    }

    /* Modal: near full screen on mobile but still clears header */
    .ldl-modal-overlay {
        padding: 70px 8px 8px;
    }
    .ldl-modal {
        max-height: calc(100vh - 90px);
        border-radius: 8px;
    }
    .ldl-modal-iframe {
        height: 65vh;
    }
}
