/* ===================================================================
   INLINE WYSIWYG BLOCK EDITOR STYLES
   Notion/Gutenberg-style inline editing — dark theme
   =================================================================== */

/* === Container === */
.inline-editor-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #0d1117;
    color: #c9d1d9;
    overflow: hidden;
}

/* === Top Toolbar === */
.ie-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 1rem;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
    z-index: 100;
    gap: 0.5rem;
}

.ie-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
}

.ie-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.ie-lesson-picker {
    max-width: 320px;
    background: #0d1117;
    color: #c9d1d9;
    border-color: #30363d;
    font-size: 0.85rem;
}

.ie-toolbar-title {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ie-save-status {
    font-size: 0.78rem;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    transition: all 0.2s;
}

.ie-status-saving {
    color: #e3b341;
}

.ie-status-saved {
    color: #3fb950;
}

.ie-status-error {
    color: #f85149;
}

/* === Canvas (scrollable content area) === */
.ie-canvas {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.ie-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
}

/* === Block wrapper === */
.ie-block {
    position: relative;
    border-radius: 6px;
    padding: 4px 40px;
    margin: 2px 0;
    border: 2px solid transparent;
    transition: border-color 0.15s, box-shadow 0.15s;
    cursor: default;
}

.ie-block-hovered {
    border-color: rgba(139, 148, 158, 0.3);
    border-style: dashed;
}

.ie-block-selected {
    border-color: #ff8c00;
    border-style: solid;
    box-shadow: 0 0 0 1px rgba(255, 140, 0, 0.2);
}

/* === Drag handle (left gutter) === */
.ie-drag-handle {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    color: #484f58;
    cursor: grab;
    font-size: 1.1rem;
    padding: 4px 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
    z-index: 2;
}

.ie-drag-handle:hover {
    color: #8b949e;
    background: #21262d;
}

.ie-drag-handle:active {
    cursor: grabbing;
}

/* === Action buttons (right gutter) === */
.ie-block-actions {
    position: absolute;
    right: 4px;
    top: 4px;
    display: flex;
    gap: 2px;
    z-index: 2;
}

.ie-action-btn {
    padding: 3px 6px;
    background: #21262d;
    border: 1px solid #30363d;
    color: #8b949e;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.15s;
    line-height: 1;
}

.ie-action-btn:hover {
    background: #30363d;
    color: #c9d1d9;
}

.ie-action-delete:hover {
    color: #f85149;
    border-color: #f85149;
}

/* === Insert line between blocks === */
.ie-insert-line {
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ie-insert-indicator {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ie-insert-hr {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    background: rgba(255, 140, 0, 0.3);
    border-radius: 1px;
}

.ie-insert-btn {
    position: relative;
    z-index: 2;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #21262d;
    border: 2px solid #ff8c00;
    color: #ff8c00;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0;
    transition: all 0.15s;
}

.ie-insert-btn:hover {
    background: #ff8c00;
    color: #000;
}

/* === Insert menu (block type picker) === */
.ie-insert-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    min-width: 420px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 200;
    animation: ieMenuFadeIn 0.1s ease;
}

@keyframes ieMenuFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.ie-insert-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #c9d1d9;
    cursor: pointer;
    font-size: 0.7rem;
    transition: all 0.1s;
}

.ie-insert-menu-item:hover {
    background: #30363d;
    border-color: #ff8c00;
    color: #ff8c00;
}

.ie-insert-menu-item i {
    font-size: 1.1rem;
}

/* === Contenteditable blocks === */
.ie-contenteditable {
    outline: none;
    min-height: 1em;
    word-break: break-word;
}

.ie-contenteditable:focus {
    outline: none;
}

.ie-contenteditable[contenteditable="true"] {
    cursor: text;
}

.ie-text-block {
    font-size: 1rem;
    line-height: 1.7;
    color: #c9d1d9;
}

.ie-text-block p {
    margin-bottom: 0.75rem;
}

.ie-text-block p:last-child {
    margin-bottom: 0;
}

.ie-text-block a {
    color: #ff8c00;
    text-decoration: underline;
}

.ie-text-block strong {
    color: #fff;
}

.ie-column {
    min-height: 40px;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid transparent;
}

.ie-column[contenteditable="true"] {
    border-color: rgba(255, 140, 0, 0.2);
}

/* === Heading controls === */
.ie-heading-controls {
    margin-bottom: 4px;
}

.ie-heading-level-select {
    background: #21262d;
    border: 1px solid #30363d;
    color: #ff8c00;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.ie-heading-level-select:focus {
    border-color: #ff8c00;
    outline: none;
}

/* === Overlay controls (for non-text blocks when selected) === */
.ie-overlay-controls {
    margin-top: 8px;
    padding: 10px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
}

.ie-overlay-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ie-overlay-input {
    width: 100%;
    background: #0d1117;
    border: 1px solid #30363d;
    color: #c9d1d9;
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 4px;
}

.ie-overlay-input:focus {
    border-color: #ff8c00;
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 140, 0, 0.15);
}

