/*
 * content_insert.css
 * Styles for ContentInsertWorker.js:
 *   - Inserted content wrappers (images, tables, charts)
 *   - Drag handle & drag state
 *   - Column/row resize handles and active state
 *   - Alignment helpers (left / center / right / full)
 *   - Insert dialog (table, chart, image prompts)
 * Does NOT modify styles.css.
 */

/* ══════════════════════════════════════════════════════════════
   WRAPPER — every inserted element lives inside this
   ══════════════════════════════════════════════════════════════ */
.ci-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin: 10px 0;
    vertical-align: top;
    box-sizing: border-box;
    /* Smooth reposition transitions */
    transition: box-shadow 0.15s;
}
.ci-wrapper:hover { outline: 1px dashed var(--accent, #C96A3A); outline-offset: 3px; }

/* ── Alignment variants ─────────────────────────────────────── */
.ci-align-center { display: block; margin-left: auto; margin-right: auto; text-align: center; }
.ci-align-left   { float: left;  margin-right: 16px; margin-bottom: 8px; }
.ci-align-right  { float: right; margin-left: 16px;  margin-bottom: 8px; }
.ci-align-full   { display: block; width: 100%; }

/* ── Caption ────────────────────────────────────────────────── */
.ci-caption {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary, #888);
    font-style: italic;
    margin-top: 4px;
    font-family: 'Nunito', sans-serif;
}

/* ══════════════════════════════════════════════════════════════
   DRAG HANDLE
   ══════════════════════════════════════════════════════════════ */
.ci-drag-handle {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 26px;
    height: 14px;
    background: var(--accent, #C96A3A);
    border-radius: 4px 4px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s;
    user-select: none;
    z-index: 10;
    line-height: 1;
}
.ci-wrapper:hover .ci-drag-handle { opacity: 1; }
.ci-drag-handle:active { cursor: grabbing; }
.ci-dragging {
    opacity: 0.7;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    z-index: 100;
    pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════
   RESIZE HANDLE (corner, for images)
   ══════════════════════════════════════════════════════════════ */
.ci-resize-handle {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    background: var(--accent, #C96A3A);
    border-radius: 0 0 4px 0;
    cursor: se-resize;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 10;
}
.ci-wrapper:hover .ci-resize-handle { opacity: 1; }

/* ══════════════════════════════════════════════════════════════
   TABLE STYLES
   ══════════════════════════════════════════════════════════════ */
.ci-table {
    border-collapse: collapse;
    width: 100%;
    font-family: 'Nunito', sans-serif;
    font-size: 13.5px;
    table-layout: fixed;
}
.ci-table th,
.ci-table td {
    border: 1px solid var(--border, #ddd);
    padding: 7px 10px;
    min-width: 60px;
    outline: none;
    vertical-align: top;
    word-break: break-word;
    position: relative;
    box-sizing: border-box;
}
.ci-table th {
    background: var(--bg-secondary, #f7f7f7);
    font-weight: 700;
    color: var(--text, #222);
    user-select: text;
}
.ci-table td:focus,
.ci-table th:focus {
    background: var(--hover, #f0ece8);
    outline: 2px solid var(--accent, #C96A3A);
    outline-offset: -2px;
}
.ci-table tr:hover td { background: var(--hover, #faf8f6); }

/* ── Column resizer ─────────────────────────────────────────── */
.ci-col-resizer {
    position: absolute;
    top: 0; right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 5;
    transition: background 0.1s;
}
.ci-col-resizer:hover,
.ci-col-resizer.ci-resizing {
    background: var(--accent, #C96A3A);
    opacity: 0.5;
}

/* ── Row resizer ────────────────────────────────────────────── */
.ci-row-resizer {
    position: absolute;
    bottom: -3px; left: 0;
    width: 100%;
    height: 6px;
    cursor: row-resize;
    background: transparent;
    z-index: 5;
    transition: background 0.1s;
}
.ci-row-resizer:hover,
.ci-row-resizer.ci-resizing {
    background: var(--accent, #C96A3A);
    opacity: 0.5;
}

/* ══════════════════════════════════════════════════════════════
   IMAGE WRAPPER
   ══════════════════════════════════════════════════════════════ */
.ci-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    pointer-events: none; /* let wrapper handle events */
}
.ci-image-wrap { cursor: default; }

/* ══════════════════════════════════════════════════════════════
   CHART AREA
   ══════════════════════════════════════════════════════════════ */
.ci-chart-area { display: block; overflow: hidden; border-radius: 8px; }
.ci-chart-loading {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary, #888);
    font-style: italic;
    font-size: 13px;
    font-family: 'Nunito', sans-serif;
}
.ci-svg { display: block; }

/* D3 axis text */
.ci-axis text {
    font-family: 'Nunito', sans-serif;
    font-size: 11px;
    fill: var(--text-secondary, #888);
}
.ci-axis line,
.ci-axis path { stroke: var(--border, #ddd); }

/* ══════════════════════════════════════════════════════════════
   INSERT DIALOG  (table / chart / image prompt)
   ══════════════════════════════════════════════════════════════ */
.ci-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ci-fade-in 0.12s ease;
}
@keyframes ci-fade-in { from { opacity:0 } to { opacity:1 } }

.ci-dialog-box {
    background: var(--bg-secondary, #fff);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 14px;
    padding: 24px 28px 20px;
    min-width: 340px;
    max-width: 480px;
    width: 90vw;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    animation: ci-slide-in 0.14s ease;
}
@keyframes ci-slide-in { from { transform:translateY(10px);opacity:0 } to { transform:none;opacity:1 } }

.ci-dialog-title {
    font-family: 'Nunito', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text, #222);
    margin-bottom: 18px;
}

.ci-dialog-fields { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }

.ci-dialog-label {
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 6px;
}

.ci-dialog-input {
    padding: 8px 12px;
    border: 1px solid var(--border, #ddd);
    border-radius: 7px;
    background: var(--bg, #fff);
    color: var(--text, #222);
    font-family: 'Nunito', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
    box-sizing: border-box;
}
.ci-dialog-input:focus { border-color: var(--accent, #C96A3A); }
select.ci-dialog-input { appearance: auto; }

.ci-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.ci-dialog-btn {
    padding: 8px 20px;
    border-radius: 7px;
    border: 1px solid var(--border, #ddd);
    font-family: 'Nunito', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s;
}
.ci-dialog-cancel {
    background: var(--bg, #fff);
    color: var(--text-secondary, #666);
}
.ci-dialog-cancel:hover { background: var(--hover, #f5f5f5); }
.ci-dialog-ok {
    background: var(--accent, #C96A3A);
    color: #fff;
    border-color: var(--accent, #C96A3A);
}
.ci-dialog-ok:hover { opacity: 0.88; }

.ci-resize-se { position:absolute;bottom:-4px;right:-4px;width:14px;height:14px;background:var(--accent,#C96A3A);border-radius:0 0 4px 0;cursor:se-resize;opacity:0;transition:opacity 0.15s;z-index:15; }
.ci-wrapper:hover .ci-resize-se { opacity:1; }

/* ══════════════════════════════════════════════════════════════
   BLOCK MODEL DRAG HANDLE  (eb-figure, eb-table-wrap)
   ══════════════════════════════════════════════════════════════
   Replaces the old absolute-positioned .ci-drag-handle.
   Displayed via canvas_editor.css .eb-block-drag-handle rules.
   These rules ensure the handle also works on legacy .ci-wrapper. */

.ci-wrapper .eb-block-drag-handle {
    top: 4px;
    left: -26px;
    opacity: 0;
    transition: opacity 0.15s;
}
.ci-wrapper:hover .eb-block-drag-handle { opacity: 1; }

/* ══════════════════════════════════════════════════════════════
   WINDOWS-STYLE RESIZE LINES  (updated)
   Persistent 1px lines on col/row edges, accent on hover.
   ══════════════════════════════════════════════════════════════ */

/* Override old transparent ci-col/row resizers with always-visible lines */
.ci-col-resizer {
    position: absolute;
    top: 0; right: 0;
    width: 4px; height: 100%;
    cursor: col-resize;
    z-index: 5;
    border-right: 1px solid var(--border, #ddd);
    background: transparent;
    transition: border-color 0.1s, background 0.1s;
}
.ci-col-resizer:hover,
.ci-col-resizer.ci-resizing {
    background: color-mix(in srgb, var(--accent, #C96A3A) 25%, transparent);
    border-right: 2px solid var(--accent, #C96A3A);
}

.ci-row-resizer {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%; height: 4px;
    cursor: row-resize;
    z-index: 5;
    border-bottom: 1px solid var(--border, #ddd);
    background: transparent;
    transition: border-color 0.1s, background 0.1s;
}
.ci-row-resizer:hover,
.ci-row-resizer.ci-resizing {
    background: color-mix(in srgb, var(--accent, #C96A3A) 25%, transparent);
    border-bottom: 2px solid var(--accent, #C96A3A);
}