/* T-Apuri — Graph Visualization Styles */
/* Session 7.5 */

/* ============================================
   1. GRAPH VIEW LAYOUT
   ============================================ */

.view-content--graph {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

/* ============================================
   2. SVG CANVAS
   ============================================ */

.graph-svg {
    flex: 1;
    width: 100%;
    min-height: 0;
    background: var(--surface-background);
    cursor: grab;
}

.graph-svg:active {
    cursor: grabbing;
}

/* ============================================
   3. TOOLBAR (search bar)
   ============================================ */

.graph-toolbar {
    position: absolute;
    top: var(--space-3);
    left: var(--space-3);
    z-index: 10;
    width: min(320px, calc(100% - var(--space-6)));
}

.graph-search-wrapper {
    position: relative;
}

.graph-search-input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-md);
    background: var(--surface-card);
    font-size: var(--font-size-sm);
    font-family: inherit;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.graph-search-input::placeholder {
    color: var(--text-muted);
}

.graph-search-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

/* ============================================
   3b. BREADCRUMB (navigaatiopolku)
   ============================================ */

.graph-breadcrumb {
    position: absolute;
    top: var(--space-3);
    left: calc(min(320px, calc(100% - var(--space-6))) + var(--space-6));
    z-index: 10;
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    font-size: var(--font-size-xs);
    max-width: 50%;
    overflow-x: auto;
}

.graph-breadcrumb-item {
    background: none;
    border: none;
    font: inherit;
    color: var(--color-primary-600);
    cursor: pointer;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
}

.graph-breadcrumb-item:hover {
    background: var(--color-primary-50);
}

.graph-breadcrumb-item--active {
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    cursor: default;
}

.graph-breadcrumb-sep {
    color: var(--text-muted);
}

@media (max-width: 640px) {
    .graph-breadcrumb {
        display: none;
    }
}

/* ============================================
   4. SEARCH DROPDOWN
   ============================================ */

.graph-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: var(--space-1);
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    max-height: 280px;
    overflow-y: auto;
    z-index: 20;
}

.graph-search-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
    border-bottom: 1px solid var(--color-neutral-100);
    transition: background var(--transition-fast);
}

.graph-search-item:last-child {
    border-bottom: none;
}

.graph-search-item:hover {
    background: var(--color-neutral-50);
}

.graph-search-item-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
}

