/* ============================================================
   SVG System View (ERD) Styles
   Design system tokens — dark mode auto-switches.
   ============================================================ */

.svg-system-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.svg-system-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

.svg-system-canvas:active {
    cursor: grabbing;
}

/* ============================================================
   Entity boxes
   ============================================================ */

.entity-node {
    cursor: grab;
}

.entity-node:active,
.entity-node.dragging {
    cursor: grabbing;
}

.entity-box {
    fill: var(--bg-raised, #ffffff);
    stroke: var(--bg-raised, #ffffff);
    stroke-width: 1;
    filter: none;
    transition: all 0.3s ease;
}

.entity-node:hover .entity-box {
    fill: var(--bg-raised-hover);
    filter: var(--svg-shadow, drop-shadow(0 2px 4px rgba(0, 0, 0, 0.05)));
}

.entity-node[data-view="detail"] .entity-box {
    stroke: var(--color1-500, #6877a6);
    stroke-width: 2;
}

.entity-name {
    font-family: var(--font-family-base);
    font-size: 13px;
    font-weight: var(--font-weight-semibold);
    fill: var(--text-primary, #1a1a1a);
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    user-select: none;
}

/* ============================================================
   Gap placeholder boxes
   ============================================================ */

.gap-node {
    cursor: pointer;
}

.gap-box {
    fill: var(--color-amber-50, #fffbeb);
    stroke: var(--color-amber-400, #fbbf24);
    stroke-width: 1.5;
    stroke-dasharray: 6 3;
}

.gap-node:hover .gap-box {
    stroke: var(--color-amber-500, #f59e0b);
    stroke-width: 2;
}

.gap-question {
    font-family: var(--font-family-base);
    font-size: 20px;
    font-weight: var(--font-weight-bold);
    fill: var(--color-amber-500, #f59e0b);
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    user-select: none;
}

.gap-hint {
    font-family: var(--font-family-base);
    font-size: 10px;
    font-weight: var(--font-weight-medium);
    fill: var(--color-amber-700, #b45309);
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
}

/* ============================================================
   Gap warning on entity boxes
   ============================================================ */

.entity-box-gap {
    stroke: var(--color-amber-400, #fbbf24);
    stroke-dasharray: 6 3;
}

.entity-has-gap:hover .entity-box-gap {
    stroke: var(--color-amber-500, #f59e0b);
    stroke-width: 2;
}

.gap-badge-circle {
    fill: var(--color-amber-400, #fbbf24);
    stroke: var(--bg-raised, #ffffff);
    stroke-width: 2;
}

.gap-badge-icon {
    font-family: var(--font-family-base);
    font-size: 12px;
    font-weight: var(--font-weight-bold);
    fill: var(--bg-raised, #ffffff);
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    user-select: none;
}

/* ============================================================
   Gap summary bar (HTML overlay)
   ============================================================ */

.gap-summary-bar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--color-amber-50, #fffbeb);
    border: 1px solid var(--color-amber-300, #fcd34d);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 10;
    max-width: 90%;
    font-family: var(--font-family-base);
    font-size: 13px;
    color: var(--color-amber-900, #78350f);
    line-height: 1.4;
}

.gap-summary-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.gap-summary-text {
    flex: 1;
}

.gap-summary-text em {
    font-style: normal;
    font-weight: var(--font-weight-semibold);
    color: var(--color-amber-700, #b45309);
}

.gap-summary-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--color-amber-600, #d97706);
    padding: 0 4px;
    flex-shrink: 0;
    line-height: 1;
}

.gap-summary-close:hover {
    color: var(--color-amber-800, #92400e);
}

/* Reset Layout button */
.reset-layout-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 5px 12px;
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    border-radius: 4px;
    border: 1px solid var(--border-default, #d0d7de);
    background: var(--bg-surface, #ffffff);
    color: var(--text-secondary, #57606a);
    cursor: pointer;
    z-index: 10;
    opacity: 0.75;
    transition: opacity 0.15s, background 0.15s;
}

.reset-layout-btn:hover {
    opacity: 1;
    background: var(--bg-raised, #f6f8fa);
}

/* ============================================================
   Detail expansion
   ============================================================ */

.detail-bg {
    fill: var(--bg-base, #eeeeee);
    stroke: var(--bg-base, #eeeeee);
    stroke-width: 1;
}

.detail-attr {
    font-family: var(--font-family-mono);
    font-size: 10px;
    fill: var(--text-secondary, #6c757d);
    pointer-events: none;
    user-select: none;
}

/* ============================================================
   Edges / connection lines
   ============================================================ */

.edge-line {
    stroke: var(--fractal-connection, #999999);
    stroke-width: 1.5;
    stroke-opacity: 0.6;
    fill: none;
}

.edge-connection:hover .edge-line,
.edge-highlighted .edge-line {
    stroke-opacity: 1;
    stroke-width: 2.5;
    stroke: var(--color1-500, #6877a6);
}

.edge-chevron {
    fill: none;
    stroke: var(--fractal-connection, #999999);
    stroke-width: 1.5;
    stroke-opacity: 0.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.edge-connection:hover .edge-chevron,
.edge-highlighted .edge-chevron {
    stroke-opacity: 1;
    stroke-width: 2.5;
    stroke: var(--color1-500, #6877a6);
}

/* Label on single-action lines */

.edge-label-bg {
    fill: var(--bg-base, #f8f9fa);
    fill-opacity: 0.9;
    stroke: none;
}

.edge-label {
    font-family: var(--font-family-base);
    font-size: 10px;
    fill: var(--text-secondary, #6c757d);
    dominant-baseline: central;
    pointer-events: none;
    user-select: none;
}

/* ============================================================
   Count badge (consolidated edges)
   ============================================================ */

.edge-badge {
    cursor: pointer;
}

.badge-circle {
    fill: var(--bg-raised, #ffffff);
    stroke: var(--color1-400, #8090c0);
    stroke-width: 1.5;
    transition: stroke 0.15s ease, fill 0.15s ease;
}

.edge-badge:hover .badge-circle {
    fill: var(--color1-50, #eef0f7);
    stroke: var(--color1-500, #6877a6);
    stroke-width: 2;
}

.badge-count {
    font-family: var(--font-family-base);
    font-size: 11px;
    font-weight: var(--font-weight-bold);
    fill: var(--color1-600, #4a5578);
    dominant-baseline: central;
    pointer-events: none;
    user-select: none;
}

.badge-circle-gap {
    fill: var(--color-amber-50, #fffbeb);
    stroke: var(--color-amber-400, #fbbf24);
    stroke-width: 1.5;
}

/* ============================================================
   Action list popup (on badge click)
   ============================================================ */

.popup-bg {
    fill: var(--bg-raised, #ffffff);
    stroke: var(--bg-raised, #ffffff);
    stroke-width: 1;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.12));
}

.popup-content {
    font-family: var(--font-family-base);
    font-size: 12px;
    color: var(--text-primary, #1a1a1a);
    line-height: 1.5;
}

.popup-action-row {
    padding: 2px 0;
    border-bottom: 1px solid var(--border-color-light, #e9ecef);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popup-action-row:last-child {
    border-bottom: none;
}

/* Gap edges — amber and dashed */

.edge-line-gap {
    stroke: var(--color-amber-400, #fbbf24);
    stroke-width: 1.5;
    stroke-opacity: 0.5;
    stroke-dasharray: 4 3;
    fill: none;
}

.edge-chevron-gap {
    fill: none;
    stroke: var(--color-amber-400, #fbbf24);
    stroke-width: 1.5;
    stroke-opacity: 0.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.edge-label-gap {
    font-family: var(--font-family-base);
    font-size: 10px;
    fill: var(--color-amber-500, #f59e0b);
    pointer-events: none;
    user-select: none;
}

/* ============================================================
   Dark mode overrides
   ============================================================ */

:root.dark .svg-system-container,
@media (prefers-color-scheme: dark) {
    .gap-box {
        fill: rgba(251, 191, 36, 0.08);
    }

    .edge-label-bg {
        fill: var(--bg-base, #1a1a2e);
    }

    .badge-circle {
        fill: var(--bg-raised, #262640);
    }

    .popup-bg {
        fill: var(--bg-raised, #262640);
        filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
    }

    .gap-badge-circle {
        stroke: var(--bg-raised, #262640);
    }

    .gap-summary-bar {
        background: rgba(251, 191, 36, 0.1);
        border-color: var(--color-amber-600, #d97706);
        color: var(--color-amber-200, #fde68a);
    }

    .gap-summary-text em {
        color: var(--color-amber-300, #fcd34d);
    }

    .reset-layout-btn {
        border-color: var(--border-default, #3a3a5c);
        background: var(--bg-raised, #262640);
        color: var(--text-secondary, #a0a0c0);
    }

    .reset-layout-btn:hover {
        background: var(--bg-surface, #2e2e4a);
    }
}
