/* AI-powered columns */

.bd-ai-th { background: #eef4ff; }
/* Inner flex row keeps the ▶ anchored when the column is too narrow for the
   full label — without this the <th>'s overflow:hidden clips the rightmost
   child (the run button) and the user can't trigger the column. Flex lives
   on the wrapper, not the <th> itself, so DataTables sort markers stay put. */
.bd-ai-th-inner {
    display: inline-flex; align-items: center; gap: 4px;
    max-width: 100%; vertical-align: middle;
}
.bd-ai-pill {
    display: inline-block; font-size: 11px; padding: 2px 6px;
    background: #4a6cf7; color: #fff; border-radius: 10px;
    flex: 0 0 auto;
}
.bd-ai-th-label {
    cursor: pointer; text-decoration: underline dotted;
    flex: 1 1 auto; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bd-ai-th-label:hover { color: #4a6cf7; }

.bd-ai-play {
    border: 0; background: transparent; cursor: pointer;
    color: #4a6cf7; font-size: 13px; padding: 0 4px;
    flex: 0 0 auto;
}
.bd-ai-play:hover { color: #1e3fc0; }
.bd-ai-cell { cursor: pointer; position: relative; }
.bd-ai-cell-overlay {
    position: absolute; top: 2px; right: 4px;
    pointer-events: auto; user-select: none;
}
.bd-ai-play-cell { visibility: hidden; }
.bd-ai-cell:hover .bd-ai-play-cell { visibility: visible; }
.bd-ai-status {
    position: absolute; inset: 0;
    display: none;
    align-items: center; justify-content: center;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border-radius: 2px;
    font-size: 12px; font-weight: 500;
}
.bd-ai-cell.bd-ai-running .bd-ai-status,
.bd-ai-cell.bd-ai-error   .bd-ai-status,
.bd-ai-cell.bd-ai-success .bd-ai-status { display: flex; }

/* Fallback for browsers without backdrop-filter — blur the underlying value instead. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .bd-ai-cell.bd-ai-running .bd-ai-value,
    .bd-ai-cell.bd-ai-success .bd-ai-value,
    .bd-ai-cell.bd-ai-error   .bd-ai-value { filter: blur(2px); }
}

.bd-ai-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    margin-right: 6px; vertical-align: middle;
}
.bd-ai-dot.is-running { background: #f0ad4e; animation: bd-ai-pulse 1s infinite; }
.bd-ai-dot.is-success { background: #5cb85c; }
.bd-ai-dot.is-error   { background: #d9534f; }
@keyframes bd-ai-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.bd-ai-stage { color: #555; font-style: italic; }
/* The cell-level background tints are no longer needed — the status overlay handles it. */
.bd-ai-running, .bd-ai-error { background: transparent; }

#bd-ai-panel {
    position: fixed; top: 0; right: 0; width: 380px; height: 100vh;
    background: #fff; box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    border-left: 1px solid #ddd; z-index: 1050; overflow-y: auto;
    display: flex; flex-direction: column;
}
#bd-ai-panel[hidden] { display: none; }
#bd-ai-panel header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; border-bottom: 1px solid #eee; font-weight: 600;
}
#bd-ai-panel .bd-ai-close {
    border: 0; background: transparent; font-size: 22px; cursor: pointer; line-height: 1;
}
.bd-ai-panel-body { padding: 14px; }
.bd-ai-panel-body label { display: block; font-size: 12px; color: #666; margin-top: 10px; }
.bd-ai-input { width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; }
.bd-ai-actions { margin-top: 14px; display: flex; gap: 8px; }
.bd-ai-actions button { padding: 6px 12px; border: 0; border-radius: 4px; cursor: pointer; }
.bd-ai-actions .bd-ai-save { background: #4a6cf7; color: #fff; }
.bd-ai-actions .bd-ai-runall { background: #5cb85c; color: #fff; }
.bd-ai-pre {
    background: #f6f8fa; padding: 8px; border-radius: 4px; font-size: 12px;
    white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow: auto;
}
.bd-ai-loading { color: #888; }
.bd-ai-check-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; padding: 6px 0; }
.bd-ai-check { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.bd-ai-error-msg { color: #d9534f; font-size: 12px; margin-top: 8px; }
.bd-ai-compat {
    margin-top: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.4;
    color: #8a6d3b; background: #fcf8e3; border: 1px solid #faebcc; border-radius: 4px;
}

/* Custom "+ Column" menu — Bootstrap's dropdown wrapper conflicted with the sidebar's
 * btn-group rules, so the trigger is just a plain LinkBuilder button and this is a
 * sibling popover toggled by JS. */
.bd-ai-add-column { position: relative; display: inline-block; }
.bd-ai-add-column-menu {
    position: absolute; top: 100%; left: 0; z-index: 1000;
    background: #fff; min-width: 200px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 6px; padding: 6px 0;
    margin-top: 4px;
}
.bd-ai-menu-item {
    display: block; padding: 8px 14px; color: #212529 !important;
    text-decoration: none; font-size: 13px;
}
.bd-ai-menu-item:hover { background: #f0f4ff; color: #212529 !important; text-decoration: none; }

/* Run confirmation rendered inside the right panel (replaces the old modal). */
.bd-ai-balance { color: #333; margin: 12px 0; }
.bd-ai-choice {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border: 1px solid #e3e8f0; border-radius: 6px; margin-bottom: 8px;
}
.bd-ai-choice.is-blocked { background: #fafafa; opacity: 0.7; }
.bd-ai-choice-info strong { display: block; font-size: 14px; }
.bd-ai-choice-info small { color: #666; }
.bd-ai-choice-btn {
    border: 0; background: #4a6cf7; color: #fff; padding: 6px 12px;
    border-radius: 4px; cursor: pointer; font-size: 13px;
}
.bd-ai-choice-btn[disabled] { background: #bbb; cursor: not-allowed; }
.bd-ai-insufficient { color: #b45309; margin-top: 12px; font-size: 13px; }
