/**
 * Netzplan (Precedence Diagram) Styles
 * Styles for the interactive CPM network diagram component.
 */

.netzplan-wrapper {
    margin: 1.5rem 0;
}

.netzplan-svg {
    display: block;
    width: 100%;
    background-color: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: visible;
}

/* Node styling */
.netzplan-node .node-bg {
    fill: #ffffff;
    stroke: #cbd5e1;
    stroke-width: 2;
    transition: stroke 0.2s;
}

.netzplan-node:hover .node-bg {
    stroke: var(--color-primary);
}

.netzplan-node .node-grid {
    stroke: #e2e8f0;
    stroke-width: 1;
}

.netzplan-node .node-label {
    font-family: var(--font-sans);
    font-size: 1.0625rem; /* 17px */
    font-weight: 600;
    fill: var(--color-text);
    text-anchor: middle;
    dominant-baseline: middle;
}

.netzplan-node .node-duration {
    font-family: var(--font-mono);
    font-size: 1.125rem; /* 18px */
    font-weight: 600;
    fill: var(--color-primary);
    text-anchor: middle;
    dominant-baseline: middle;
}

/* Edge group for click handling */
.netzplan-edge-group {
    cursor: pointer;
}

/* Edge styling - 2 states: active (gray), critical (red) */
.netzplan-edge {
    stroke: #94a3b8;
    stroke-width: 3;
    fill: none;
    pointer-events: none; /* Let the hit area handle clicks */
    transition: stroke 0.2s, stroke-width 0.2s;
}

/* Active state: dependency (medium gray) */
.netzplan-edge.active {
    stroke: #94a3b8;
    stroke-width: 3;
}

.netzplan-edge-group:hover .netzplan-edge.active {
    stroke: #64748b;
    stroke-width: 4;
}

/* Critical state: critical path (muted red) */
.netzplan-edge.critical {
    stroke: #dc2626;
    stroke-width: 3;
}

.netzplan-edge-group:hover .netzplan-edge.critical {
    stroke: #b91c1c;
    stroke-width: 4;
}

/* Validation feedback states */
.netzplan-edge.correct {
    stroke: #16a34a;
    stroke-width: 4;
    stroke-dasharray: none;
}

.netzplan-edge.incorrect {
    stroke: #dc2626;
    stroke-width: 4;
    stroke-dasharray: 6, 4;
}

.netzplan-edge.missing {
    stroke: #f97316;
    stroke-width: 4;
    stroke-dasharray: none;
}

/* Input fields inside SVG foreignObject */
.netzplan-input {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 1.125rem; /* 18px */
    text-align: center;
    border: 1px solid #cbd5e1;
    border-radius: 0.125rem;
    background: #fff;
    outline: none;
    box-sizing: border-box;
    transition: all 0.15s;
}

.netzplan-input::placeholder {
    color: #94a3b8;
    font-size: 0.875rem; /* 14px */
    font-family: var(--font-sans);
}

.netzplan-input:focus {
    border-color: var(--color-primary);
    background: white;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.netzplan-input:hover:not(:focus):not(.given) {
    background: rgba(37, 99, 235, 0.05);
}

.netzplan-input.given {
    color: var(--color-text-muted);
    background: #f1f5f9;
    cursor: default;
}

.netzplan-input.error {
    color: #dc2626;
    background: #fee2e2;
    font-weight: 700;
}

.netzplan-input.small {
    font-size: 1rem; /* 16px */
}

.netzplan-input.small::placeholder {
    font-size: 0.8125rem; /* 13px */
}

.netzplan-input.valid {
    border-color: var(--color-success);
    background-color: rgba(34, 197, 94, 0.1);
}

.netzplan-input.invalid {
    border-color: var(--color-error);
    background-color: rgba(239, 68, 68, 0.1);
}

.netzplan-input.solution {
    border-color: var(--color-primary);
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--color-primary);
    font-weight: 600;
}

/* Data table above diagram */
.netzplan-data-table {
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.netzplan-data-table table {
    width: auto;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.netzplan-data-table th,
.netzplan-data-table td {
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--color-border);
    text-align: left;
    white-space: nowrap;
}

.netzplan-data-table th {
    background-color: var(--color-surface);
    font-weight: 600;
}

.netzplan-data-table td:first-child {
    font-weight: 600;
    font-family: var(--font-mono);
}

/* Critical path hint */
.netzplan-critical-hint {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.netzplan-critical-hint strong {
    color: var(--color-text);
}

/* Action buttons */
.netzplan-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.netzplan-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    cursor: pointer;
    transition: all 0.15s;
}

.netzplan-btn:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
}

.netzplan-btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.netzplan-btn-primary:hover {
    background: #1d4ed8;
}

/* Results display */
.netzplan-results {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.netzplan-results.success {
    background-color: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--color-success);
    color: var(--color-success);
}

.netzplan-results.error {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--color-error);
    color: var(--color-error);
}

.netzplan-results ul {
    margin: 0.5rem 0 0 1.5rem;
    padding: 0;
}

.netzplan-results li {
    margin: 0.25rem 0;
}

/* Legend */
.netzplan-legend {
    margin-top: 1rem;
    font-size: 0.875rem;
}

.netzplan-legend summary {
    cursor: pointer;
    color: var(--color-text-muted);
    font-weight: 500;
}

.netzplan-legend summary:hover {
    color: var(--color-primary);
}

.netzplan-legend .legend-content {
    margin-top: 0.75rem;
    padding: 1rem;
    background-color: var(--color-bg);
    border-radius: var(--radius-md);
}

.netzplan-legend .legend-table {
    border-collapse: collapse;
    font-size: 0.8125rem;
    width: auto;
}

.netzplan-legend .legend-table th {
    text-align: left;
    padding: 0.25rem 0.75rem 0.5rem 0;
    color: var(--color-text);
    font-weight: 600;
    border-bottom: 1px solid var(--color-border);
}

.netzplan-legend .legend-table td {
    padding: 0.25rem 0.75rem 0.25rem 0;
    color: var(--color-text-muted);
    vertical-align: middle;
}

.netzplan-legend .legend-table td:first-child {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    padding-right: 1rem;
}

.netzplan-legend .legend-table td:first-child strong {
    color: var(--color-text);
}

.netzplan-legend .legend-note {
    margin: 0.5rem 0 0 0;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-style: italic;
}

/* Legend line indicators */
.netzplan-legend .legend-line {
    display: inline-block;
    width: 2.5rem;
    height: 4px;
    vertical-align: middle;
    border-radius: 2px;
}

.netzplan-legend .legend-line.dashed {
    background: repeating-linear-gradient(
        90deg,
        #cbd5e1 0,
        #cbd5e1 6px,
        transparent 6px,
        transparent 10px
    );
}

.netzplan-legend .legend-line.solid {
    background-color: #94a3b8;
}

.netzplan-legend .legend-line.critical {
    background-color: #dc2626;
}

/* Responsive */
@media (max-width: 640px) {
    .netzplan-critical-path label {
        flex-direction: column;
        align-items: flex-start;
    }

    .netzplan-critical-input {
        width: 100%;
    }

    .netzplan-legend .legend-content {
        grid-template-columns: 1fr;
    }
}
