/* General Layout */
body { background-color: #f8f9fa; }
#editor-workspace, #debug-area { display: none; }

/* Projects List */
.projects-container {
    max-height: 400px;
    overflow-y: auto;
}

.project-item {
    padding: 12px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.project-item:hover {
    background: #e9ecef;
    border-color: #0066cc;
    transform: translateX(5px);
}

.project-item .project-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.project-item .project-meta {
    font-size: 0.85rem;
    color: #6c757d;
}

.project-item .project-stats {
    display: flex;
    gap: 15px;
    margin-top: 5px;
    font-size: 0.85rem;
}

.project-item .badge {
    font-size: 0.75rem;
}

/* Chapter automation */
.chapter-marker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
}

.chapter-status {
    flex-grow: 1;
    margin-left: 1rem;
    font-size: 0.85em;
    color: #666;
    font-style: italic;
}

.chapter-controls {
    display: flex;
    gap: 0.25rem;
}

.automate-chapter {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    border: none;
    transition: all 0.3s ease;
}

.automate-chapter:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.dropdown-menu {
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.dropdown-item:hover {
    background-color: #f8f9fa;
}

.chapter-group[style*="opacity: 0.6"] {
    cursor: not-allowed;
}

/* Auto Structure button - make it contextual */
#auto-structure-btn {
    transition: all 0.3s ease;
    position: relative;
}

#auto-structure-btn:not(:disabled):hover {
    transform: scale(1.05);
}

#auto-structure-btn .structure-icon {
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Navigation Bar with Save Button */
#save-btn {
    transition: opacity 0.3s ease;
}
#save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
#save-btn .save-icon {
    margin-right: 5px;
}

/* Slide Bank Tabs */
#slide-bank-tabs {
    margin-bottom: 0;
}

#slide-bank-tabs .nav-link {
    padding: 0.25rem 0.75rem;
    font-size: 0.9rem;
}

/* Documents List */
.documents-list {
    padding: 10px;
    background-color: #e9ecef;
    border-radius: 0.25rem;
    height: 65vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.document-folder {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    margin-bottom: 10px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.document-folder:hover {
    background: #f8f9fa;
    border-color: #6c757d;
}

.document-folder.expanded {
    background: #e7f3ff;
    border-color: #0066cc;
}

.document-folder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 500;
    color: #333;
}

.document-folder-icon {
    margin-right: 5px;
}

.document-slides {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #dee2e6;
}

.document-slides.show {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}

.document-slide-thumb {
    padding: 3px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.15rem;
    cursor: grab;
    text-align: center;
    transition: transform 0.2s;
    font-size: 0.75rem;
}

.document-slide-thumb:hover {
    transform: scale(1.05);
    border-color: #0066cc;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Visual indicator for assigned slides */
.document-slide-thumb.assigned {
    background: #e7f3ff;
    border-color: #28a745;
}

.document-slide-thumb.assigned div {
    color: #28a745;
    font-weight: 600;
}

/* Slide Bank - Grid Layout for Orphan Slides */
.slide-bank-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: min-content; /* Align items to top */
    gap: 8px;
    padding: 10px;
    background-color: #e9ecef;
    border-radius: 0.25rem;
    height: 65vh;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    align-content: start; /* Align content to top */
}

.slide-bank-thumbnail {
    padding: 5px 5px 3px 5px;
    background-color: white;
    border-radius: 0.25rem;
    cursor: grab;
    text-align: center;
    border: 2px solid #dc3545; /* Red for unassigned */
    position: relative;
    transition: transform 0.2s;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 90px;
    height: auto;
}

.slide-bank-thumbnail:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 5;
}

