/* Schema Graph Specific Styles - Dune Light Theme */
:root {
    --graph-bg: #ffffff;
    --graph-bg-secondary: #f8f9fa;
    --primary-color: #F4603E;

    /* Node Colors - Dune/Sim Palette */
    --graph-node-schema: #446BCE;
    --graph-node-table: #109C6B;
    --graph-node-enriched: #F4603E;
    --graph-link: rgba(15, 15, 21, 0.15);
    --graph-hover: #F4603E;
}

.graph-container {
    width: 100%;
    height: 100vh;
    background: var(--graph-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.graph-header {
    background: var(--graph-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 1.5rem 2rem;
    flex-shrink: 0;
}

.graph-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.graph-header h1 {
    margin: 0;
    font-size: 1.75rem;
    color: var(--color-text);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.graph-subtitle {
    margin: 0.25rem 0 0;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

/* Controls */
.graph-controls {
    background: var(--graph-bg-secondary);
    border-bottom: 1px solid var(--color-border-light);
    padding: 1rem 2rem;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.graph-search-box {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.graph-search-box input {
    width: 100%;
    padding: 0.65rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.graph-search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

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

/* Table Search & Navigate */
.table-search-container {
    position: relative;
    flex: 1;
    min-width: 250px;
    max-width: 350px;
}

.table-search-container input {
    width: 100%;
    padding: 0.65rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.table-search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

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

.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: var(--shadow-lg);
}

.search-results-dropdown.active {
    display: block;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.15s;
}

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

.search-result-item:hover {
    background: var(--color-bg-tertiary);
}

.search-result-item.no-results {
    color: var(--color-text-muted);
    cursor: default;
}

.search-result-item.no-results:hover {
    background: transparent;
}

.search-result-item .result-name {
    color: var(--color-text);
    font-weight: 500;
}

.search-result-item .result-schema {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.graph-filters {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.filter-label input[type="number"] {
    padding: 0.4rem 0.6rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    font-size: 0.9rem;
    width: 60px;
}

.filter-label input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Stats */
.graph-stats {
    background: var(--graph-bg-secondary);
    border-bottom: 1px solid var(--color-border-light);
    padding: 0.6rem 2rem;
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    text-align: center;
    flex-shrink: 0;
    font-family: var(--font-mono);
    letter-spacing: 0.3px;
}

/* Graph Canvas */
.graph-canvas {
    flex: 1;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(68, 107, 206, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(16, 156, 107, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(244, 96, 62, 0.03) 0%, transparent 60%),
        linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
}

#graphSvg {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#graphSvg:active {
    cursor: grabbing;
}

/* Node Styles */
.node-schema {
    stroke: var(--color-border);
    stroke-width: 2px;
    cursor: pointer;
    transition: all 0.25s ease-out;
}

.node-schema:hover {
    stroke: var(--color-text-muted);
    stroke-width: 3px;
}

.node-schema.expanded {
    stroke: var(--color-text);
    stroke-width: 3px;
}

.node-table {
    stroke: var(--color-border);
    stroke-width: 1.5px;
    cursor: pointer;
    transition: all 0.2s ease-out;
}

.node-table:hover {
    stroke: var(--color-text-muted);
    stroke-width: 2px;
}

.node-table.enriched {
    stroke: var(--graph-node-enriched);
    stroke-width: 2px;
}

.node-label {
    fill: var(--color-text);
    font-size: 11px;
    font-weight: 500;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: middle;
}

.node-label-large {
    font-size: 13px;
    font-weight: 600;
}

.node-count {
    fill: var(--color-text-muted);
    font-size: 9px;
    pointer-events: none;
    text-anchor: middle;
}

/* Link Styles */
.link {
    stroke: var(--graph-link);
    stroke-width: 1px;
    stroke-opacity: 0.5;
    fill: none;
    pointer-events: none;
    transition: stroke 0.2s, stroke-width 0.2s, stroke-opacity 0.2s;
}

.link.highlighted {
    stroke: var(--graph-hover);
    stroke-width: 2px;
    stroke-opacity: 1;
    stroke-dasharray: 5 3;
    animation: dash 0.8s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -8;
    }
}

/* Relationship link types */
.link.dependency {
    stroke: rgba(68, 107, 206, 0.5);
}

.link.cross-schema {
    stroke: rgba(244, 96, 62, 0.5);
    stroke-dasharray: 4 2;
}

/* Info Panel */
.info-panel {
    position: absolute;
    top: 80px;
    right: -350px;
    width: 320px;
    max-height: calc(100vh - 100px);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transition: right 0.3s ease;
    z-index: 100;
}

.info-panel.active {
    right: 20px;
}

.info-panel-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.info-panel-close:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

.info-panel h3 {
    margin: 0 0 1rem;
    color: var(--color-text);
    font-size: 1.2rem;
    padding-right: 30px;
}

.info-panel-section {
    margin-bottom: 1.5rem;
}

.info-panel-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.info-panel-section-content {
    color: var(--color-text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.info-panel-tables-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.info-panel-tables-list li {
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    background: var(--color-bg-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    color: var(--color-text);
}

.info-panel-tables-list li:hover {
    background: var(--color-bg-tertiary);
    transform: translateX(4px);
}

/* Legend */
.graph-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-md);
}

.legend-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Zoom Controls (optional) */
.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background: var(--color-bg-tertiary);
    border-color: var(--color-text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .graph-header {
        padding: 1rem;
    }

    .graph-header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .graph-controls {
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
    }

    .graph-search-box {
        max-width: 100%;
    }

    .table-search-container {
        max-width: 100%;
    }

    .info-panel {
        width: calc(100% - 40px);
        right: -100%;
    }

    .info-panel.active {
        right: 20px;
    }

    .graph-legend {
        bottom: 10px;
        left: 10px;
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
    }
}

/* Tooltips */
.graph-tooltip {
    position: absolute;
    background: var(--color-text);
    color: var(--color-bg);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1000;
    white-space: nowrap;
}

.graph-tooltip.active {
    opacity: 1;
}

/* Relationship Styles in Modal */
.relationships-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.relationship-group {
    flex: 1;
    min-width: 200px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
}

.relationship-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.relationship-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

.rel-item {
    padding: 0.4rem 0.5rem;
    margin-bottom: 0.25rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text);
}

.rel-item:hover {
    background: var(--color-bg-tertiary);
    transform: translateX(4px);
}

.rel-arrow {
    font-weight: bold;
    opacity: 0.7;
}

.rel-dependency .rel-arrow {
    color: var(--color-blue);
}

.rel-dependent .rel-arrow {
    color: var(--color-green);
}

.rel-cross-schema .rel-arrow {
    color: var(--primary-color);
}

.rel-schema {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin-left: auto;
}

.rel-more {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-style: italic;
    padding: 0.25rem 0.5rem;
}

.more-cols {
    color: var(--color-text-muted);
    font-style: italic;
    text-align: center;
}

/* Dune Link Styling */
.dune-link {
    color: var(--color-text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s;
}

.dune-link:hover {
    color: var(--primary-color);
}

.dune-link .link-icon {
    opacity: 0.6;
    transition: opacity 0.2s;
}

.dune-link:hover .link-icon {
    opacity: 1;
}

/* Detail Actions */
.detail-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.action-btn {
    padding: 0.5rem 1rem;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-text-muted);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-text);
    color: var(--color-bg);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10000;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