.graph-search-item-type {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.graph-search-no-results {
    padding: var(--space-3);
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.graph-search-loading {
    padding: var(--space-3);
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

/* ============================================
   5. ZOOM CONTROLS
   ============================================ */

.graph-controls {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 10;
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.graph-control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--surface-card);
    border: none;
    color: var(--text-secondary);
    font-size: var(--font-size-lg);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.graph-control-btn:hover {
    background: var(--color-neutral-100);
    color: var(--text-primary);
}

.graph-control-btn + .graph-control-btn {
    border-top: 1px solid var(--color-neutral-100);
}

/* ============================================
   6. TOOLTIP
   ============================================ */

.graph-tooltip {
    position: absolute;
    pointer-events: none;
    z-index: 30;
    max-width: 320px;
    padding: var(--space-2) var(--space-3);
    background: var(--color-neutral-800);
    color: var(--text-inverse);
    font-size: var(--font-size-xs);
    line-height: var(--line-height-normal);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-md);
    word-wrap: break-word;
}

.graph-tooltip-title {
    font-weight: var(--font-weight-semibold);
    margin-bottom: 2px;
}

.graph-tooltip-subtitle {
    opacity: 0.8;
    margin-bottom: 2px;
    font-style: italic;
}

.graph-tooltip-type {
    opacity: 0.7;
}

.graph-tooltip-warning {
    margin-top: 3px;
    color: #fca5a5;
    font-size: 0.6875rem;
}

.graph-tooltip-meta {
    margin-top: 3px;
    opacity: 0.6;
    font-size: 0.6875rem;
}

.graph-tooltip-hint {
    margin-top: 4px;
    opacity: 0.5;
    font-size: 0.6875rem;
}

/* ============================================
   7. LEGEND
   ============================================ */

.graph-legend {
    position: absolute;
    bottom: var(--space-3);
    left: var(--space-3);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    z-index: 10;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.graph-legend-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.graph-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.graph-legend-dot--law {
    background: #2563eb;
}

.graph-legend-dot--court {
    background: #f59e0b;
}

.graph-legend-dot--guidance {
    background: #8b5cf6;
}

.graph-legend-dot--proposal {
    background: #14b8a6;
}

.graph-legend-dot--kila {
    background: #ec4899;
}

.graph-legend-dot--concept {
    background: #10b981;
}

/* ============================================
   8. GRAPH NODES (SVG)
   ============================================ */

.graph-node {
    cursor: pointer;
}

.graph-node circle {
    stroke-width: 2px;
    transition: r 0.15s ease;
}

.graph-node:hover circle {
    r: 15;
}

.graph-node--law circle {
    fill: #2563eb;
    stroke: #1d4ed8;
}

.graph-node--court circle {
    fill: #f59e0b;
    stroke: #d97706;
}

.graph-node--guidance circle {
    fill: #8b5cf6;
    stroke: #7c3aed;
}

.graph-node--proposal circle {
    fill: #14b8a6;
    stroke: #0d9488;
}

.graph-node--kila circle {
    fill: #ec4899;
    stroke: #db2777;
}

.graph-node--concept circle {
    fill: #10b981;
    stroke: #059669;
}

.graph-node--topic circle {
    fill: #6b7280;
    stroke: #4b5563;
}

.graph-node--default circle {
    fill: #94a3b8;
    stroke: #64748b;
}

/* Voimassaolo: kumotut nodet */
.graph-node--revoked circle {
    fill: none;
    stroke-dasharray: 4 3;
    stroke-width: 2.5px;
}

/* Keskiö-node (valittu) */
.graph-node--center circle {
    stroke-width: 3px;
    r: 15;
}

/* Laajennettu node (drill-down) */
.graph-node--expanded circle {
    stroke-width: 3px;
}

/* ============================================
   9. GRAPH LABELS (SVG)
   ============================================ */

.graph-label {
    font-size: 11px;
    font-family: var(--font-family-base);
    fill: var(--text-primary);
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: central;
    user-select: none;
}

/* ============================================
   10. GRAPH LINKS (SVG)
   ============================================ */

.graph-link {
    stroke: var(--color-neutral-300);
    stroke-width: 1.5px;
    stroke-opacity: 0.6;
    fill: none;
}

.graph-link--highlighted {
    stroke: var(--color-primary-500);
    stroke-opacity: 1;
    stroke-width: 2px;
}

/* Suhdetyyppi-label linkillä */
.graph-link-label {
    font-size: 9px;
    font-family: var(--font-family-base);
    fill: var(--text-muted);
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: central;
}

/* ============================================
   11. EMPTY STATE
   ============================================ */

.graph-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    z-index: 5;
    pointer-events: none;
}

.graph-empty h3 {
    font-size: var(--font-size-xl);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.graph-empty p {
    font-size: var(--font-size-sm);
    max-width: 300px;
}

.graph-empty .onboarding-examples {
    pointer-events: auto;
}

/* ============================================
   12. LOADING INDICATOR (graafi)
   ============================================ */

.graph-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    z-index: 15;
}

/* ============================================
   13. CONTEXT PANEL: CONTENT AREA + BUTTONS
   ============================================ */

.graph-content-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    font-family: inherit;
    color: var(--color-primary-600);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.graph-content-link:hover {
    background: var(--color-primary-50);
    border-color: var(--color-primary-300);
}

.graph-content-link:disabled {
    opacity: 0.6;
    cursor: wait;
}

.graph-content-text {
    margin-top: var(--space-2);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text-primary);
    max-height: 400px;
    overflow-y: auto;
    padding: var(--space-2);
    background: var(--color-neutral-50);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--color-neutral-200);
}

/* ============================================
   14. RESPONSIVE
   ============================================ */

@media (min-width: 640px) {
    .graph-toolbar {
        top: var(--space-4);
        left: var(--space-4);
    }

    .graph-controls {
        top: var(--space-4);
        right: var(--space-4);
    }

    .graph-legend {
        bottom: var(--space-4);
        left: var(--space-4);
    }
}
