:root {
    --bg-color: #f4f4f9;
    --text-color: #333;
    --header-bg: #fff;
    --panel-bg: #fff;
    --border-color: #ddd;
    --primary-color: #007bff;
    --hover-bg: #e9ecef;

    --sentiment-positive: #2ca02c;
    --sentiment-negative: #d62728;
    --sentiment-neutral: #7f7f7f;
    --sentiment-undetermined: #ffbf00;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

header {
    background-color: var(--header-bg);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

h1 {
    margin: 0;
    font-size: 1.5rem;
}

.controls-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.pipeline-controls,
.dataset-controls,
.analysis-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.pipeline-controls h3,
.dataset-controls h3,
.analysis-controls h3 {
    margin: 0;
    font-size: 1rem;
    margin-right: 0.5rem;
    min-width: 140px;
    white-space: nowrap;
}

.pipeline-controls input[type="text"] {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 200px;
}

.pipeline-controls select,
.dataset-controls select,
.analysis-controls select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.pipeline-controls button,
.dataset-controls button,
.analysis-controls button {
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.analysis-controls button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.pipeline-controls button:hover:not(:disabled),
.dataset-controls button:hover:not(:disabled),
.analysis-controls button:hover:not(:disabled) {
    background-color: #0056b3;
}

.controls {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.filter-list {
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    background: #fff;
    padding: 0.5rem;
    min-width: 160px;
    border-radius: 4px;
}

.filter-list label {
    display: block;
    font-size: 0.8rem;
    font-weight: normal;
    cursor: pointer;
    margin-bottom: 0.25rem;
    white-space: nowrap;
}

.filter-list input {
    margin-right: 0.5rem;
}

main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.grid-container {
    flex: 2;
    overflow: auto;
    padding: 1rem;
    background-color: #fff;
    border-right: 1px solid var(--border-color);
}

.details-panel {
    flex: 1;
    padding: 1rem;
    background-color: var(--panel-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 310px;
}

/* Grid Table Styles */
table.ticker-grid {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.9rem;
}

th,
td {
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: left;
}

th {
    background-color: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

th.ticker-col {
    position: sticky;
    left: 0;
    z-index: 20;
    background-color: #f8f9fa;
    border-right: 2px solid var(--border-color);
}

td.ticker-col {
    position: sticky;
    left: 0;
    z-index: 15;
    background-color: #fff;
    border-right: 2px solid var(--border-color);
    font-weight: bold;
    cursor: pointer;
}

td.ticker-col.selected {
    background-color: #e3f2fd;
    color: var(--primary-color);
}

.cell-content {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.provider-badge {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 50%;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
}

.provider-badge.positive {
    background-color: var(--sentiment-positive);
}

.provider-badge.negative {
    background-color: var(--sentiment-negative);
}

.provider-badge.neutral {
    background-color: var(--sentiment-neutral);
}

.provider-badge.undetermined {
    background-color: var(--sentiment-undetermined);
}

.provider-badge.selected {
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #333;
    transform: scale(1.2);
    z-index: 5;
}

/* Details Panel */
.json-output-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.5rem;
    height: 100%;
}

#json-output {
    flex: 1;
    background-color: #282c34;
    color: #abb2bf;
    padding: 1rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    border: 1px solid #444;
    resize: none;
}

#copy-btn {
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

#copy-btn:hover {
    background-color: #0056b3;
}

#copy-btn:active {
    transform: translateY(1px);
}

.selected-item strong {
    display: block;
    margin-bottom: 0.25rem;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background-color: #282c34;
    color: #abb2bf;
    padding: 1rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    z-index: 1000;
    pointer-events: auto;
    /* Allow clicking links inside */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    white-space: pre-wrap;
    border: 1px solid #444;
}

/* Floating Terminal */
.floating-terminal {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 600px;
    height: 400px;
    background-color: #1e1e1e;
    border: 1px solid #333;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 2000;
}

.terminal-header {
    background-color: #333;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: bold;
}

.terminal-header button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-weight: bold;
}

.terminal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background-color: #1e1e1e;
}

#terminal-output {
    margin: 0;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    color: #d4d4d4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Selected Data Panel Styles */
.selected-data-list {
    flex: 1;
    overflow-y: auto;
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
}

.selected-data-card {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.selected-data-card h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: var(--primary-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 0.25rem;
}

.selected-data-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.selected-data-label {
    font-weight: bold;
    color: #666;
}

.selected-data-value {
    color: #333;
    text-align: right;
    max-width: 70%;
    word-wrap: break-word;
}

.placeholder-text {
    color: #999;
    text-align: center;
    margin-top: 2rem;
    font-style: italic;
}

/* Sentiment Text Colors */
.sentiment-text-positive {
    color: var(--sentiment-positive);
    font-weight: bold;
}

.sentiment-text-negative {
    color: var(--sentiment-negative);
    font-weight: bold;
}

.sentiment-text-neutral {
    color: var(--sentiment-neutral);
    font-weight: bold;
}

.sentiment-text-undetermined {
    color: var(--sentiment-undetermined);
    font-weight: bold;
}