/**
 * Modern Components — global styling for native Gutenberg blocks
 * produced by TheDoot Migrator (details, file) across frontend + editor.
 * Selectors are bootstrapped with `body` / `.editor-styles-wrapper` and
 * !important so they win over WordPress theme default block styles.
 */

/* ===== High-Specificity Frontend & Editor Accordion Overrides ===== */
body .wp-block-details,
.editor-styles-wrapper .wp-block-details,
body details.thedoot-accordion-item {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 10px !important;
    margin-bottom: 14px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important;
    overflow: hidden !important;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

body .wp-block-details[open],
.editor-styles-wrapper .wp-block-details[open] {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
    border-color: #94a3b8 !important;
}

body .wp-block-details > summary,
.editor-styles-wrapper .wp-block-details > summary,
body details.thedoot-accordion-item > summary {
    padding: 14px 18px !important;
    font-weight: 600 !important;
    font-size: 15px !important;
    color: #0f172a !important;
    background: #f8fafc !important;
    border-bottom: 1px solid #f1f5f9 !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background 0.25s ease;
}

body .wp-block-details > summary:hover,
.editor-styles-wrapper .wp-block-details > summary:hover {
    background: #f1f5f9 !important;
}

body .wp-block-details > summary::-webkit-details-marker,
.editor-styles-wrapper .wp-block-details > summary::-webkit-details-marker {
    display: none;
}

body .wp-block-details > summary::after,
.editor-styles-wrapper .wp-block-details > summary::after {
    content: '\25BE';
    font-size: 14px;
    line-height: 1;
    color: #2271b1;
    transition: transform 0.25s ease;
}

body .wp-block-details[open] > summary::after,
.editor-styles-wrapper .wp-block-details[open] > summary::after {
    transform: rotate(180deg);
}

/* Smooth height animation where the browser supports ::details-content. */
body .wp-block-details,
.editor-styles-wrapper .wp-block-details {
    interpolate-size: allow-keywords;
}

body .wp-block-details::details-content,
.editor-styles-wrapper .wp-block-details::details-content {
    height: 0;
    overflow: hidden;
    transition: height 0.3s ease;
}

body .wp-block-details[open]::details-content,
.editor-styles-wrapper .wp-block-details[open]::details-content {
    height: auto;
}

/* ===== High-Specificity PDF File Cards ===== */
body .wp-block-file,
.editor-styles-wrapper .wp-block-file {
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    padding: 14px !important;
    background: #ffffff !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1rem 0;
}

body .wp-block-file a:not(.wp-block-file__button),
.editor-styles-wrapper .wp-block-file a:not(.wp-block-file__button) {
    font-weight: 600 !important;
    color: #1d2327 !important;
    text-decoration: none !important;
    word-break: break-word;
}

body .wp-block-file a:not(.wp-block-file__button):hover,
.editor-styles-wrapper .wp-block-file a:not(.wp-block-file__button):hover {
    color: #135e96 !important;
}

body .wp-block-file__button,
.editor-styles-wrapper .wp-block-file__button {
    display: inline-flex;
    align-items: center;
    background: #2271b1 !important;
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: 999px !important;
    padding: 0.5rem 1.25rem !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    white-space: nowrap;
    transition: background 0.25s ease;
}

body .wp-block-file__button:hover,
.editor-styles-wrapper .wp-block-file__button:hover {
    background: #135e96 !important;
    color: #ffffff !important;
}

body .wp-block-file__embed,
.editor-styles-wrapper .wp-block-file__embed {
    width: 100% !important;
    min-height: 550px !important;
    border-radius: 6px !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06) !important;
    box-sizing: border-box;
}

/* ===== Touch device fallback action card ===== */
body .thedoot-pdf-scroll-wrapper,
.editor-styles-wrapper .thedoot-pdf-scroll-wrapper {
    position: relative !important;
    width: 100% !important;
    height: 500px !important;
    max-height: 75vh !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    background: #f8fafc !important;
    box-sizing: border-box;
}

