/* main.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

.dashboard {
    display: flex;
    height: 100vh;
    gap: 1px;
    background: #ddd;
}

.tree-panel {
    flex: 2;
    background: white;
    position: relative;
    overflow: hidden;
}

.details-panel {
    flex: 1;
    background: white;
    display: flex;
    flex-direction: column;
    min-width: 350px;
    max-width: 450px;
}

.header {
    background: #2c3e50;
    color: white;
    padding: 15px;
    font-size: 14px;
    font-weight: 600;
}

.controls {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.variable-selector {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* Search functionality styles */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 8px 30px 8px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out;
}

.search-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.clear-search-btn:hover {
    background: #f0f0f0;
    color: #666;
}

.search-results {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    margin-top: 5px;
    display: none;
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    transition: background-color 0.2s ease;
}

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

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-item.highlighted {
    background: #e3f2fd;
}

.search-result-name {
    font-weight: 600;
    color: #2c3e50;
}

.search-result-code {
    color: #666;
    font-size: 11px;
    margin-left: 8px;
}

.search-result-level {
    color: #999;
    font-size: 10px;
    text-transform: uppercase;
    margin-left: 8px;
}

/* Tree control buttons */
.tree-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tree-control-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 80px;
}

.tree-control-btn:hover {
    background: #f8f9fa;
    border-color: #3498db;
}

.tree-control-btn:active {
    background: #e9ecef;
}

.details-content {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}

.node-info {
    background: linear-gradient(135deg, #f8f9fa, #ffffff);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.node-info h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 8px 0;
    padding: 6px 0;
    font-size: 14px;
    border-bottom: 1px solid #f1f3f4;
}

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

.info-label {
    font-weight: 600;
    color: #495057;
    flex: 1;
}

.info-value {
    color: #212529;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-weight: 500;
    text-align: right;
    flex: 1;
}

/* Enhanced visual indicators */
.significance-indicator {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.significance-indicator.significant {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    color: #155724;
    border: 1px solid #c3e6cb;
}

.significance-indicator.not-significant {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.coefficient-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.coefficient-badge.positive {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    color: #856404;
    border: 1px solid #ffeaa7;
}

.coefficient-badge.negative {
    background: linear-gradient(135deg, #d1ecf1, #bee5eb);
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.metric-card {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    transition: all 0.2s ease;
}

.metric-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: #3498db;
}

.metric-label {
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.metric-description {
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
    margin: 4px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.level-indicator {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.level-indicator.sic1 {
    background: #e74c3c;
    color: white;
}

.level-indicator.sic2 {
    background: #f39c12;
    color: white;
}

.level-indicator.sic3 {
    background: #f1c40f;
    color: #2c3e50;
}

.level-indicator.sic4 {
    background: #27ae60;
    color: white;
}

.level-indicator.sic5 {
    background: #8e44ad;
    color: white;
}

.spider-container {
    flex: 1;
    min-height: 300px;
    border-top: 1px solid #eee;
    padding: 15px;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-size: 16px;
}

.node circle {
    fill: #fff;
    stroke: #555;
    stroke-width: 1.5px;
    cursor: pointer;
}

.node text {
    font-size: 12px;
    font-family: sans-serif;
}

.link {
    fill: none;
    stroke: #555;
    stroke-opacity: 0.4;
    stroke-width: 1.5px;
}

.node:hover circle {
    stroke: #ff6b6b;
    stroke-width: 2px;
}

.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
}

/* Narrative Tab Styles */
.narrative-content {
    padding: 0;
    max-height: 100%;
    overflow-y: auto;
}

.narrative-placeholder {
    text-align: center;
    color: #666;
    padding: 50px 20px;
}

.data-availability {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 10px 15px;
    margin-bottom: 15px;
    font-size: 12px;
}

.availability-indicator {
    display: inline-flex;
    align-items: center;
    margin-right: 15px;
    font-weight: 600;
}

.availability-indicator.available {
    color: #28a745;
}

.availability-indicator.unavailable {
    color: #dc3545;
}

.availability-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}

.availability-indicator.available::before {
    background-color: #28a745;
}

.availability-indicator.unavailable::before {
    background-color: #dc3545;
}

.narrative-section {
    margin-bottom: 20px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.narrative-section-header {
    background: #f8f9fa;
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    color: #495057;
    transition: background-color 0.2s ease;
}

.narrative-section-header:hover {
    background: #e9ecef;
}

.narrative-section-header .icon {
    font-size: 16px;
    transition: transform 0.2s ease;
}

.narrative-section.expanded .narrative-section-header .icon {
    transform: rotate(90deg);
}

.narrative-section-content {
    padding: 15px;
    display: none;
}

.narrative-section.expanded .narrative-section-content {
    display: block;
}

.coefficient-interpretation {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

.coefficient-interpretation:last-child {
    margin-bottom: 0;
}

.coefficient-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 13px;
}

.coefficient-text {
    color: #495057;
    font-size: 14px;
    line-height: 1.4;
}

.significance-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 8px;
}

.significance-badge.significant {
    background-color: #d4edda;
    color: #155724;
}

.significance-badge.not-significant {
    background-color: #f8d7da;
    color: #721c24;
}

.cause-effect-chain {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

.cause-effect-chain:last-child {
    margin-bottom: 0;
}

.chain-flow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.chain-element {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
}

.chain-element.cause {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.chain-element.mechanism {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.chain-element.effect {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.chain-arrow {
    color: #6c757d;
    font-weight: bold;
}

.chain-coefficient {
    font-size: 11px;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 4px;
}

.example-firm {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

.example-firm:last-child {
    margin-bottom: 0;
}

.firm-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
}

.firm-id {
    font-size: 11px;
    color: #6c757d;
    margin-bottom: 6px;
}

.firm-description {
    color: #495057;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 8px;
}

.firm-website {
    font-size: 12px;
}

.firm-website a {
    color: #007bff;
    text-decoration: none;
}

.firm-website a:hover {
    text-decoration: underline;
}

.representative-statement {
    background: #f8f9fa;
    border-left: 4px solid #007bff;
    padding: 12px 15px;
    margin-bottom: 10px;
    font-style: italic;
    color: #495057;
    border-radius: 0 4px 4px 0;
}

.representative-statement:last-child {
    margin-bottom: 0;
}

.representative-statement::before {
    content: '"';
    font-size: 18px;
    color: #007bff;
    font-weight: bold;
}

.representative-statement::after {
    content: '"';
    font-size: 18px;
    color: #007bff;
    font-weight: bold;
}

.policy-request {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

.policy-request:last-child {
    margin-bottom: 0;
}

.policy-type {
    display: inline-block;
    background: #e9ecef;
    color: #495057;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.policy-description {
    color: #495057;
    font-size: 14px;
    line-height: 1.4;
}

.fallback-notice {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 15px;
    font-size: 12px;
    color: #856404;
}

.fallback-notice .icon {
    margin-right: 6px;
}

.no-data-message {
    text-align: center;
    color: #6c757d;
    padding: 30px 20px;
    font-style: italic;
}

.viz-tabs {
    display: flex;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 0;
}

.tab-button {
    background: none;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-size: 13px;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.2s ease;
}

.tab-button:hover {
    color: #495057;
    background: #f8f9fa;
}

.tab-button.active {
    color: #007bff;
    border-bottom-color: #007bff;
    background: #fff;
}

.tab-panel {
    display: none;
    padding: 15px;
    height: 300px;
    overflow-y: auto;
}

.tab-panel.active {
    display: block;
}

.visualizations-container {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-top: 15px;
    overflow: hidden;
}
