/* Enterprise AI Graph — page-specific styles */

body { background: var(--bg-primary); color: var(--text-primary); font-family: 'Inter', system-ui, sans-serif; }

/* Entity colors (from Mermaid palette) */
:root {
    --c-industry: #1f77b4;
    --c-domain: #2ca02c;
    --c-company: #ff7f0e;
    --c-opmodel: #9467bd;
    --c-process: #d62728;
    --c-usecase: #00d4ff;
    --c-capability: #8c564b;
    --c-outcome: #e377c2;
}

/* KPI cards */
.kpi-card { transition: transform 0.15s, border-color 0.15s; }
.kpi-card:hover { transform: translateY(-2px); border-color: var(--accent) !important; }

/* Lens buttons */
.lens-btn { cursor: pointer; }
.lens-btn:hover { opacity: 0.85; }
#clear-filters:disabled { cursor: not-allowed; opacity: 0.48; border-color: var(--border-mid) !important; color: var(--text-subtle) !important; }
#clear-filters.has-active-filters { box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.12); }
#clear-filters.has-active-filters:hover { background: rgba(var(--accent-rgb), 0.1) !important; }

/* SVG graph */
#graph-svg { display: block; }
#graph-svg .cluster-card { transition: opacity 0.16s ease; }
#graph-svg .cluster-card rect { transition: fill-opacity 0.16s ease, stroke-width 0.16s ease, filter 0.16s ease; }
#graph-svg .cluster-card.is-dimmed { cursor: pointer; }
#graph-svg .cluster-card.is-dimmed.is-hover-revealed rect { fill-opacity: 0.22; stroke-width: 2.5; filter: brightness(1.2); }
#graph-svg .node-rect { cursor: pointer; transition: opacity 0.2s, filter 0.2s; rx: 8; }
#graph-svg .node-rect:hover { filter: brightness(1.2); }
#graph-svg .node-rect.dimmed { opacity: 0.2; }
#graph-svg .node-rect.selected { stroke: var(--accent); stroke-width: 3; }
#graph-svg .node-label { pointer-events: none; user-select: none; font-size: 11px; font-weight: 600; fill: #f8fafc; }
#graph-svg .edge-line { stroke: var(--text-subtle); stroke-width: 1; opacity: 0.3; transition: opacity 0.2s; }
#graph-svg .edge-line.highlighted { opacity: 0.8; stroke: var(--accent); stroke-width: 2; }
#graph-svg .edge-line.dimmed { opacity: 0.05; }
#graph-svg text.entity-type { font-size: 9px; font-weight: 700; text-transform: uppercase; fill: var(--text-subtle); letter-spacing: 0.05em; }

/* Light mode adjustments */
html[data-theme="light"] #graph-svg .node-label { fill: #1c1917; }
html[data-theme="light"] #graph-svg .edge-line { stroke: #78716c; }

/* Light mode: darken hardcoded entity colors for WCAG AA contrast on light backgrounds */
html[data-theme="light"] #kpi-usecases { color: #0e7490 !important; }
html[data-theme="light"] #kpi-companies { color: #c2410c !important; }
html[data-theme="light"] #kpi-opmodels { color: #6b21a8 !important; }
html[data-theme="light"] #kpi-relationships { color: #be185d !important; }
html[data-theme="light"] .kpi-card .tracking-wide { color: #475569 !important; }
html[data-theme="light"] .tracking-wider { color: #0e7490 !important; background: rgba(8,145,178,0.12) !important; border-color: rgba(8,145,178,0.3) !important; }

/* List table */
#list-tbody tr { border-bottom: 1px solid var(--border-mid); transition: background 0.15s; cursor: pointer; }
#list-tbody tr:hover { background: rgba(0,212,255,0.05); }
#list-tbody td { padding: 12px 16px; vertical-align: top; }
#list-tbody .uc-id { font-family: monospace; font-size: 10px; color: var(--text-subtle); }
#list-tbody .uc-name { font-weight: 600; color: var(--text-primary); }
#list-tbody .uc-company { color: var(--c-company); font-weight: 500; }
#list-tbody .uc-impact { color: var(--text-muted); font-size: 12px; max-width: 300px; }
#list-tbody .core-badge { display: inline-block; font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 9999px; background: rgba(0,212,255,0.1); color: var(--accent); border: 1px solid rgba(0,212,255,0.2); margin-left: 4px; }

/* Concept dictionary modal */
#glossary-modal:not(.hidden) { display: flex !important; }
.glossary-card {
    position: relative;
    width: 100%;
    max-width: 56rem;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    margin: auto;
    border-radius: 0.75rem;
    border: 1px solid var(--border-mid);
    background: var(--bg-surface);
    box-shadow: 0 24px 70px rgba(0,0,0,.45);
    overflow: hidden;
}
.glossary-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-mid);
    background: var(--bg-primary);
}
.glossary-content {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1.25rem;
}

