/* AAAB visual overrides for the entities5 prototype.
   Goals:
     - Hide the C#.NET tab + view + modal (Laravel-only).
     - Hide the project-header buttons in .tab-container (Save As / Info /
       Load Project) — AAAB owns persistence; auto-load + the slim Save
       button injected by aaab-bootstrap.js are enough.
     - Hide Import/Export Entities buttons (project is AAAB-scoped).
     - Restyle .tab, .toolbar, .toolbar-btn with a slim modern Flux-ish
       look that visually matches the host AAAB app.
*/

/* ── Hide cnet ── */
.tab[onclick*="'cnet'"] { display: none !important; }
#cnet-view { display: none !important; }
#cnetConfigModal { display: none !important; }

/* ── Hide the entire right-side project-button block in .tab-container.
       The block is an inline-styled <div style="margin-left:auto; ...">.
       :has() picks the parent that contains the Load Project button. ── */
.tab-container > div[style*="margin-left"] { display: none !important; }

/* ── Hide Import / Export Entities (project is AAAB-scoped) ── */
.toolbar-btn[onclick="importEntitiesJSON()"],
.toolbar-btn[onclick="exportEntitiesJSON()"] { display: none !important; }

/* ── Typography + chrome ── */
body {
    font-family: 'Manrope', system-ui, -apple-system, Segoe UI, sans-serif;
    color: #18181b;
    background: #fafafa;
}

.tab-container {
    background: #ffffff !important;
    border-bottom: 1px solid #e4e4e7 !important;
    padding: 0 12px !important;
    height: 44px !important;
    gap: 4px !important;
    display: flex !important;
    align-items: stretch !important;
}

.tab {
    background: transparent !important;
    border: 0 !important;
    border-bottom: 2px solid transparent !important;
    padding: 0 14px !important;
    margin: 0 !important;
    color: #71717a !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    letter-spacing: -0.005em !important;
    border-radius: 0 !important;
    display: flex !important;
    align-items: center !important;
    transition: color .12s, border-color .12s, background .12s !important;
}
.tab:hover {
    color: #18181b !important;
    background: #f4f4f5 !important;
}
.tab.active {
    color: #18181b !important;
    border-bottom-color: #18181b !important;
    background: transparent !important;
    font-weight: 600 !important;
}

/* ── Toolbar (per-view action row) ── */
.toolbar {
    background: #ffffff !important;
    border-bottom: 1px solid #e4e4e7 !important;
    padding: 8px 12px !important;
    gap: 6px !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
}

.toolbar label {
    font-size: 12px !important;
    color: #52525b !important;
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
}
.toolbar label:hover {
    background: transparent !important;
}
.toolbar input[type="number"] {
    padding: 3px 6px !important;
    border: 1px solid #d4d4d8 !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    background: #ffffff !important;
    color: #18181b !important;
}

/* ── Buttons ── */
.toolbar-btn {
    background: #ffffff !important;
    color: #3f3f46 !important;
    border: 1px solid #e4e4e7 !important;
    border-radius: 6px !important;
    padding: 5px 10px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    cursor: pointer !important;
    transition: background .12s, border-color .12s, color .12s, box-shadow .12s !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    box-shadow: none !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}
.toolbar-btn:hover {
    background: #f4f4f5 !important;
    border-color: #d4d4d8 !important;
    color: #18181b !important;
}
.toolbar-btn:active {
    background: #e4e4e7 !important;
    transform: translateY(0) !important;
}
.toolbar-btn:disabled {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
}

.toolbar-btn.primary {
    background: #18181b !important;
    color: #fafafa !important;
    border-color: #18181b !important;
}
.toolbar-btn.primary:hover {
    background: #27272a !important;
    border-color: #27272a !important;
    color: #ffffff !important;
}

.toolbar-btn.danger {
    background: #ffffff !important;
    color: #b91c1c !important;
    border-color: #fecaca !important;
}
.toolbar-btn.danger:hover {
    background: #fef2f2 !important;
    border-color: #f87171 !important;
    color: #991b1b !important;
}

/* ── Zoom indicator pill ── */
.zoom-indicator {
    background: transparent !important;
    color: #71717a !important;
    font-size: 11px !important;
    font-family: 'JetBrains Mono', ui-monospace, monospace !important;
    padding: 0 8px !important;
    margin-left: auto !important;
    border: 0 !important;
}

