/* Nightwatch Custom Styles */

:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --light-bg: #ecf0f1;
    --dark-bg: #1a1a1a;
}

body {
    padding-top: 60px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Navigation Enhancement */
.navbar-dark {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.navbar-brand i {
    color: var(--accent-color);
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 1.5rem;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.card-header {
    background-color: var(--light-bg);
    border-bottom: 2px solid var(--accent-color);
}

/* Progress Bars */
.progress {
    background-color: var(--light-bg);
}

.progress-bar {
    background: linear-gradient(90deg, var(--accent-color), var(--success-color));
}

/* Badges */
.badge {
    padding: 0.5em 0.75em;
    font-weight: 500;
}

/* Buttons */
.btn {
    border-radius: 5px;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), #2980b9);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2980b9, var(--accent-color));
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Accordion */
.accordion-button:not(.collapsed) {
    background-color: var(--light-bg);
    color: var(--primary-color);
}

.accordion-button:focus {
    box-shadow: none;
    border-color: var(--accent-color);
}

/* Tables */
.table {
    background-color: white;
}

.table-hover tbody tr:hover {
    background-color: rgba(52, 152, 219, 0.05);
}

/* List Groups */
.list-group-item {
    transition: background-color 0.2s;
}

.list-group-item:hover {
    background-color: var(--light-bg);
}

.list-group-item-action:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

/* Footer */
.footer {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
    margin-top: auto;
}

/* Loading Spinner */
.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3em;
}

/* Scenario Matrix Visualization */
.scenario-matrix {
    position: relative;
    width: 100%;
    height: 400px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    margin: 20px 0;
}

.scenario-quadrant {
    position: absolute;
    width: 50%;
    height: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    transition: background-color 0.3s;
}

.scenario-quadrant:hover {
    background-color: rgba(52, 152, 219, 0.1);
    cursor: pointer;
}

.quadrant-q1 { top: 0; right: 0; }
.quadrant-q2 { top: 0; left: 0; }
.quadrant-q3 { bottom: 0; left: 0; }
.quadrant-q4 { bottom: 0; right: 0; }

/* Step Indicators */
.step-indicator {
    display: flex;
    justify-content: space-between;
    margin: 30px 0;
    position: relative;
}

.step-indicator::before {
    content: "";
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--light-bg);
    z-index: -1;
}

.step-item {
    background-color: white;
    border: 2px solid var(--light-bg);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    transition: all 0.3s;
}

.step-item.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.step-item.completed {
    background-color: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

/* Driving Forces Chart */
.force-chart {
    position: relative;
    width: 100%;
    height: 400px;
    border: 1px solid var(--light-bg);
    border-radius: 8px;
}

.force-point {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--accent-color);
    transform: translate(-50%, -50%);
    cursor: pointer;
}

.force-point:hover {
    width: 15px;
    height: 15px;
    background-color: var(--warning-color);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--light-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

/* Chat Panel Styles */
.chat-panel {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    background-color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.chat-messages-container {
    height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.chat-welcome-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #6c757d;
}

.chat-message {
    margin-bottom: 1rem;
    animation: fadeInUp 0.3s ease-out;
}

.chat-message-content {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
}

.user-message {
    background: linear-gradient(135deg, var(--accent-color), #2980b9);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.assistant-message {
    background-color: white;
    border: 1px solid #e9ecef;
    color: #333;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.error-message {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    opacity: 0.8;
}

.message-text {
    line-height: 1.4;
    font-size: 0.95rem;
}

.message-text p {
    margin-bottom: 0.5rem;
}

.message-text p:last-child {
    margin-bottom: 0;
}

/* Typing Animation */
.typing-animation {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
}

.typing-animation span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-color);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-animation span:nth-child(1) {
    animation-delay: 0s;
}

.typing-animation span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-animation span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.3;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Chat Input Area */
.chat-input-container {
    background-color: white;
    border-top: 1px solid #dee2e6;
}

.chat-input-container .form-select {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #495057;
}

.chat-input-container .form-control {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    resize: none;
    font-size: 0.95rem;
    line-height: 1.4;
    transition: border-color 0.2s ease;
}

.chat-input-container .form-control:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.chat-input-container .btn-primary {
    border-radius: 8px;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

/* Chat Controls */
.chat-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-controls .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 4px;
}

/* Context Badges */
.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Custom Scrollbar for Chat */
.chat-messages-container::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Chat Panel Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        max-height: 500px;
        transform: translateY(0);
    }
}

.chat-panel-row {
    animation: slideDown 0.3s ease-out;
}

/* Chat Panel Toggle Button States */
#toggle-chat-btn {
    transition: all 0.3s ease;
}