/* Detail panel header */
#detail-panel .detail-panel-header {
    background: var(--bg-primary);
    border-bottom: 2px solid var(--accent);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    backdrop-filter: blur(8px);
}

/* Detail panel */
#detail-panel {
    display: flex;
    flex-direction: column;
    width: min(24rem, 100vw);
    background: var(--bg-surface) !important;
    /* The local Tailwind build does not include translate-x-full. Keep the
       drawer hidden until an entity is selected instead of covering the page. */
    transform: translateX(100%);
}
#detail-panel.open { transform: translateX(0); }
#detail-body .detail-section { margin-bottom: 1rem; }
#detail-body .detail-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-subtle); margin-bottom: 4px; }
#detail-title { word-break: break-word; overflow-wrap: break-word; }
#detail-body .detail-subsection { padding: 8px 0; border-top: 1px solid var(--border-soft); }
#detail-body .detail-subsection:first-of-type { border-top: 0; padding-top: 0; }
#detail-body .detail-sub-label { font-size: 12px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
#detail-body .detail-meta { font-size: 11px; color: var(--text-subtle); margin-top: 3px; }
#detail-panel #detail-body .detail-meta { color: #aebed1; }
html[data-theme="light"] #detail-panel #detail-body .detail-meta { color: #475569; }
#detail-body .detail-status { display: inline-block; margin-left: 4px; padding: 1px 5px; border-radius: 999px; font-size: 9px; text-transform: uppercase; letter-spacing: 0.04em; border: 1px solid var(--border-mid); color: var(--text-muted); }
#detail-body .detail-status-verified, #detail-body .detail-status-evidenced { color: #34d399; border-color: rgba(52,211,153,0.35); }
#detail-body .detail-status-ambiguous { color: #fbbf24; border-color: rgba(251,191,36,0.35); }
#detail-body .detail-value { font-size: 14px; color: var(--text-primary); line-height: 1.5; word-break: break-word; overflow-wrap: break-word; }
#detail-body .detail-link { color: var(--accent); text-decoration: underline; font-size: 13px; word-break: break-all; }
#detail-body .detail-link.dead { text-decoration: line-through; color: var(--text-subtle); }
#detail-body .detail-chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 9999px; margin: 2px; cursor: pointer; border: 1px solid var(--border-mid); background: var(--bg-primary); color: var(--text-muted); transition: border-color 0.15s; }
#detail-body .detail-chip:hover { border-color: var(--accent); color: var(--accent); }
#detail-body .detail-quote { font-size: 13px; font-style: italic; color: var(--text-muted); border-left: 3px solid var(--accent); padding-left: 10px; margin: 8px 0; }
#detail-body .rel-link { color: var(--accent); cursor: pointer; font-size: 12px; font-weight: 600; line-height: 1.5; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
#detail-body .rel-link:hover { color: #ffffff; text-decoration-style: solid; }