/* ── New AAAB-injected buttons live in their own .aaab-tabbar-right container ── */
.aaab-tabbar-right {
    margin-left: auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 0 !important;
}
.aaab-tabbar-right .aaab-btn {
    background: #ffffff;
    color: #3f3f46;
    border: 1px solid #e4e4e7;
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.aaab-tabbar-right .aaab-btn:hover {
    background: #f4f4f5;
    border-color: #d4d4d8;
    color: #18181b;
}
.aaab-tabbar-right .aaab-btn.primary {
    background: #18181b;
    color: #fafafa;
    border-color: #18181b;
}
.aaab-tabbar-right .aaab-btn.primary:hover {
    background: #27272a;
    border-color: #27272a;
}
.aaab-tabbar-right .aaab-btn .ic {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}
.aaab-tabbar-right .aaab-saved-pill {
    font-size: 10px;
    color: #71717a;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    padding: 0 6px;
}
.aaab-tabbar-right .aaab-saved-pill.dirty { color: #ca8a04; }
.aaab-tabbar-right .aaab-saved-pill.saving { color: #2563eb; }

/* ── Showcase viewer mode (html.aaab-viewer, set by aaab-bootstrap.js from
       ?viewer=1). Each showcase modal embeds the editor pinned to ONE view:
       hide the whole tab bar (only the read-only pill remains) and every
       control that saves, generates, imports/exports, or replaces data.
       Drag / add / edit stay alive — the sandbox is the point; nothing a
       viewer does can persist (no auto-save wiring + no-op save endpoint). ── */
.aaab-viewer .tab-container .tab { display: none !important; }

/* Screenshot mode (html.aaab-shot, thumbnail job): strip ALL chrome so the
   capture is canvas-only — the tab bar (incl. the sandbox pill), every
   per-view toolbar row, and the canvas status bar. */
.aaab-shot .tab-container,
.aaab-shot .toolbar,
.aaab-shot .canvas-status { display: none !important; }
.aaab-viewer .toolbar-btn[onclick="createTestData()"],
.aaab-viewer .toolbar-btn[onclick="regenerateDatabaseFromEntities()"],
.aaab-viewer .toolbar-btn[onclick="generateSQL()"],
.aaab-viewer .toolbar-btn[onclick="generateModelsFromEntities()"] { display: none !important; }

/* ── Pin the footer on the two large Laravel "Generation Options" modals.
       Original modal-content used `overflow-y: auto` on the whole box, so
       the footer scrolled out of view with the body and the "✨ Generate →"
       button sat below the visible iframe area. Users reported it as
       "not clickable" because they never realised they had to scroll
       inside the modal to reach it. Switch to a flex column: header +
       footer hold their height, body owns the scroll. ID selectors keep
       this scoped to the two oversized modals so the smaller ones
       (entity/attribute/relationship/etc.) stay unchanged. ── */
#laravelConfigModal .modal-content,
#laravelVueConfigModal .modal-content {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}
#laravelConfigModal .modal-header,
#laravelVueConfigModal .modal-header,
#laravelConfigModal .modal-footer,
#laravelVueConfigModal .modal-footer {
    flex: 0 0 auto !important;
}
#laravelConfigModal .modal-body,
#laravelVueConfigModal .modal-body {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    min-height: 0 !important;
}

/* ── Highlight Related ─────────────────────────────────────────────────────
   Applied by applyHighlight() whenever a box or relation is selected and the
   toggle is on. `.hl-related` rings the boxes at the far end of the selected
   relations; the selected box itself keeps its own blue `.selected` treatment,
   so the two roles stay visually distinct. Curves and their crow's-foot markers
   are styled from JS (stroke colour) since they are SVG.

   The highlight ADDS to what is selected — it never touches anything else.
   Fading the rest was tried and removed: `opacity` below 1 gives every faded
   box, connector path and marker group its own transparency layer, and on a
   large schema that is hundreds of offscreen buffers the compositor has to
   allocate and blend on each repaint. Same reason there is no filter() and no
   transition here: a saturate() filter measured ~60% slower repaints while
   hovering, and a transition would animate 100+ boxes on every selection
   change. Colour and shadow on the highlighted items only. ── */
.entity.hl-related {
    border-color: #ea580c;
    box-shadow: 0 4px 16px rgba(234, 88, 12, 0.35);
}

/* Grab affordance for the new drag-to-pan on empty canvas. Entity boxes
   (cursor: move) and connector hit paths (cursor: pointer) override this. */
.canvas-wrapper { cursor: grab; }
.canvas-wrapper.panning { cursor: grabbing; }

/* ── Canvas status bar ─────────────────────────────────────────────────────
   Bottom-left overlay on each diagram: item counts, the current selection,
   and the zoom controls (plain wheel pans now, so zoom needs buttons). ── */
.canvas-status {
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100% - 20px);
    padding: 5px 8px;
    border: 1px solid #e4e4e7;
    border-radius: 7px;
    /* Opaque, not blurred: a backdrop-filter over the canvas forces the
       blurred region to be re-sampled on every repaint behind it. */
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    font-size: 11.5px;
    line-height: 1.4;
    color: #52525b;
    cursor: default;
    user-select: none;
}

