/**
 * Moodle Module Detail - CSS
 * 
 * Sidebar Layout:
 * - JS relocates sidebar to <main> for full-height layout
 * - Main becomes flex container when .oew-has-sidebar is added
 * - Sidebar sticks to the full height of main
 */

/* Module title - same style as card titles */
.oew-module-detail-title {
    max-width: 960px;
    margin: 0 auto 24px;
    padding: 0 16px;
    font-family: verdana;
    font-size: 18px;
    font-weight: 600;
    color: var(--oew-text, #333333);
    line-height: 1.4;
}

/* Layout when sidebar is present (main gets .oew-has-sidebar via JS) */
#content.oew-has-sidebar {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    position: relative;
    /* Override theme max-width centering (e.g. Hello Elementor's site-main constraint) */
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-inline: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-inline: 0 !important;
    width: 100%;
}

/* Sidebar full height on the left — sits at page edge because #content is full-width */
#content.oew-has-sidebar .oew-moodle-module-detail-sidebar {
    position: relative;
    left: auto;
    top: auto;
    bottom: auto;
    width: 220px;
    flex-shrink: 0;
    background: var(--oew-primary, #003556);
    overflow-y: auto;
    z-index: 10;
}

/* Main content area takes remaining space (sidebar is a flex sibling, no padding needed) */
#content.oew-has-sidebar .oew-main-content {
    flex: 1;
    min-width: 0;
}

/* Intro video centering in remaining flex:1 space */
#content.oew-has-sidebar .oew-intro-video-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

#content.oew-has-sidebar .oew-intro-video-center video,
#content.oew-has-sidebar .oew-intro-video-center .oew-moodle-module-intro-no-video {
    margin: auto;
    max-width: 860px;
}

#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-title {
    color: white;
    font-size: 14px;
    font-weight: 600;
    padding: 16px 16px 8px;
    margin: 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-nav {
    padding: 8px 0;
}

#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: white;
    text-decoration: none;
    padding: 10px 16px;
    font-size: 14px;
    min-height: 44px;
    transition: background 0.2s ease;
    border-left: 3px solid transparent;
    box-sizing: border-box;
}

#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-item:hover {
    background: rgba(255,255,255,0.1);
}

#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-item.active {
    background: rgba(0, 151, 144, 0.3);
    border-left-color: var(--oew-secondary, #009790);
}

#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-action.active {
    background: rgba(0, 151, 144, 0.3);
    border-left: 3px solid var(--oew-secondary, #009790);
}

#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-item span {
    display: block;
    font-weight: 500;
}

#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-item small {
    display: block;
    font-size: 11px;
    opacity: 0.7;
    margin-top: 2px;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

/* Sidebar quick action links — match sidebar-item style */
#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-actions {
    border-top: 1px solid rgba(255,255,255,0.15);
    padding-top: 4px;
    margin-top: 4px;
}

#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-action {
    display: flex;
    align-items: center;
    color: white;
    text-decoration: none;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    min-height: 44px;
    transition: background 0.2s ease;
    box-sizing: border-box;
}

#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-action:hover {
    background: rgba(255,255,255,0.1);
}

/* Sidebar Font Awesome icons */
#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-action .fa-solid,
#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-back .fa-solid {
    width: 20px;
    text-align: center;
    margin-right: 8px;
    font-size: 14px;
}

/* Sidebar back link */
#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-back {
    display: flex;
    align-items: center;
    color: white;
    text-decoration: none;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    min-height: 44px;
    box-sizing: border-box;
    border-top: 1px solid rgba(255,255,255,0.15);
    margin-top: 8px;
}

#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-back:hover {
    background: rgba(255,255,255,0.1);
}

/* Sidebar divider */
#content.oew-has-sidebar .oew-sidebar-divider {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.15);
    margin: 8px 0;
}

/* Sidebar module subtitle */
#content.oew-has-sidebar .oew-moodle-module-detail-sidebar-subtitle {
    color: rgba(255,255,255,0.7);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 16px 8px;
    margin: 0;
}

/* Page fade-in to prevent flash between navigations */
@keyframes oew-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Widget container (no longer has sidebar inside) */
.oew-moodle-module-detail {
    width: 100%;
    animation: oew-fade-in 0.3s ease;
}

.oew-moodle-module-intro {
    animation: oew-fade-in 0.3s ease;
}