/* Decision path chain */
#detail-body .path-chain { display: flex; flex-direction: column; gap: 0; }
#detail-body .path-step { padding: 6px 10px; border-radius: 6px; cursor: pointer; transition: transform 0.12s; }
#detail-body .path-step:hover { transform: translateX(3px); }
#detail-body .path-step-type { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
#detail-body .path-step-name { font-size: 12px; color: var(--text-primary); font-weight: 500; word-break: break-word; overflow-wrap: break-word; }
#detail-body .path-arrow { text-align: center; font-size: 9px; color: var(--text-subtle); padding: 1px 0; }

/* Pin / compare button */
#detail-body .pin-btn { width: auto; padding: 4px 8px; border-radius: 6px; font-size: 10px; font-weight: 700; cursor: pointer; border: 1px solid var(--border-mid); background: var(--bg-primary); color: var(--text-muted); transition: border-color 0.15s, color 0.15s; white-space: nowrap; }
#detail-body .pin-btn:hover { border-color: var(--accent); color: var(--accent); }
#detail-body .pin-btn.pinned { background: rgba(0,212,255,0.1); border-color: var(--accent); color: var(--accent); }
#detail-body #detail-clear-pins-btn { padding: 4px 8px; border: 1px solid var(--border-mid) !important; border-radius: 6px; background: var(--bg-primary) !important; color: var(--text-muted) !important; cursor: pointer; font-size: 10px; font-weight: 700; line-height: 1.2; text-decoration: none !important; }
#detail-body #detail-clear-pins-btn:hover { border-color: var(--accent) !important; color: var(--accent) !important; }

