/* Simple slideshow styles for content rendered from CKEditor */
.exam-slideshow { 
    position: relative; 
    width: 100%; 
    max-width: 800px;
    margin: 1.5rem auto;
    padding: 0 50px; /* Space for arrows */
}

.exam-slideshow .slides { 
    position: relative; 
    overflow: hidden;
    background: #f8f9fa;
    border-radius: 8px;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.exam-slideshow .slide { 
    display: none; 
    margin: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    align-items: center;
    justify-content: center;
}

.exam-slideshow .slide.active { 
    display: flex;
    position: relative;
}

.exam-slideshow .slide img { 
    max-width: 100%; 
    max-height: 600px;
    height: auto; 
    display: block; 
    border-radius: 4px;
    object-fit: contain;
}

.exam-slideshow .nav-btn { 
    position: absolute; 
    top: 50%; 
    transform: translateY(-50%); 
    background: rgba(0,0,0,0.5); 
    color: #fff; 
    border: 0; 
    border-radius: 50%; 
    width: 40px; 
    height: 40px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: background 0.2s;
    z-index: 10;
}

.exam-slideshow .nav-btn:hover { 
    background: rgba(0,0,0,0.75); 
}

.exam-slideshow .nav-prev { 
    left: 0;
}

.exam-slideshow .nav-next { 
    right: 0;
}

.exam-slideshow .dots { 
    display: flex; 
    gap: 8px; 
    justify-content: center; 
    margin-top: 12px;
    padding: 0 50px; /* Align with content */
}

.exam-slideshow .dot { 
    width: 10px; 
    height: 10px; 
    border-radius: 50%; 
    background: #cfd4da; 
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.exam-slideshow .dot:hover {
    transform: scale(1.2);
}

.exam-slideshow .dot.active { 
    background: #0d6efd; 
}

/* In editor (admin) - show thumbnail grid preview instead of grey box */
/* Only apply these styles when inside the actual CKEditor editing context */
.ck-editor__editable .exam-slideshow { 
    border: 1px dashed #ced4da; 
    border-radius: 6px; 
    padding: 8px; 
    background: #f8f9fa;
    min-height: 60px;
    margin-bottom: 10px; /* gives room to click below */
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.ck-editor__editable .exam-slideshow:hover { 
    background: #e9ecef;
    border-color: #adb5bd;
}

.ck-editor__editable .exam-slideshow .slides {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    overflow: visible;
    position: static; /* prevent absolute positioning from student mode */
    min-height: 0;
}

/* Target the divs that CKEditor creates (it strips our .slide class) */
.ck-editor__editable .exam-slideshow .slides > div {
    display: flex !important;
    position: static;
    flex: 0 0 auto;
    width: 140px;
    height: 100px;
    overflow: hidden;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    align-items: center;
    justify-content: center;
}

.ck-editor__editable .exam-slideshow .slides > div:hover {
    border-color: #0d6efd;
    box-shadow: 0 2px 6px rgba(13, 110, 253, 0.2);
}

/* Target CKEditor's image widget wrapper inside slideshow */
.ck-editor__editable .exam-slideshow .image-inline,
.ck-editor__editable .exam-slideshow .ck-widget {
    max-width: 140px !important;
    max-height: 100px !important;
    width: auto !important;
}

/* Target the actual images inside CKEditor widgets in slideshow */
.ck-editor__editable .exam-slideshow .slides img {
    max-width: 140px !important;
    max-height: 100px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.ck-editor__editable .exam-slideshow .slides img:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

/* Hide CKEditor's image resizer handles in slideshow */
.ck-editor__editable .exam-slideshow .ck-widget__resizer {
    display: none !important;
}

.ck-editor__editable .exam-slideshow .slide {
    display: flex !important;
    position: static; /* thumbnails should flow */
    flex: 0 0 auto;
    width: 140px;
    height: 100px;
    overflow: hidden;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    align-items: center;
    justify-content: center;
}

.ck-editor__editable .exam-slideshow .slide img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.ck-editor__editable .exam-slideshow .slide img:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.ck-editor__editable .exam-slideshow .slide:hover {
    border-color: #0d6efd;
    box-shadow: 0 2px 6px rgba(13, 110, 253, 0.2);
}

/* Hide navigation controls in editor */
.ck-editor__editable .exam-slideshow .nav-btn,
.ck-editor__editable .exam-slideshow .dots {
    display: none !important;
}

/* Add a subtle "Slideshow" label in editor */
.ck-editor__editable .exam-slideshow::before {
    content: "Slideshow (" attr(data-slide-count) " images)";
    display: block;
    font-size: 11px;
    color: #6c757d;
    margin-bottom: 6px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
/* Modal thumbnail hover effect */
.slideshow-thumbnail {
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s !important;
}

.slideshow-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    border-color: #0d6efd !important;
}

.slideshow-thumbnail:active {
    transform: scale(0.98);
}

/* Fullscreen slideshow overlay for students */
.slideshow-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10250; /* Must clear .exam-nav-bar (10150) so the presentation isn't blocked by the question-number nav bar */
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slideshow-fullscreen-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 80px 80px;
}

.slideshow-fullscreen-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-height: calc(100vh - 140px);
}

.slideshow-fullscreen-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.slideshow-fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.slideshow-fullscreen-close:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.slideshow-fullscreen-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 36px;
    line-height: 1;
    cursor: pointer;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.slideshow-fullscreen-nav:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-50%) scale(1.1);
}

.slideshow-fullscreen-prev {
    left: 20px;
}

.slideshow-fullscreen-next {
    right: 20px;
}

.slideshow-fullscreen-dots {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 25px;
}

.slideshow-fullscreen-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.2s;
}

.slideshow-fullscreen-dot:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.3);
}

.slideshow-fullscreen-dot.active {
    background: #fff;
    transform: scale(1.2);
}

.slideshow-fullscreen-counter {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* Make slideshow images show pointer cursor to indicate they're clickable */
.exam-slideshow .slide img {
    cursor: pointer;
}
