/* AudioBook Organizer - Theme and Color Styles */

/* Section Colors */
.section-color-1 {
    background-color: var(--section-color-1) !important;
    border-left: 4px solid #ffb74d !important;
}

.section-color-2 {
    background-color: var(--section-color-2) !important;
    border-left: 4px solid #81c784 !important;
}

.section-color-3 {
    background-color: var(--section-color-3) !important;
    border-left: 4px solid #64b5f6 !important;
}

.section-color-4 {
    background-color: var(--section-color-4) !important;
    border-left: 4px solid #f06292 !important;
}

.section-color-5 {
    background-color: var(--section-color-5) !important;
    border-left: 4px solid #a1887f !important;
}

.section-color-6 {
    background-color: var(--section-color-6) !important;
    border-left: 4px solid #4dd0e1 !important;
}

.section-color-7 {
    background-color: var(--section-color-7) !important;
    border-left: 4px solid #ba68c8 !important;
}

.section-color-8 {
    background-color: var(--section-color-8) !important;
    border-left: 4px solid #7986cb !important;
}

/* Selection colors matching section colors */
.color-1-selection ::selection {
    background-color: var(--section-color-1) !important;
}

.color-2-selection ::selection {
    background-color: var(--section-color-2) !important;
}

.color-3-selection ::selection {
    background-color: var(--section-color-3) !important;
}

.color-4-selection ::selection {
    background-color: var(--section-color-4) !important;
}

.color-5-selection ::selection {
    background-color: var(--section-color-5) !important;
}

.color-6-selection ::selection {
    background-color: var(--section-color-6) !important;
}

.color-7-selection ::selection {
    background-color: var(--section-color-7) !important;
}

.color-8-selection ::selection {
    background-color: var(--section-color-8) !important;
}

/* Color indicator in sections list */
.color-indicator {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    margin-right: var(--spacing-sm);
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}

/* Next color preview */
.next-color-preview {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: var(--background-light);
}

.color-preview-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
}

/* ✅ FIXED: Section highlight in book content (unified definition) */
/* The structure is: <span class="section-highlight section-color-X"><span class="fmt-title">Text</span></span> */

.section-highlight {
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    position: relative;
    /* Force display as block for formatted content */
    display: block !important;
    /* Add margin for spacing */
    margin: 4px 0 !important;
}

.section-highlight:hover {
    filter: brightness(0.95);
}

/* ✅ CRITICAL: Override formatted text margins/padding inside section highlights */
.section-highlight .fmt-title,
.section-highlight .fmt-subtitle,
.section-highlight .fmt-section,
.section-highlight .fmt-subsection {
    /* Remove default margins that formatted text usually has */
    margin: 0 !important;
    /* Remove padding to prevent double-padding */
    padding: 0 !important;
    /* Make sure background is transparent so parent color shows */
    background: transparent !important;
    /* Keep the text formatting but remove spacing */
    display: block !important;
}

/* ✅ DEBUGGING: Force section highlights to be visible with higher specificity */
.section-highlight.section-color-1 {
    background-color: var(--section-color-1) !important;
    border-left: 4px solid #ffb74d !important;
}

.section-highlight.section-color-2 {
    background-color: var(--section-color-2) !important;
    border-left: 4px solid #81c784 !important;
}

.section-highlight.section-color-3 {
    background-color: var(--section-color-3) !important;
    border-left: 4px solid #64b5f6 !important;
}

.section-highlight.section-color-4 {
    background-color: var(--section-color-4) !important;
    border-left: 4px solid #f06292 !important;
}

.section-highlight.section-color-5 {
    background-color: var(--section-color-5) !important;
    border-left: 4px solid #a1887f !important;
}

.section-highlight.section-color-6 {
    background-color: var(--section-color-6) !important;
    border-left: 4px solid #4dd0e1 !important;
}

.section-highlight.section-color-7 {
    background-color: var(--section-color-7) !important;
    border-left: 4px solid #ba68c8 !important;
}

.section-highlight.section-color-8 {
    background-color: var(--section-color-8) !important;
    border-left: 4px solid #7986cb !important;
}

/* ✅ RESTORED: Proper section highlight styling */

/* ✅ NEW: Section highlight protection in edit mode */
.book-content.edit-mode .section-highlight {
    /* Make section highlights non-editable */
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    
    /* Visual indication that it's protected */
    position: relative;
    cursor: not-allowed !important;
    
    /* Add a subtle border to indicate protection */
    border: 2px dashed rgba(255, 152, 0, 0.6) !important;
    
    /* Prevent text editing */
    pointer-events: none !important;
}

/* ✅ NEW: Add protection indicator */
.book-content.edit-mode .section-highlight::before {
    content: "🔒";
    position: absolute;
    top: -2px;
    right: -2px;
    background: rgba(255, 152, 0, 0.9);
    color: white;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 3px;
    z-index: 10;
    pointer-events: none;
}

/* ✅ NEW: Override formatted text editability inside protected highlights */
.book-content.edit-mode .section-highlight .fmt-title,
.book-content.edit-mode .section-highlight .fmt-subtitle,
.book-content.edit-mode .section-highlight .fmt-section,
.book-content.edit-mode .section-highlight .fmt-subsection,
.book-content.edit-mode .section-highlight * {
    /* Disable all editing */
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
}

/* ✅ NEW: Show hover message */
.book-content.edit-mode .section-highlight:hover::after {
    content: "Delete section to edit this text";
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
}

.section-highlight::after {
    content: '';
    position: absolute;
    right: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: inherit;
    border: 1px solid rgba(0,0,0,0.1);
}

.section-highlight.flash {
    animation: flash-highlight 1s ease-in-out;
}

/* Drag and Drop Styles */
.dragging {
    opacity: 0.6;
    cursor: move;
    box-shadow: var(--shadow-lg);
    background: white;
    position: relative;
    z-index: 100;
}

.drag-over {
    border: 2px dashed var(--primary-color);
    padding: var(--spacing-sm);
    margin: 8px 0;
    border-radius: var(--radius-sm);
    background: rgba(var(--primary-color-rgb), 0.05);
}

.drag-handle {
    cursor: move;
    padding: 4px;
    margin-right: var(--spacing-sm);
    color: var(--text-secondary);
    opacity: 0.6;
    transition: opacity 0.2s;
}

.section-item:hover .drag-handle {
    opacity: 1;
}

.drag-placeholder {
    border: 2px dashed var(--border-color);
    margin: var(--spacing-sm) 0;
    height: 80px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.02);
} 