.ie-overlay-check {
    font-size: 0.85rem;
    color: #8b949e;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* === Card grid editing === */
.ie-card-input {
    width: 100%;
    background: #0d1117;
    border: 1px solid #30363d;
    color: #c9d1d9;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
}

.ie-card-input:focus {
    border-color: #ff8c00;
    outline: none;
}

.ie-card-input.ie-card-title {
    color: #ff8c00;
    font-weight: 600;
    font-size: 0.9rem;
}

.ie-card-remove-btn {
    background: none;
    border: none;
    color: #f85149;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 4px;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.ie-card-remove-btn:hover {
    opacity: 1;
}

.ie-add-card-btn {
    display: block;
    margin: 8px auto 0;
    background: transparent;
    border: 1px dashed #30363d;
    color: #8b949e;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.ie-add-card-btn:hover {
    border-color: #ff8c00;
    color: #ff8c00;
}

/* === Accordion editing === */
.ie-accordion-section {
    background: #16213e;
    border: 1px solid #2a3a5c;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.ie-accordion-title-input {
    background: transparent;
    border: 1px solid transparent;
    color: #ff8c00;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 2px 6px;
    border-radius: 4px;
    flex: 1;
}

.ie-accordion-title-input:focus {
    border-color: #ff8c00;
    outline: none;
    background: #0d1117;
}

.ie-accordion-content-input {
    width: 100%;
    background: #0d1117;
    border: 1px solid #30363d;
    color: #ccc;
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 4px;
    resize: vertical;
}

.ie-accordion-content-input:focus {
    border-color: #ff8c00;
    outline: none;
}

/* === Floating text toolbar === */
.ie-text-toolbar {
    position: fixed;
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    animation: ieToolbarFadeIn 0.1s ease;
}

@keyframes ieToolbarFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.ie-tt-btn {
    padding: 4px 8px;
    background: transparent;
    border: none;
    color: #c9d1d9;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: all 0.1s;
    line-height: 1;
}

.ie-tt-btn:hover {
    background: #30363d;
    color: #ff8c00;
}

.ie-tt-divider {
    width: 1px;
    height: 18px;
    background: #30363d;
    margin: 0 2px;
}

/* === Block renderer styles (student-facing, also used in editor preview) === */
.lesson-block-renderer {
    max-width: 900px;
    margin: 0 auto;
}

.lesson-block {
    margin-bottom: 1rem;
}

.lesson-block .block-heading {
    color: #ff8c00;
    margin: 1rem 0 0.5rem;
}

.lesson-block .block-image {
    margin: 1rem auto;
}

.lesson-block .block-image figcaption {
    text-align: center;
    font-size: 0.85rem;
    color: #8b949e;
    margin-top: 0.5rem;
    font-style: italic;
}

/* === Responsive === */
@media (max-width: 768px) {
    .ie-canvas {
        padding: 1rem 0.5rem;
    }

    .ie-block {
        padding: 4px 30px;
    }

    .ie-insert-menu {
        min-width: 300px;
        grid-template-columns: repeat(3, 1fr);
    }

    .ie-toolbar {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .ie-lesson-picker {
        max-width: 200px;
    }

    .ie-text-toolbar {
        left: 50% !important;
        transform: translateX(-50%);
    }
}

@media (max-width: 480px) {
    .ie-insert-menu {
        min-width: 240px;
        grid-template-columns: repeat(2, 1fr);
    }
}

/* === Asset Library Panel === */
.ie-asset-library {
    display: flex;
    gap: 0;
    padding: 0;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
    overflow-x: auto;
    max-height: 160px;
}

.ie-asset-category {
    display: flex;
    flex-direction: column;
    min-width: 200px;
    border-right: 1px solid #30363d;
    flex-shrink: 0;
}

.ie-asset-category:last-child {
    border-right: none;
}

.ie-asset-category-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #8b949e;
    padding: 6px 10px 2px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.ie-asset-scroll {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 8px 8px;
    overflow-y: auto;
    max-height: 120px;
}

.ie-asset-card {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: #c9d1d9;
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.ie-asset-card:hover {
    background: #21262d;
    border-color: #ff8c00;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(255,140,0,0.15);
}

.ie-asset-card:active {
    transform: translateY(0);
}

.ie-asset-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}