.slide-bank-thumbnail .btn-close {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid #dc3545;
    border-radius: 50%;
    padding: 0;
    z-index: 10;
    font-size: 0.7em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.slide-bank-thumbnail .btn-control {
    width: 18px;
    height: 18px;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid #dee2e6;
    border-radius: 3px;
    padding: 0;
    font-size: 0.65em;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.slide-bank-thumbnail .btn-control.btn-edit {
    border-color: #0d6efd;
    color: #0d6efd;
}

.slide-bank-thumbnail:hover .btn-close {
    opacity: 1;
}

.slide-bank-thumbnail img {
    width: 100%;
    height: 60px;
    object-fit: contain;
    border-radius: 0.2rem;
    margin-bottom: 3px;
    background-color: #f8f9fa;
}

.slide-bank-thumbnail .slide-title {
    font-size: 0.7em;
    font-weight: 600;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    padding: 2px;
    line-height: 1.1;
    margin: 0;
}

/* Controls Container in Slide Bank */
.slide-bank-grid .controls-container {
    grid-column: 1 / -1; /* Span both columns for the button */
    margin-bottom: 5px;
}

.slide-bank-grid .controls-container .btn {
    width: 100%;
    padding: 6px 12px;
    font-size: 0.85em;
}

/* Work Area */
#work-area {
    min-height: 60vh;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
}

.chapter-group {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chapter-header {
    margin-bottom: 10px;
}

.chapter-marker {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 0.25rem 0.25rem 0 0;
    margin-bottom: 0;
}

/* Chapter Summary Styles */
.chapter-summary {
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.25rem 0.25rem;
    padding: 12px 15px;
    margin-bottom: 10px;
    position: relative;
    transition: all 0.3s ease;
}

.chapter-summary:hover {
    background: linear-gradient(135deg, #ffffff 0%, #f1f3f5 100%);
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}

.summary-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.summary-text {
    flex: 1;
    font-size: 0.9em;
    line-height: 1.4;
    color: #495057;
    font-style: italic;
    padding: 3px 0;
}

.btn-edit-summary {
    opacity: 0;
    transition: opacity 0.2s;
    background: white;
    border: 1px solid #6c757d;
    color: #6c757d;
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 0.8em;
    cursor: pointer;
}

.chapter-summary:hover .btn-edit-summary {
    opacity: 1;
}

.btn-edit-summary:hover {
    background: #6c757d;
    color: white;
}

/* Summary editor textarea */
.summary-editor {
    font-size: 0.9em;
    line-height: 1.4;
    font-style: italic;
    border: 2px solid #667eea;
    border-radius: 4px;
    padding: 5px 8px;
    width: 100%;
    resize: vertical;
    min-height: 50px;
}

.summary-editor:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 0.2rem rgba(118, 75, 162, 0.25);
}

.chapter-controls button {
    margin-left: 5px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chapter-controls button:hover {
    opacity: 1;
}

.slide-container {
    min-height: 120px;
    border: 2px dashed #ccc;
    border-radius: 0.25rem;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background-color: #f8f9fa;
}

.work-area-slide {
    width: 160px;  /* Increased width for better thumbnail visibility */
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 5px;
    cursor: grab;
    display: flex;
    flex-direction: column;
    text-align: center;
    position: relative;
    transition: transform 0.2s;
}

.work-area-slide:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.work-area-slide img {
    width: 100%;
    height: 100px;  /* Increased height for better visibility */
    object-fit: contain;  /* Preserve aspect ratio */
    background-color: #f8f9fa;  /* Light gray background for images */
    border-radius: 0.2rem;
    margin-bottom: 5px;
    image-rendering: -webkit-optimize-contrast;  /* Better rendering quality */
    image-rendering: crisp-edges;  /* Fallback for other browsers */
}

.work-area-slide .slide-title {
    font-size: 0.75em;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.work-area-slide .slide-controls {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.work-area-slide:hover .slide-controls {
    opacity: 1;
}

.work-area-slide .btn-control {
    width: 20px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid #dee2e6;
    border-radius: 3px;
    padding: 0;
    font-size: 0.7em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.work-area-slide .btn-control:hover {
    background-color: #fff;
    transform: scale(1.1);
}

.work-area-slide .btn-edit {
    border-color: #0d6efd;
    color: #0d6efd;
}

.work-area-slide .btn-remove {
    border-color: #dc3545;
    color: #dc3545;
}

.work-area-slide .btn-preview {
    border-color: #28a745;
    color: #28a745;
}

.work-area-slide .btn-preview:hover {
    background-color: #28a745;
    color: white;
}

.slide-bank-thumbnail .btn-preview {
    border-color: #28a745;
    color: #28a745;
}

.slide-bank-thumbnail .btn-preview:hover {
    background-color: #28a745;
    color: white;
}

/* Quiz Thumbnail */
.quiz-thumbnail {
    width: 140px;
    background: linear-gradient(135deg, #1e1e1e 0%, #3a3a3a 100%);
    border: 2px solid #ffc107;
    border-radius: 0.25rem;
    padding: 15px 5px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    transition: all 0.3s;
    color: white;
    min-height: 100px;
}

.quiz-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(255, 193, 7, 0.3);
    background: linear-gradient(135deg, #2a2a2a 0%, #4a4a4a 100%);
}

.quiz-thumbnail .quiz-icon {
    font-size: 1.5em;
    margin-bottom: 5px;
}

.quiz-thumbnail .quiz-label {
    font-size: 0.9em;
    font-weight: bold;
    margin-bottom: 3px;
}

.quiz-thumbnail .quiz-count {
    font-size: 0.75em;
    opacity: 0.9;
}

/* Bottom Inspector Panel */
.inspector-panel {
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 10px;
}

.inspector-panel .nav-tabs {
    border-bottom: 2px solid #dee2e6;
}

.inspector-panel pre {
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.85em;
}

/* Quiz Modal Styles */
#quizModal .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

.quiz-question {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 0.25rem;
}

.quiz-question input,
.quiz-question select,
.quiz-question textarea {
    margin-bottom: 10px;
}

.quiz-choice {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.quiz-choice input[type="text"] {
    flex: 1;
}

/* Utility Classes */
.dragging {
    opacity: 0.5;
}

.drag-over {
    background-color: #e3f2fd !important;
    border-color: #2196f3 !important;
}

/* Fix Sortable dragging issues */
.slide-bank-thumbnail.sortable-ghost {
    opacity: 0.4;
}

.slide-bank-thumbnail.sortable-drag {
    opacity: 0.8;
}

/* Ensure no horizontal scroll */
#slide-bank {
    box-sizing: border-box;
}

#slide-bank * {
    box-sizing: border-box;
}

/* Text message styles */
.slide-bank-grid .text-center {
    grid-column: 1 / -1;
    padding: 20px;
}

/* Extracted Images Grid */
.images-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 10px;
    background-color: #e9ecef;
    border-radius: 0.25rem;
    height: 65vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.image-thumbnail {
    background: white;
    border: 2px solid #17a2b8;
    border-radius: 0.25rem;
    padding: 5px;
    cursor: grab;
    position: relative;
    transition: all 0.2s;
}

.image-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 10;
}

.image-thumbnail img {
    width: 100%;
    height: auto;
    border-radius: 0.2rem;
}

.image-thumbnail .image-info {
    font-size: 0.7em;
    text-align: center;
    margin-top: 3px;
    color: #666;
}

.image-thumbnail .image-controls {
    position: absolute;
    top: 3px;
    right: 3px;
    display: flex;
    gap: 3px;
    opacity: 0;
    transition: opacity 0.2s;
}

.image-thumbnail:hover .image-controls {
    opacity: 1;
}

.image-thumbnail .btn-control {
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #17a2b8;
    border-radius: 3px;
    padding: 0;
    font-size: 0.7em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #17a2b8;
}

.image-thumbnail .btn-control:hover {
    background: #17a2b8;
    color: white;
}

#images-tab-badge {
    display: inline-block;
}

#images-tab .badge {
    margin-left: 5px;
    background-color: #17a2b8;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .slide-bank-grid {
        grid-template-columns: 1fr;
    }
    
    .work-area-slide,
    .quiz-thumbnail {
        width: 120px;
    }
    
    .slide-bank-thumbnail {
        height: 100px;
    }
}