.canvas-status-counts {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.canvas-status-selection {
    padding-left: 10px;
    border-left: 1px solid #e4e4e7;
    color: #ea580c;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.canvas-status-zoom {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-left: auto;
    padding-left: 10px;
    border-left: 1px solid #e4e4e7;
}

.canvas-status-zoom-value {
    min-width: 38px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.canvas-status-btn {
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 1px solid #e4e4e7;
    border-radius: 5px;
    background: #fff;
    color: #52525b;
    font-size: 11.5px;
    line-height: 1;
    cursor: pointer;
}

.canvas-status-btn:hover {
    background: #f4f4f5;
    color: #18181b;
}

/* ── Text View modal (Entities / Database toolbars). Rendered-HTML
       mirror of the showcase "Entities & DB (text)" artifact. Oversized
       like the Laravel options modals: flex column so header + footer
       hold their height and the body owns the scroll. ── */
#textViewModal .modal-content {
    max-width: 1200px;
    width: 92%;
    max-height: 90vh;
    margin: 4vh auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#textViewModal .modal-header,
#textViewModal .modal-footer { flex: 0 0 auto; }
#textViewModal .modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 20px 24px;
}

.tv-mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; }

.tv-section-title {
    font-size: 17px;
    font-weight: 600;
    color: #18181b;
    margin: 22px 0 12px;
}
.tv-section-title:first-child { margin-top: 0; }
.tv-count {
    font-size: 13px;
    font-weight: 400;
    color: #71717a;
}

.tv-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

.tv-card {
    border: 1px solid #e4e4e7;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}
.tv-card-header {
    padding: 10px 14px;
    border-bottom: 1px solid #e4e4e7;
}
.tv-card-title {
    font-weight: 600;
    font-size: 14px;
    color: #18181b;
}
.tv-card-desc {
    font-size: 12.5px;
    color: #71717a;
    margin-top: 2px;
}

.tv-attr-list {
    list-style: none;
    margin: 0;
    padding: 4px 14px;
}
.tv-attr {
    padding: 7px 0;
    border-top: 1px solid #f4f4f5;
}
.tv-attr:first-child { border-top: 0; }
.tv-attr-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.tv-attr-name {
    font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
    font-size: 13px;
    color: #18181b;
}
.tv-attr-type {
    font-size: 11.5px;
    color: #71717a;
}
.tv-attr-desc {
    font-size: 12px;
    color: #71717a;
    margin-top: 3px;
}

.tv-badges {
    margin-left: auto;
    display: flex;
    gap: 4px;
}
.tv-badge {
    display: inline-block;
    font-size: 10.5px;
    line-height: 1.6;
    padding: 0 8px;
    border-radius: 999px;
    background: #f4f4f5;
    color: #52525b;
    white-space: nowrap;
}
.tv-badge.blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.tv-table-wrap {
    border: 1px solid #e4e4e7;
    border-radius: 10px;
    background: #fff;
    overflow-x: auto;
}
.tv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.tv-table th {
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 10.5px;
    font-weight: 600;
    color: #71717a;
    padding: 9px 14px;
    border-bottom: 1px solid #e4e4e7;
}
.tv-table td {
    padding: 9px 14px;
    border-top: 1px solid #f4f4f5;
    vertical-align: top;
}
.tv-table tr:first-child td { border-top: 0; }
.tv-desc-cell { color: #71717a; }

/* ── Help modal typography (server-rendered workbook HTML) ── */
#helpModalContent h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 18px 0 8px;
}
#helpModalContent h2:first-child { margin-top: 0; }
#helpModalContent p { margin: 0 0 10px; }
#helpModalContent ol,
#helpModalContent ul {
    margin: 0 0 10px;
    padding-left: 22px;
}
#helpModalContent li { margin-bottom: 4px; }