body .thedoot-pdf-canvas-viewer,
.editor-styles-wrapper .thedoot-pdf-canvas-viewer {
    position: relative !important;
    width: 100% !important;
    height: 500px !important;
    max-height: 75vh !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x pan-y !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    background: #f8fafc !important;
    box-sizing: border-box;
}

body .thedoot-pdf-page-canvas,
.editor-styles-wrapper .thedoot-pdf-page-canvas {
    display: block !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 auto 12px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

body iframe.thedoot-mobile-pdf-iframe,
.editor-styles-wrapper iframe.thedoot-mobile-pdf-iframe {
    display: block;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-width: 100%;
    border: none !important;
    touch-action: pan-x pan-y !important;
    pointer-events: auto !important;
    box-sizing: border-box;
}

body .thedoot-mobile-pdf-action-card,
.editor-styles-wrapper .thedoot-mobile-pdf-action-card,
body .thedoot-mobile-pdf-action,
.editor-styles-wrapper .thedoot-mobile-pdf-action {
    pointer-events: none !important;
}

body .thedoot-mobile-pdf-action-card a,
body .thedoot-mobile-pdf-action-card button,
.editor-styles-wrapper .thedoot-mobile-pdf-action-card a,
.editor-styles-wrapper .thedoot-mobile-pdf-action-card button,
body .thedoot-mobile-pdf-action a,
body .thedoot-mobile-pdf-action button,
.editor-styles-wrapper .thedoot-mobile-pdf-action a,
.editor-styles-wrapper .thedoot-mobile-pdf-action button {
    pointer-events: auto !important;
}

body .thedoot-mobile-pdf-iframe,
.editor-styles-wrapper .thedoot-mobile-pdf-iframe {
    display: block;
    width: 100% !important;
    height: 500px !important;
    max-width: 100%;
    box-sizing: border-box;
}

body .thedoot-mobile-pdf-action,
.editor-styles-wrapper .thedoot-mobile-pdf-action {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 0 0.25rem;
    border-top: 1px dashed #e2e8f0;
    margin-top: 0.5rem;
}

body .thedoot-mobile-pdf-action__name,
.editor-styles-wrapper .thedoot-mobile-pdf-action__name {
    color: #646970;
    font-size: 13px;
    word-break: break-all;
}

body .thedoot-pdf-action-bar,
.editor-styles-wrapper .thedoot-pdf-action-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

body .thedoot-btn-download,
body .thedoot-btn-open,
.editor-styles-wrapper .thedoot-btn-download,
.editor-styles-wrapper .thedoot-btn-open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: 999px;
    padding: 0.45rem 1.1rem;
    font-size: 13px;
    font-weight: 600;
}

body .thedoot-btn-download,
.editor-styles-wrapper .thedoot-btn-download {
    background: #2271b1 !important;
    color: #ffffff !important;
}

body .thedoot-btn-download:hover,
.editor-styles-wrapper .thedoot-btn-download:hover {
    background: #135e96 !important;
    color: #ffffff !important;
}

body .thedoot-btn-open,
.editor-styles-wrapper .thedoot-btn-open {
    border: 1px solid #2271b1 !important;
    color: #2271b1 !important;
}

body .thedoot-btn-open:hover,
.editor-styles-wrapper .thedoot-btn-open:hover {
    background: #f0f6fc !important;
}