/* Comparison drawer */
.comparison-drawer { position: fixed; z-index: 55; inset: 0; pointer-events: none; }
.comparison-handle { position: fixed; z-index: 57; top: 50%; left: 0; display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.65rem 0.7rem 0.65rem 0.55rem; border: 1px solid rgba(var(--accent-rgb), 0.6); border-left: 0; border-radius: 0 0.65rem 0.65rem 0; background: var(--bg-elevated); color: var(--accent); box-shadow: 4px 8px 24px rgba(0,0,0,0.25); cursor: pointer; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.02em; transform: translateY(-50%); pointer-events: auto; transition: background 0.15s, color 0.15s; }
.comparison-handle:hover { background: rgba(var(--accent-rgb), 0.12); }
.comparison-handle:focus-visible, .comparison-close-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.comparison-handle-count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.2rem; height: 1.2rem; padding: 0 0.25rem; border-radius: 999px; background: var(--accent); color: #0f172a; font-size: 0.65rem; }
.comparison-handle-chevron { transition: transform 0.2s ease; }
.comparison-drawer.is-open .comparison-handle-chevron { transform: rotate(180deg); }
.comparison-drawer.is-open .comparison-handle { left: min(72rem, calc(100vw - 2.5rem)); }
.comparison-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(2, 6, 23, 0.58); opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
.comparison-drawer-panel { position: fixed; z-index: 56; top: 0; bottom: 0; left: 0; width: min(72rem, calc(100vw - 2.5rem)); display: flex; flex-direction: column; border-right: 1px solid var(--border-mid); background: var(--bg-elevated); box-shadow: 12px 0 42px rgba(0,0,0,0.38); transform: translateX(-100%); transition: transform 0.25s ease; pointer-events: none; }
.comparison-drawer.is-open .comparison-backdrop { opacity: 1; pointer-events: auto; }
.comparison-drawer.is-open .comparison-drawer-panel { transform: translateX(0); pointer-events: auto; }
.comparison-drawer-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border-mid); background: var(--bg-primary); }
.comparison-kicker { margin: 0 0 0.2rem; color: var(--accent); font-size: 0.66rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.comparison-drawer-header h3 { margin: 0; color: var(--text-primary); font-size: 1.05rem; font-weight: 800; }
.comparison-drawer-header h3 span { color: var(--text-subtle); font-size: 0.8rem; font-weight: 600; }
.comparison-drawer-actions { display: flex; align-items: center; gap: 0.5rem; }
.comparison-close-btn { display: inline-grid; width: 2rem; height: 2rem; place-items: center; border: 1px solid var(--border-mid); border-radius: 0.45rem; background: var(--bg-elevated); color: var(--text-muted); cursor: pointer; }
.comparison-close-btn:hover { border-color: var(--accent); color: var(--accent); }
.comparison-drawer-body { flex: 1 1 auto; overflow: auto; padding: 0.65rem 1.25rem 1.25rem; }
.comparison-drawer-note { margin: 0; padding: 0.85rem 1.25rem; border-top: 1px solid var(--border-mid); color: var(--text-subtle); font-size: 0.74rem; }
.comparison-drawer-note i { color: var(--accent); margin-right: 0.3rem; }

/* Comparison table */
.compare-clear-btn { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.65rem; border: 1px solid var(--border-mid); border-radius: 0.4rem; background: var(--bg-primary); color: var(--text-muted); cursor: pointer; font-size: 0.75rem; font-weight: 700; line-height: 1; transition: border-color 0.15s, color 0.15s, background 0.15s; }
.compare-clear-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(0,212,255,0.08); }
.compare-clear-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.compare-table th { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border-mid); color: var(--text-primary); font-weight: 600; position: relative; min-width: 190px; vertical-align: top; }
.compare-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-soft); color: var(--text-muted); vertical-align: top; line-height: 1.4; }
.compare-table .compare-row-label { font-weight: 800; color: #9fb7d1; text-transform: uppercase; font-size: 10px; letter-spacing: 0.055em; white-space: nowrap; background: rgba(96, 165, 250, 0.07); border-right: 1px solid rgba(148, 163, 184, 0.18); }
html[data-theme="light"] .compare-table .compare-row-label { color: #334e68; background: rgba(14, 116, 144, 0.08); border-right-color: rgba(51, 78, 104, 0.2); }
.compare-head { display: flex; flex-direction: column; gap: 0.3rem; padding-right: 24px; }
.compare-head strong { color: var(--text-primary); font-size: 0.8rem; line-height: 1.35; }
.compare-head-type { color: var(--accent); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.compare-head-company { color: var(--text-muted); font-size: 0.7rem; font-weight: 600; }
.compare-head-company i { color: var(--c-company); }
.compare-remove { position: absolute; top: 6px; right: 4px; background: none; border: none; color: var(--text-subtle); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.compare-remove:hover { color: var(--accent); }
.compare-evidence-link { display: inline-flex; align-items: flex-start; gap: 0.35rem; color: var(--accent); font-weight: 600; text-decoration: none; }
.compare-evidence-link:hover { text-decoration: underline; }
.compare-evidence-link i { margin-top: 0.15rem; }
.compare-empty { color: var(--text-subtle); font-style: italic; }

/* List row highlight states */
#list-tbody tr.uc-row-highlight { background: rgba(0,212,255,0.08); }
#list-tbody tr.uc-row-highlight .uc-name { color: var(--accent); }
#list-tbody tr.uc-row-dim { opacity: 0.35; }

/* Reduced motion: respects OS-level accessibility preference automatically */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
    .kpi-card:hover { transform: none; }
    #detail-panel { transition: none; }
}

/* 3D view */
#three-view { position: relative; }
#three-canvas-wrap { position: relative; }
#three-canvas-wrap canvas { display: block; border-radius: inherit; }
#three-controls button { transition: color 0.15s, border-color 0.15s; }
#three-controls button:hover { border-color: var(--accent); }
#three-tooltip { max-width: 240px; word-break: break-word; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
#explore-3d { transition: all 0.15s; }
#explore-3d:hover { opacity: 0.88; }

/* Scrollbar */
#detail-panel::-webkit-scrollbar { width: 5px; }
#detail-panel::-webkit-scrollbar-track { background: var(--bg-elevated); }
#detail-panel::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }

/* Loading */
.loading-shimmer { background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-primary) 50%, var(--bg-elevated) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Responsive */
@media (max-width: 768px) {
    #detail-panel { width: 100%; }
    #list-tbody .uc-impact { max-width: 200px; }
}