.oew-moodle-assessment {
    animation: oew-fade-in 0.3s ease;
}

 .oew-moodle-module-detail-pdf-wrapper {
     max-width: 960px;
     margin: 0 auto 24px;
     /* Subtle teal frame with a teal-tinted drop shadow (cards use a black
        shadow at 8% opacity which is too subtle here). overflow:hidden
        clips the iframe content to the frame edges. */
     border: 1px solid var(--oew-secondary, #009790);
     border-radius: 0;
     box-shadow: 0 4px 12px rgba(0, 151, 144, 0.25);
     overflow: hidden;
 }

.oew-moodle-module-detail-pdf iframe {
    width: 100%;
    height: 1200px;
    border: none;
    border-radius: 0;
    background: var(--oew-surface, #f5f5f5);
}

/* Resources list */
.oew-moodle-module-detail-resources {
    max-width: 960px;
    margin: 24px auto 0;
    padding: 16px;
    background: var(--oew-background, #FFFFFF);
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--oew-shadow, rgba(0,0,0,0.08));
}

.oew-moodle-module-detail-resource {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.oew-moodle-module-detail-resource:last-child {
    border-bottom: none;
}

.oew-moodle-module-detail-resource-icon {
    width: 40px;
    height: 40px;
    background: var(--oew-primary, #003556);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.oew-moodle-module-detail-resource-name {
    flex: 1;
    font-size: 14px;
    color: var(--oew-text, #333333);
}

.oew-moodle-module-detail-resource-download a {
    color: var(--oew-primary, #003556);
    text-decoration: none;
    font-weight: 500;
}

.oew-moodle-module-detail-resource-download a:hover {
    color: var(--oew-secondary, #009790);
}

/* Empty state */
.oew-moodle-module-detail-empty {
    max-width: 960px;
    margin: 24px auto;
    padding: 48px 24px;
    text-align: center;
    background: var(--oew-surface, #f5f5f5);
    border-radius: 8px;
}

.oew-moodle-module-detail-empty p {
    margin: 0;
    color: var(--oew-text-muted, #666666);
}

/* Back link */
.oew-moodle-module-detail-back {
    max-width: 960px;
    margin: 24px auto;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.oew-moodle-module-detail-back a {
    color: var(--oew-primary, #003556);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.oew-moodle-module-detail-back a:hover {
    color: var(--oew-secondary, #009790);
}

/* -------- Infographic -------- */
.oew-moodle-module-detail-infographic-title {
    max-width: 960px;
    margin: 48px auto 12px;
    padding: 16px 20px;
    font-family: verdana;
    font-size: 24px;
    font-weight: 700;
    /* !important to survive any Elementor/theme reset on h2 color/background */
    color: #FFFFFF !important;
    /* Horizontal gradient: solid blue on the left fading to transparent on the right */
    background: linear-gradient(to right, var(--oew-primary, #003556) 0%, transparent 100%) !important;
}

 .oew-moodle-module-detail-infographic {
     max-width: 960px;
     margin: 24px auto 24px;
     padding: 0 16px;
 }

.oew-moodle-module-detail-infographic-image {
    width: 100%;
    border: 1px solid var(--oew-secondary, #009790);
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 151, 144, 0.25);
    background: var(--oew-surface, #f5f5f5);
}

.oew-moodle-module-detail-infographic-image img {
    display: block;
    width: 100%;
    height: auto;
}

.oew-moodle-module-detail-infographic-empty {
    color: #666;
    font-size: 14px;
    padding: 20px;
    text-align: center;
    background: var(--oew-surface, #f5f5f5);
    border: 1px solid var(--oew-secondary, #009790);
    border-radius: 0;
    box-shadow: 0 4px 12px rgba(0, 151, 144, 0.25);
}


/* Page header title — blue gradient banner with white text (same treatment as infographic title) */
.page-header .entry-title {
    font-family: verdana;
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 24px;
    padding: 20px 24px;
    color: #FFFFFF !important;
    background: linear-gradient(to right, var(--oew-primary, #003556) 0%, transparent 100%) !important;
}

/* Mobile & Tablet Responsive — hamburger menu active */
@media (max-width: 1024px) {
    .page-header .entry-title {
        font-size: 20px;
        padding-left: 16px;
        padding-right: 16px;
        overflow-wrap: break-word;
        word-wrap: break-word;
        box-sizing: border-box;
    }

    #content.oew-has-sidebar {
        display: block;
    }

    #content.oew-has-sidebar .oew-main-content {
        flex: none;
        width: 100%;
        padding-left: 0;
    }

    /* Hamburger toggle — sits in normal document flow */
    .oew-moodle-sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 14px 28px;
        background: var(--oew-primary, #003556);
        color: white;
        border: none;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        min-height: 44px;
        box-sizing: border-box;
        font-size: 15px;
        font-weight: 600;
    }

    .oew-hamburger-icon {
        margin-left: 12px;
        font-size: 18px;
        line-height: 1;
    }

    /* Sidebar — normal flow, nav+actions hidden by default */
    #content.oew-has-sidebar .oew-moodle-module-detail-sidebar {
        width: 100%;
        border-radius: 0;
        background: var(--oew-primary, #003556);
    }

    #content.oew-has-sidebar .oew-moodle-module-detail-sidebar-title {
        display: none;
    }

    /* Sidebar panel content — hidden by default, shown via .oew-sidebar-open */
    #content.oew-has-sidebar .oew-sidebar-panel {
        max-height: 0;
        overflow: hidden;
        transition: max-height 300ms ease-in-out;
    }

    #content.oew-has-sidebar.oew-sidebar-open .oew-sidebar-panel {
        max-height: 500px;
    }

    #content.oew-has-sidebar .oew-moodle-module-detail-sidebar-back {
        margin-top: 0;
        border-top: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        justify-content: flex-start;
        padding: 12px 20px;
    }

    #content.oew-has-sidebar .oew-moodle-module-detail-sidebar-nav {
        display: block;
        padding: 0;
    }

    #content.oew-has-sidebar .oew-moodle-module-detail-sidebar-item {
        padding: 12px 20px;
        border-left: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    #content.oew-has-sidebar .oew-moodle-module-detail-sidebar-item.active {
        border-left: none;
        border-bottom-color: var(--oew-secondary, #009790);
    }

    #content.oew-has-sidebar .oew-moodle-module-detail-sidebar-action.active {
        border-left-color: transparent;
        border-bottom: 3px solid var(--oew-secondary, #009790);
    }

    #content.oew-has-sidebar .oew-moodle-module-detail-sidebar-item {
        font-size: 13px;
        padding: 10px 20px;
    }

    #content.oew-has-sidebar .oew-moodle-module-detail-sidebar-item small {
        display: block;
        font-size: 11px;
    }

    .oew-moodle-module-detail-pdf iframe {
        height: 600px;
    }

    /* Small lateral inset on the wrapper so the teal border doesn't
       touch the screen edges in responsive. */
    .oew-moodle-module-detail-pdf-wrapper {
        margin-left: 8px;
        margin-right: 8px;
    }

    /* The content view wraps the widget in an Elementor e-con-boxed container
       with 10px lateral padding in responsive — neutralize it so the only
       lateral gap is the 8px on the wrapper above. */
    .e-con-boxed:has(.oew-moodle-module-detail) {
        padding-left: 0;
        padding-right: 0;
    }

    .oew-moodle-module-detail-infographic {
        margin: 16px auto 0;
        padding: 0 12px;
    }

    .oew-moodle-module-detail-infographic-title {
        font-size: 20px;
        padding: 12px 16px;
    }

    .oew-moodle-module-detail-back {
        padding: 12px 16px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .oew-moodle-module-detail-resources {
        max-width: 100%;
        margin: 16px;
    }

    .oew-moodle-module-detail-resource {
        flex-wrap: wrap;
        gap: 8px;
    }

    .oew-moodle-module-detail-resource-name {
        min-width: 0;
        word-break: break-word;
    }

    /* Tablet-specific tweaks (hamburger active but larger screen) */
    @media (min-width: 769px) {
        .page-header .entry-title {
            font-size: 26px;
        }

        .oew-moodle-module-detail-pdf iframe {
            height: 800px;
        }

        .oew-moodle-module-detail-infographic {
            margin: 20px auto 0;
        }
    }
}

/* Mobile phones (≤768) */
@media (max-width: 768px) {
    .oew-moodle-module-detail-infographic-title {
        font-size: 18px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .oew-moodle-module-detail-pdf iframe {
        height: 500px;
    }
}

/* Desktop: hide hamburger */
@media (min-width: 1025px) {
    .oew-moodle-sidebar-toggle {
        display: none !important;
    }
}

/* Back/forward nav at the bottom of the module detail page is no longer
   needed (2026-06-22 user request). Hidden globally — not viewport-
   scoped — because the element should not appear at any breakpoint. */
.oew-moodle-module-detail-back {
    display: none !important;
}
/*==============================================================================
   Moodle Module Detail — Slide Viewer Styles (ADD-ON)
   ============================================================================*/

/* -------- Slide Viewer Container -------- */
.oew-moodle-module-detail-slides {
    max-width: 960px;
    margin: 0 auto 30px;
    padding: 0 16px;
    border: 1px solid var(--oew-secondary, #009790);
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 151, 144, 0.25);
    background: var(--oew-surface, #f5f5f5);
}

/* -------- Slide Viewer Viewport -------- */
.oew-moodle-module-detail-slides-viewer {
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 400px;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
}

/* -------- Loading Indicator -------- */
.oew-moodle-module-detail-slides-loading {
    color: #666;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* -------- Error / Fallback State -------- */
.oew-moodle-module-detail-slides-error {
    text-align: center;
    color: #666;
    padding: 40px 20px;
    background: #f5f5f5;
    border-radius: 8px;
}

.oew-moodle-module-detail-slides-error p {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
}

.oew-moodle-module-detail-slides-error a {
    color: #003556;
    text-decoration: underline;
}

.oew-moodle-module-detail-slides-error a:hover {
    color: #002a45;
}

/* -------- Responsive: Tablet & Mobile -------- */
@media (max-width: 768px) {
    .oew-moodle-module-detail-slides-viewer {
        min-height: 250px;
    }

    .oew-moodle-module-detail-slides-error {
        padding: 20px 15px;
    }
}