/* Desktop View: Show Download Only */
@media (min-width: 769px) {
    body .thedoot-btn-open,
    body a.thedoot-open-btn,
    .editor-styles-wrapper .thedoot-btn-open,
    .editor-styles-wrapper a.thedoot-open-btn,
    .thedoot-mobile-pdf-action a[target="_blank"] {
        display: none !important;
    }

    /* Hide desktop filename text links inside file block */
    body .wp-block-file > a:not(.wp-block-file__button):not(.thedoot-btn-download),
    .editor-styles-wrapper .wp-block-file > a:not(.wp-block-file__button):not(.thedoot-btn-download) {
        display: none !important;
    }

    /* Clean, compact desktop button */
    body .wp-block-file .wp-block-file__button,
    body .thedoot-btn-download,
    .editor-styles-wrapper .wp-block-file .wp-block-file__button,
    .editor-styles-wrapper .thedoot-btn-download {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 6px 14px !important;
        font-size: 13px !important;
        font-weight: 500 !important;
        border-radius: 6px !important;
        background-color: #2563eb !important;
        color: #ffffff !important;
        text-decoration: none !important;
        transition: background-color 0.2s ease !important;
        margin-top: 8px !important;
    }

    body .wp-block-file .wp-block-file__button:hover,
    body .thedoot-btn-download:hover,
    .editor-styles-wrapper .wp-block-file .wp-block-file__button:hover,
    .editor-styles-wrapper .thedoot-btn-download:hover {
        background-color: #1d4ed8 !important;
    }
}

/* Mobile View: Show Both Download & Open Side-by-Side */
@media (max-width: 768px) {
    /* Hide native Gutenberg filename link and duplicate native download button */
    body .wp-block-file > a:not(.thedoot-btn-download):not(.thedoot-btn-open),
    .editor-styles-wrapper .wp-block-file > a:not(.thedoot-btn-download):not(.thedoot-btn-open) {
        display: none !important;
    }

    /* Container & Button Action Bar */
    body .thedoot-pdf-action-bar,
    body .thedoot-mobile-pdf-action,
    .editor-styles-wrapper .thedoot-pdf-action-bar,
    .editor-styles-wrapper .thedoot-mobile-pdf-action {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        gap: 8px !important;
        margin-top: 8px !important;
        width: 100% !important;
        padding: 0 4px !important;
    }

    /* Compact Professional Side-by-Side Action Buttons */
    body .thedoot-mobile-pdf-action a,
    .editor-styles-wrapper .thedoot-mobile-pdf-action a {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex: 0 1 auto !important;
        min-width: 100px !important;
        padding: 7px 14px !important;
        font-size: 12px !important;
        font-weight: 600 !important;
        letter-spacing: 0.2px !important;
        border-radius: 6px !important;
        text-decoration: none !important;
        text-align: center !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
        box-sizing: border-box !important;
    }

    body .thedoot-mobile-pdf-action a.thedoot-btn-download,
    body .thedoot-mobile-pdf-action a[download],
    .editor-styles-wrapper .thedoot-mobile-pdf-action a.thedoot-btn-download,
    .editor-styles-wrapper .thedoot-mobile-pdf-action a[download] {
        background-color: #2563eb !important;
        color: #ffffff !important;
    }

    body .thedoot-mobile-pdf-action a.thedoot-btn-open,
    body .thedoot-mobile-pdf-action a[target="_blank"],
    .editor-styles-wrapper .thedoot-mobile-pdf-action a.thedoot-btn-open,
    .editor-styles-wrapper .thedoot-mobile-pdf-action a[target="_blank"] {
        background-color: #0f172a !important;
        color: #ffffff !important;
    }

    /* Touch Scroll Fix for Iframe Wrapper */
    body .thedoot-pdf-scroll-wrapper,
    body .thedoot-pdf-canvas-viewer,
    .editor-styles-wrapper .thedoot-pdf-scroll-wrapper,
    .editor-styles-wrapper .thedoot-pdf-canvas-viewer {
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-x pan-y !important;
    }
}

@media (max-width: 600px) {
    body .wp-block-file__embed,
    body .thedoot-pdf-scroll-wrapper,
    body .thedoot-pdf-canvas-viewer,
    body .thedoot-mobile-pdf-iframe,
    .editor-styles-wrapper .wp-block-file__embed,
    .editor-styles-wrapper .thedoot-pdf-scroll-wrapper,
    .editor-styles-wrapper .thedoot-pdf-canvas-viewer,
    .editor-styles-wrapper .thedoot-mobile-pdf-iframe {
        height: 400px !important;
        min-height: 400px !important;
    }
}