#toggle-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#toggle-chat-btn .bi-chat-dots-fill {
    color: var(--accent-color);
}

/* Responsive Chat Panel */
@media (max-width: 991.98px) {
    .chat-messages-container {
        height: 300px;
    }
    
    .chat-message-content {
        max-width: 95%;
    }
    
    .message-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

@media (max-width: 767.98px) {
    .chat-messages-container {
        height: 250px;
    }
    
    .chat-input-container {
        padding: 0.75rem !important;
    }
    
    .input-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .input-group .form-control {
        border-radius: 8px !important;
    }
    
    .input-group .btn {
        border-radius: 8px !important;
        width: 100%;
    }
    
    .chat-controls {
        justify-content: center;
        gap: 0.25rem;
    }
    
    .chat-controls .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Citation System Styles */

/* Citation Markers */
.citation-marker {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent-color), #2980b9);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    margin: 0 0.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    vertical-align: super;
    line-height: 1;
    min-width: 16px;
    text-align: center;
}

.citation-marker:hover {
    background: linear-gradient(135deg, #2980b9, var(--accent-color));
    transform: scale(1.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    color: white;
    text-decoration: none;
}

.citation-marker:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Citation Tooltips */
.citation-tooltip {
    position: absolute;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    max-width: 350px;
    z-index: 1050;
    font-size: 0.875rem;
    line-height: 1.4;
    display: none;
    animation: fadeInTooltip 0.2s ease-out;
}

.citation-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
}

.citation-tooltip.show {
    display: block;
}

.citation-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e9ecef;
}

.citation-tooltip-title {
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.3;
    flex: 1;
    margin-right: 0.5rem;
}

.citation-tooltip-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.citation-tooltip-close:hover {
    background-color: #f8f9fa;
    color: var(--danger-color);
}

.citation-tooltip-content {
    color: #495057;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.4;
}

.citation-tooltip-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.citation-tooltip-date {
    font-size: 0.75rem;
    color: #6c757d;
    font-style: italic;
}

/* Credibility Badges */
.credibility-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

.credibility-high {
    background-color: var(--success-color);
    color: white;
}

.credibility-medium {
    background-color: var(--warning-color);
    color: white;
}

.credibility-low {
    background-color: var(--danger-color);
    color: white;
}

/* Bias Indicators */
.bias-indicator {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
}

.bias-left {
    background-color: #007bff;
    color: white;
}

.bias-center {
    background-color: #6c757d;
    color: white;
}

.bias-right {
    background-color: #dc3545;
    color: white;
}

/* Source Type Badges */
.source-type-badge {
    display: inline-block;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: capitalize;
    background-color: var(--light-bg);
    color: var(--primary-color);
    border: 1px solid #dee2e6;
}

/* Citation Reference Sections */
.citation-references {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.citation-references-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
}

.citation-references-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.citation-references-toggle {
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.citation-references-toggle:hover {
    background-color: rgba(52, 152, 219, 0.1);
    color: #2980b9;
}

.citation-references-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.citation-reference-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.875rem;
    line-height: 1.4;
}

.citation-reference-item:last-child {
    border-bottom: none;
}

.citation-reference-number {
    background: var(--accent-color);
    color: white;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    min-width: 24px;
    text-align: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.citation-reference-content {
    flex: 1;
}

.citation-reference-source {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.citation-reference-text {
    color: #495057;
    margin-bottom: 0.5rem;
    font-style: italic;
}

.citation-reference-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.citation-reference-link {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s ease;
}

.citation-reference-link:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* Citation Generation Controls */
.citation-controls {
    margin: 1.5rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.citation-controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.citation-controls-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.citation-generate-btn {
    background: linear-gradient(135deg, var(--success-color), #219a52);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.citation-generate-btn:hover {
    background: linear-gradient(135deg, #219a52, var(--success-color));
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.citation-generate-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.citation-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-color);
    font-size: 0.875rem;
}

.citation-loading .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

.citation-status {
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.citation-status.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.citation-status.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.citation-status.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Citation Panel Toggle */
.citation-panel-toggle {
    background: none;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.citation-panel-toggle:hover {
    background-color: var(--accent-color);
    color: white;
}

.citation-panel-toggle.active {
    background-color: var(--accent-color);
    color: white;
}

/* Citation Highlight */
.citation-highlight {
    background-color: rgba(52, 152, 219, 0.1);
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.citation-highlight:hover {
    background-color: rgba(52, 152, 219, 0.2);
}

/* Citation Animations */
@keyframes fadeInTooltip {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes citationPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.citation-marker.pulse {
    animation: citationPulse 0.6s ease-in-out;
}

/* Responsive Citation Styles */
@media (max-width: 768px) {
    .citation-tooltip {
        max-width: 280px;
        font-size: 0.8rem;
        padding: 0.75rem;
    }
    
    .citation-tooltip-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .citation-references {
        padding: 1rem;
    }
    
    .citation-reference-item {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .citation-reference-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .citation-controls {
        padding: 0.75rem;
    }
    
    .citation-controls-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
}

@media (max-width: 576px) {
    .citation-marker {
        font-size: 0.7rem;
        padding: 0.15rem 0.3rem;
    }
    
    .citation-tooltip {
        max-width: 260px;
        left: 50% !important;
        transform: translateX(-50%);
    }
    
    .citation-tooltip::before {
        left: 50%;
        transform: translateX(-50%);
    }
}

/* S&P Analysis Styles */

/* S&P Analysis Controls */
.sp-analysis-controls {
    margin: 1.5rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.sp-analysis-controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sp-analysis-controls-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sp-analysis-generate-btn {
    background: linear-gradient(135deg, #007bff, #0056b3);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sp-analysis-generate-btn:hover {
    background: linear-gradient(135deg, #0056b3, #007bff);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.sp-analysis-generate-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.sp-analysis-toggle {
    background: none;
    border: 1px solid #007bff;
    color: #007bff;
    padding: 0.375rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.sp-analysis-toggle:hover {
    background-color: #007bff;
    color: white;
}

.sp-analysis-toggle.active {
    background-color: #007bff;
    color: white;
}

/* S&P Analysis Status */
.sp-analysis-status {
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.sp-analysis-status.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.sp-analysis-status.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.sp-analysis-status.loading {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.sp-analysis-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #007bff;
    font-size: 0.875rem;
}

.sp-analysis-loading .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* S&P Analysis Overlays */
.scenario-matrix-container {
    position: relative;
}

.scenario-quadrant-card {
    position: relative;
    overflow: visible;
}

.sp-analysis-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 0.5rem;
    z-index: 10;
    backdrop-filter: blur(2px);
    border: 2px solid rgba(0, 123, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.sp-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.sp-overlay-toggle {
    display: flex;
    gap: 0.25rem;
}

.sp-overlay-toggle .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 3px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.sp-overlay-toggle .btn:hover {
    opacity: 1;
}

.sp-overlay-content {
    height: calc(100% - 2rem);
    overflow: hidden;
}

/* S&P Summary Content */
.sp-summary-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 100%;
}

.sp-impact-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0.5rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.sp-impact-score.impact-very-positive {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.sp-impact-score.impact-positive {
    background: linear-gradient(135deg, #20c997, #17a2b8);
    color: white;
}

.sp-impact-score.impact-neutral {
    background: linear-gradient(135deg, #6c757d, #adb5bd);
    color: white;
}

.sp-impact-score.impact-negative {
    background: linear-gradient(135deg, #fd7e14, #dc3545);
    color: white;
}

.sp-impact-score.impact-very-negative {
    background: linear-gradient(135deg, #dc3545, #721c24);
    color: white;
}

.sp-impact-icon {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.sp-impact-value {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
}

.sp-impact-label {
    font-size: 0.7rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sp-favorability {
    text-align: center;
    margin-bottom: 0.5rem;
}

.sp-favorability-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sp-favorability-badge.highly_favorable {
    background-color: #28a745;
    color: white;
}

.sp-favorability-badge.favorable {
    background-color: #20c997;
    color: white;
}

.sp-favorability-badge.neutral {
    background-color: #6c757d;
    color: white;
}

.sp-favorability-badge.unfavorable {
    background-color: #fd7e14;
    color: white;
}

.sp-favorability-badge.highly_unfavorable {
    background-color: #dc3545;
    color: white;
}

.sp-quick-stats {
    display: flex;
    justify-content: space-around;
    gap: 0.5rem;
}

.sp-stat {
    text-align: center;
    flex: 1;
}

.sp-stat-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.sp-stat-label {
    display: block;
    font-size: 0.7rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* S&P Details Content */
.sp-details-content {
    padding: 0.5rem;
    background: white;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    height: 100%;
    overflow-y: auto;
}

.sp-details-section {
    margin-bottom: 1rem;
}

.sp-details-section:last-child {
    margin-bottom: 0;
}

.sp-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.sp-company-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* S&P Company Cards */
.sp-company-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 0.5rem;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.sp-company-card:hover {
    border-color: #007bff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.sp-company-card.winner {
    border-left: 3px solid #28a745;
}

.sp-company-card.loser {
    border-left: 3px solid #dc3545;
}

.sp-company-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.sp-company-symbol {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--primary-color);
}

.sp-company-score {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    margin-left: auto;
}

.sp-company-score.impact-very-positive {
    background-color: #28a745;
    color: white;
}

.sp-company-score.impact-positive {
    background-color: #20c997;
    color: white;
}

.sp-company-score.impact-neutral {
    background-color: #6c757d;
    color: white;
}

.sp-company-score.impact-negative {
    background-color: #fd7e14;
    color: white;
}

.sp-company-score.impact-very-negative {
    background-color: #dc3545;
    color: white;
}

.sp-company-name {
    font-size: 0.7rem;
    color: #495057;
    margin-bottom: 0.1rem;
    line-height: 1.2;
}

.sp-company-sector {
    font-size: 0.65rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
}

.sp-company-performance {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.1rem 0.25rem;
    border-radius: 2px;
    text-align: center;
}

.sp-company-performance.performance-strong-outperform {
    background-color: #28a745;
    color: white;
}

.sp-company-performance.performance-outperform {
    background-color: #20c997;
    color: white;
}

.sp-company-performance.performance-neutral {
    background-color: #6c757d;
    color: white;
}

.sp-company-performance.performance-underperform {
    background-color: #fd7e14;
    color: white;
}

.sp-company-performance.performance-strong-underperform {
    background-color: #dc3545;
    color: white;
}

/* S&P Sector Breakdown */
.sp-sector-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sp-sector-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: #f8f9fa;
    border-radius: 3px;
    border: 1px solid #e9ecef;
}

.sp-sector-name {
    font-size: 0.7rem;
    color: var(--primary-color);
    flex: 1;
}

.sp-sector-count {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6c757d;
    background: white;
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
    min-width: 20px;
    text-align: center;
}

/* S&P Company Tooltips */
.sp-company-tooltip {
    position: absolute;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    max-width: 300px;
    z-index: 1060;
    font-size: 0.875rem;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

/* Concise hover tooltip for S&P companies */
.sp-tooltip {
    position: absolute;
    pointer-events: none;
    z-index: 999;
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    max-width: 260px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sp-company-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

.sp-company-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
}

.sp-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e9ecef;
}

.sp-tooltip-header h6 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    flex: 1;
    margin-right: 0.5rem;
}

.sp-tooltip-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.sp-tooltip-close:hover {
    background-color: #f8f9fa;
    color: var(--danger-color);
}

.sp-tooltip-content {
    font-size: 0.8rem;
}

.sp-tooltip-section {
    margin-bottom: 0.5rem;
}

.sp-tooltip-section:last-child {
    margin-bottom: 0;
}

.sp-tooltip-list {
    margin: 0.25rem 0 0 0;
    padding-left: 1rem;
}

.sp-tooltip-list li {
    margin-bottom: 0.1rem;
    font-size: 0.75rem;
    line-height: 1.3;
}

/* S&P Loading States */
.sp-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    color: #6c757d;
    font-size: 0.8rem;
    text-align: center;
}

/* S&P Analysis Animations */
@keyframes spFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sp-analysis-overlay {
    animation: spFadeIn 0.3s ease-out;
}

@keyframes spPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.sp-company-card:hover {
    animation: spPulse 0.6s ease-in-out;
}

/* Responsive S&P Analysis Styles */
@media (max-width: 991.98px) {
    .sp-analysis-overlay {
        padding: 0.3rem;
        font-size: 0.8rem;
    }
    
    .sp-impact-score {
        padding: 0.3rem;
    }
    
    .sp-company-card {
        padding: 0.3rem;
    }
    
    .sp-company-tooltip {
        max-width: 250px;
        font-size: 0.8rem;
        padding: 0.75rem;
    }
}

@media (max-width: 767.98px) {
    .sp-analysis-controls {
        padding: 0.75rem;
    }
    
    .sp-analysis-controls-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .sp-analysis-overlay {
        position: relative;
        background: rgba(255, 255, 255, 0.98);
        margin-top: 0.5rem;
        border: 1px solid #dee2e6;
    }
    
    .sp-company-tooltip {
        max-width: 200px;
        font-size: 0.75rem;
        left: 50% !important;
        transform: translateX(-50%);
    }
    
    .sp-company-tooltip::before {
        left: 50%;
        transform: translateX(-50%);
    }
    
    .sp-quick-stats {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .sp-details-content {
        max-height: 200px;
    }
}

@media (max-width: 575.98px) {
    .sp-analysis-overlay {
        padding: 0.25rem;
    }
    
    .sp-company-card {
        padding: 0.25rem;
    }
    
    .sp-company-name {
        font-size: 0.65rem;
    }
    
    .sp-company-symbol {
        font-size: 0.75rem;
    }
    
    .sp-impact-score {
        padding: 0.25rem;
    }
    
    .sp-impact-value {
        font-size: 1rem;
    }
}

/* PDF Generation Styles */

/* PDF Generation Controls */
.pdf-generation-controls {
    margin: 1.5rem 0;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.pdf-generation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.pdf-generation-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pdf-generate-btn {
    background: linear-gradient(135deg, #dc3545, #c82333);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pdf-generate-btn:hover {
    background: linear-gradient(135deg, #c82333, #dc3545);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.pdf-generate-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pdf-format-selection {
    margin-top: 1rem;
}

.pdf-format-selection .form-label {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.pdf-format-selection .form-select {
    border: 2px solid #dee2e6;
    border-radius: 6px;
    transition: border-color 0.2s ease;
}

.pdf-format-selection .form-select:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* PDF Status Container */
.pdf-status-container {
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

.pdf-status-container.generating {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.pdf-status-container.success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.pdf-status-container.error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* PDF Generation Modal Styles */
.pdf-progress-section {
    padding: 1rem 0;
}

.pdf-progress-section .progress {
    height: 20px;
    background-color: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.pdf-progress-section .progress-bar {
    background: linear-gradient(90deg, #dc3545, #c82333);
    transition: width 0.3s ease;
}

.pdf-status-message {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #dc3545;
}

.pdf-status-message .spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
    color: #dc3545;
}

.pdf-report-details {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.pdf-report-details .row {
    margin-bottom: 0.5rem;
}

.pdf-report-details .row:last-child {
    margin-bottom: 0;
}

.pdf-report-details small {
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* PDF Completion Section */
.pdf-completion-section {
    text-align: center;
    padding: 2rem 1rem;
}

.success-icon {
    animation: successPulse 0.6s ease-in-out;
}

@keyframes successPulse {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.report-info {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
}

.report-info .row {
    align-items: center;
}

.report-info small {
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
}

#pdf-download-btn {
    background: linear-gradient(135deg, #28a745, #20c997);
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
}

#pdf-download-btn:hover {
    background: linear-gradient(135deg, #20c997, #28a745);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* PDF Error Section */
.pdf-error-section {
    text-align: center;
    padding: 2rem 1rem;
}

.error-icon {
    animation: errorShake 0.6s ease-in-out;
}

@keyframes errorShake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.error-details {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 1rem;
    text-align: left;
}

.error-details small {
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* PDF History Styles */
.pdf-history-list {
    max-height: 400px;
    overflow-y: auto;
}

.pdf-history-item {
    padding: 1rem;
    margin-bottom: 0.75rem;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    border-left: 4px solid #dc3545;
    transition: all 0.2s ease;
}

.pdf-history-item:hover {
    border-color: #dc3545;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateX(2px);
}

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

.pdf-history-item .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

.pdf-history-item .badge.text-success {
    background-color: #d4edda;
    color: #155724;
}

.pdf-history-item .badge.text-primary {
    background-color: #d1ecf1;
    color: #0c5460;
}

.pdf-history-item .badge.text-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.pdf-history-item .badge.text-warning {
    background-color: #fff3cd;
    color: #856404;
}

.pdf-history-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.pdf-history-actions .btn {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 4px;
}

/* PDF Loading Animation */
.pdf-generating-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #dc3545;
    font-weight: 500;
}

.pdf-generating-indicator .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* PDF Progress Badge */
#pdf-progress-percentage {
    background: linear-gradient(135deg, #dc3545, #c82333);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
}

/* PDF Modal Customizations */
#pdfGenerationModal .modal-header {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    border-bottom: none;
}

#pdfGenerationModal .modal-header .btn-close {
    filter: invert(1);
}

#pdfGenerationModal .modal-body {
    padding: 2rem;
}

#pdfGenerationModal .modal-footer {
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

/* Responsive PDF Styles */
@media (max-width: 991.98px) {
    .pdf-generation-controls {
        padding: 0.75rem;
    }
    
    .pdf-generation-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .pdf-generate-btn {
        width: 100%;
        justify-content: center;
    }
    
    .pdf-report-details .row {
        margin-bottom: 0.75rem;
    }
    
    .pdf-history-actions {
        flex-direction: column;
        gap: 0.25rem;
        width: 100%;
    }
    
    .pdf-history-actions .btn {
        width: 100%;
    }
}

@media (max-width: 767.98px) {
    #pdfGenerationModal .modal-body {
        padding: 1rem;
    }
    
    .pdf-completion-section,
    .pdf-error-section {
        padding: 1rem 0.5rem;
    }
    
    .report-info .row {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .pdf-history-item {
        padding: 0.75rem;
    }
    
    .pdf-history-item .d-flex {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .pdf-format-selection {
        margin-top: 0.75rem;
    }
}

@media (max-width: 575.98px) {
    .pdf-generate-btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .pdf-generation-title {
        font-size: 0.9rem;
    }
    
    #pdf-download-btn {
        padding: 0.5rem 1.5rem;
        font-size: 1rem;
    }
    
    .success-icon i,
    .error-icon i {
        font-size: 2rem !important;
    }
}

/* S&P Scatter Plot Visualization Styles */

/* Main Plot Container */
.sp-quadrant-visualization {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 1rem;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sp-plot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--accent-color);
}

.sp-plot-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sp-plot-controls {
    display: flex;
    gap: 0.5rem;
}

.sp-plot-controls .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 4px;
}

/* Scatter Plot SVG */
.sp-scatter-plot-container {
    position: relative;
    width: 100%;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.sp-scatter-plot {
    width: 100%;
    height: 400px;
    border-radius: 6px;
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
}

/* Quadrant Background Areas */
.sp-quadrant-bg {
    opacity: 0.3;
    transition: opacity 0.2s ease;
}

.sp-quadrant-bg:hover {
    opacity: 0.5;
}

.sp-q1 {
    fill: rgba(40, 167, 69, 0.1);
}

.sp-q2 {
    fill: rgba(0, 123, 255, 0.1);
}

.sp-q3 {
    fill: rgba(255, 193, 7, 0.1);
}

.sp-q4 {
    fill: rgba(220, 53, 69, 0.1);
}

/* Grid Lines */
.sp-grid-lines line {
    stroke: #dee2e6;
    stroke-width: 2;
    stroke-dasharray: 5, 5;
}

/* Axis Labels and Titles */
.sp-quadrant-label {
    font-size: 14px;
    font-weight: 700;
    fill: var(--primary-color);
    text-anchor: middle;
    dominant-baseline: middle;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sp-axis-title {
    font-size: 12px;
    font-weight: 600;
    fill: var(--secondary-color);
    text-anchor: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Company Dots */
.sp-company-dot {
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.8;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.sp-company-dot:hover {
    opacity: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transform: scale(1.1);
}

.sp-company-dot:active {
    transform: scale(0.95);
}

/* Legend */
.sp-legend {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 0.75rem;
    max-width: 200px;
    backdrop-filter: blur(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sp-legend-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0 0 0.5rem 0;
    text-align: center;
}

.sp-legend-items {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sp-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    line-height: 1.2;
}

.sp-legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.sp-legend-label {
    color: var(--primary-color);
    font-weight: 500;
}

/* Company Preview Tooltip */
.sp-company-preview-tooltip {
    position: absolute;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    z-index: 1000;
    display: none;
    pointer-events: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    max-width: 200px;
}

.sp-company-preview-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 10px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--primary-color);
}

.sp-preview-header {
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--accent-color);
}

.sp-preview-content {
    line-height: 1.3;
}

.sp-preview-sector {
    font-size: 0.75rem;
    opacity: 0.8;
    margin: 0.25rem 0;
}

.sp-preview-score {
    font-weight: 600;
    color: #ffc107;
}

/* Detailed Company Tooltip */
.sp-detailed-tooltip {
    position: absolute;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    padding: 1rem;
    max-width: 350px;
    z-index: 1060;
    font-size: 0.875rem;
    line-height: 1.4;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.sp-detailed-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

.sp-detailed-tooltip::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
}

.sp-detailed-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e9ecef;
}

.sp-tooltip-company-info h6 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    line-height: 1.2;
}

.sp-tooltip-sector {
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 0.25rem;
}

.sp-tooltip-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sp-tooltip-close:hover {
    background-color: #f8f9fa;
    color: var(--danger-color);
}

.sp-detailed-tooltip-content {
    font-size: 0.85rem;
}

.sp-tooltip-section {
    margin-bottom: 0.75rem;
}

.sp-tooltip-section:last-child {
    margin-bottom: 0;
}

.sp-impact-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.sp-impact-display.impact-very-positive {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

.sp-impact-display.impact-positive {
    background: linear-gradient(135deg, #20c997, #17a2b8);
    color: white;
}

.sp-impact-display.impact-neutral {
    background: linear-gradient(135deg, #6c757d, #adb5bd);
    color: white;
}

.sp-impact-display.impact-negative {
    background: linear-gradient(135deg, #fd7e14, #dc3545);
    color: white;
}

.sp-impact-display.impact-very-negative {
    background: linear-gradient(135deg, #dc3545, #721c24);
    color: white;
}

.sp-impact-label {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.9;
}

.sp-impact-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.sp-performance-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 0.5rem;
}

.sp-performance-badge.performance-strong-outperform {
    background-color: #28a745;
    color: white;
}

.sp-performance-badge.performance-outperform {
    background-color: #20c997;
    color: white;
}

.sp-performance-badge.performance-neutral {
    background-color: #6c757d;
    color: white;
}

.sp-performance-badge.performance-underperform {
    background-color: #fd7e14;
    color: white;
}

.sp-performance-badge.performance-strong-underperform {
    background-color: #dc3545;
    color: white;
}

.sp-reasoning-text {
    font-size: 0.8rem;
    line-height: 1.4;
    color: #495057;
    margin: 0.25rem 0 0 0;
}

.sp-tooltip-list {
    margin: 0.25rem 0 0 0;
    padding-left: 1rem;
    list-style-type: disc;
}

.sp-tooltip-list li {
    margin-bottom: 0.1rem;
    font-size: 0.8rem;
    line-height: 1.3;
}

/* Responsive Scatter Plot Styles */
@media (max-width: 991.98px) {
    .sp-scatter-plot {
        height: 350px;
    }
    
    .sp-plot-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .sp-plot-controls {
        justify-content: center;
    }
    
    .sp-legend {
        position: relative;
        top: auto;
        right: auto;
        margin-top: 0.75rem;
        max-width: 100%;
    }
    
    .sp-legend-items {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .sp-detailed-tooltip {
        max-width: 280px;
        font-size: 0.8rem;
        padding: 0.75rem;
    }
}

@media (max-width: 767.98px) {
    .sp-scatter-plot {
        height: 300px;
    }
    
    .sp-quadrant-visualization {
        padding: 0.75rem;
    }
    
    .sp-plot-title {
        font-size: 1rem;
    }
    
    .sp-plot-controls .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .sp-legend {
        padding: 0.5rem;
    }
    
    .sp-legend-title {
        font-size: 0.8rem;
    }
    
    .sp-legend-item {
        font-size: 0.7rem;
    }
    
    .sp-detailed-tooltip {
        max-width: 260px;
        left: 50% !important;
        transform: translateX(-50%);
    }
    
    .sp-detailed-tooltip::before {
        left: 50%;
        transform: translateX(-50%);
    }
    
    .sp-company-preview-tooltip {
        max-width: 150px;
        font-size: 0.75rem;
    }
}

@media (max-width: 575.98px) {
    .sp-scatter-plot {
        height: 250px;
    }
    
    .sp-quadrant-label {
        font-size: 10px;
    }
    
    .sp-axis-title {
        font-size: 9px;
    }
    
    .sp-legend-items {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .sp-legend-color {
        width: 10px;
        height: 10px;
    }
    
    .sp-detailed-tooltip-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .sp-plot-controls {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .sp-plot-controls .btn {
        width: 100%;
    }
}

/* Animation for scatter plot loading */
@keyframes spDotFadeIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 0.8;
        transform: scale(1);
    }
}

.sp-company-dot {
    animation: spDotFadeIn 0.3s ease-out forwards;
}

/* Hover effects for quadrant backgrounds */
.sp-quadrant-bg {
    cursor: pointer;
}

.sp-quadrant-bg:hover {
    opacity: 0.2;
    transition: opacity 0.2s ease;
}

/* Loading state for scatter plot */
.sp-scatter-plot-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: #6c757d;
    font-size: 0.9rem;
}

.sp-scatter-plot-loading .spinner-border {
    width: 2rem;
    height: 2rem;
    margin-right: 0.75rem;
}


/* Empty visualization message */
.sp-empty-message {
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 2rem;
    border: 2px dashed #dee2e6;
}

/* Responsive Design */
@media (max-width: 768px) {
    .scenario-matrix {
        height: 300px;
    }
    
    .step-indicator {
        flex-direction: column;
        align-items: center;
    }
    
    .step-indicator::before {
        width: 2px;
        height: 100%;
        top: 0;
        left: 50%;
    }
    
    .step-item {
        margin: 10px 0;
    }
    
    .sp-scenario-vertex-label {
        font-size: 9px;
    }
    
    .sp-detailed-scenario-tooltip {
        max-width: 280px;
        font-size: 0.8rem;
        padding: 0.75rem;
    }
    
    .sp-scenario-preview-tooltip {
        max-width: 150px;
        font-size: 0.75rem;
    }
}

/* =============================================
   ENHANCED AUTOMATIC CITATION SYSTEM STYLING
   ============================================= */

/* Enhanced citation marks for automatic injection */
.citation-mark {
    color: #0d6efd;
    font-weight: 700;
    font-size: 0.75em;
    text-decoration: none;
    cursor: help;
    transition: all 0.2s ease;
    padding: 0.1em 0.3em;
    border-radius: 3px;
    background: rgba(13, 110, 253, 0.1);
    margin: 0 0.1em;
    display: inline-block;
    line-height: 1;
    vertical-align: super;
}

.citation-mark:hover {
    color: #0a58ca;
    background: rgba(13, 110, 253, 0.2);
    transform: scale(1.1);
    text-decoration: none;
}

/* Auto-generated references panel */
.references-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
}

.reference-item {
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s ease;
    background: white;
}

.reference-item:hover {
    border-color: #0d6efd;
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.1);
}

.reference-number {
    min-width: 2rem;
    text-align: center;
    font-weight: 600;
}

.reference-title {
    color: #212529;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
}

.reference-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.credibility-score {
    font-weight: 500;
    color: #495057;
}

.citation-excerpt {
    font-style: italic;
    border-left: 3px solid #0d6efd;
    padding-left: 0.5rem;
    color: #495057;
    background: #f8f9fa;
    margin: 0.25rem 0;
}

/* Content areas with citations */
.narrative-content {
    line-height: 1.7;
    font-size: 0.95rem;
}

.narrative-content .citation-mark {
    margin: 0 0.05em;
}

/* Loading state for citation generation */
.citation-generating {
    position: relative;
}

.citation-generating::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0d6efd;
    border-radius: 50%;
    animation: citation-spin 1s linear infinite;
}

@keyframes citation-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Enhanced tooltip styling for citations */
.tooltip.citation-tooltip .tooltip-inner {
    max-width: 300px;
    text-align: left;
    background-color: #212529;
    color: #fff;
    font-size: 0.8rem;
    line-height: 1.4;
    border-radius: 6px;
}

.tooltip.citation-tooltip .tooltip-arrow::before {
    border-top-color: #212529;
}

/* Citation status indicators */
.citation-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-left: 0.5rem;
}

.citation-status-indicator.auto-generated {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.2);
}

.citation-status-indicator i {
    font-size: 0.7rem;
}

/* Responsive enhancements for automatic citations */
@media (max-width: 768px) {
    .citation-mark {
        font-size: 0.7em;
        padding: 0.05em 0.2em;
    }
    
    .reference-item {
        padding: 0.5rem;
    }
    
    .reference-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .references-list {
        max-height: 300px;
    }
}

@media (max-width: 576px) {
    .citation-mark {
        font-size: 0.65em;
    }
    
    .reference-item {
        padding: 0.375rem;
    }
    
    .reference-title {
        font-size: 0.85rem;
    }
    
    .citation-excerpt {
        font-size: 0.8rem;
        padding-left: 0.375rem;
        border-left-width: 2px;
    }
}