/* Side Panel Overlay */
.side-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.side-panel-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Side Panel */
.side-panel {
    position: fixed;
    top: 0;
    right: -650px;
    width: 600px;
    height: 100%;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.side-panel.active {
    right: 0;
}

/* Side Panel Header */
.side-panel-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.side-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.side-panel-close {
    background: none;
    border: none;
    font-size: 24px;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.side-panel-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Side Panel Content */
.side-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

#portfolioTab .analysis-section {
    margin-bottom: 16px;
}

#portfolioTab .analysis-section h4 {
    margin: 0 0 10px 0;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}

#portfolioTab .metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

#portfolioTab .metric {
    background: #f9fafb;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

#portfolioTab .metric .label {
    display: block;
    font-size: 10px;
    color: #6b7280;
    margin-bottom: 3px;
}

#portfolioTab .metric .value {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
}

#portfolioTab .metric .value.text-success {
    color: #10b981;
}

#portfolioTab .metric .value.text-danger {
    color: #ef4444;
}

#portfolioTab .recommendation {
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
}

#portfolioTab .recommendation.buy {
    background: #d1fae5;
    color: #065f46;
}

#portfolioTab .recommendation.sell {
    background: #fee2e2;
    color: #991b1b;
}

#portfolioTab .recommendation.hold {
    background: #fef3c7;
    color: #92400e;
}

#portfolioTab .loading {
    text-align: center;
    padding: 30px;
    color: #6b7280;
    font-size: 14px;
}

#portfolioTab .error-message {
    padding: 16px;
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #991b1b;
    font-size: 14px;
}

/* Side Panel Footer */
.side-panel-footer {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
}

.side-panel-footer .btn-primary,
.side-panel-footer .btn-secondary {
    flex: 1;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.side-panel-footer .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.side-panel-footer .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.side-panel-footer .btn-secondary {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
}

.side-panel-footer .btn-secondary:hover {
    background: #f9fafb;
}

/* Dropdown */
#portfolioTab .dropdown {
    position: relative;
}

#portfolioTab .dropdown button {
    padding: 10px 16px;
    border-radius: 6px;
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    cursor: pointer;
    font-weight: 500;
}

#portfolioTab .dropdown-content {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    background: white;
    min-width: 120px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    margin-bottom: 4px;
    overflow: hidden;
}

#portfolioTab .dropdown:hover .dropdown-content {
    display: block;
}

#portfolioTab .dropdown-content a {
    display: block;
    padding: 10px 16px;
    color: #374151;
    text-decoration: none;
    transition: background 0.2s;
}

#portfolioTab .dropdown-content a:hover {
    background: #f9fafb;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .side-panel {
        width: 100%;
        right: -100%;
    }
}


/* Signal Badges */
.signal-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 6px;
}

.signal-badge.buy {
    background: #d1fae5;
    color: #065f46;
}

.signal-badge.sell {
    background: #fee2e2;
    color: #991b1b;
}

.signal-badge.neutral,
.signal-badge.hold {
    background: #f3f4f6;
    color: #6b7280;
}


/* Reopen Button (floating on right edge) */
.side-panel-reopen {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px 0 0 8px;
    padding: 12px 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 998;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 60px;
}

.side-panel-reopen:hover {
    right: 0;
    box-shadow: -4px 4px 15px rgba(102, 126, 234, 0.4);
    transform: translateY(-50%) scale(1.05);
}

/* AI Decision Summary */
.ai-decision-summary {
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    border-left: 4px solid;
}

.ai-decision-summary.success {
    background: #f0fdf4;
    border-color: #22c55e;
}

.ai-decision-summary.danger {
    background: #fef2f2;
    border-color: #ef4444;
}

.ai-decision-summary.neutral {
    background: #f9fafb;
    border-color: #6b7280;
}

.ai-decision-summary h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.decision-action {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 10px;
}

.ai-decision-summary.success .decision-action {
    color: #22c55e;
}

.ai-decision-summary.danger .decision-action {
    color: #ef4444;
}

.ai-decision-summary.neutral .decision-action {
    color: #6b7280;
}

.decision-details {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #6b7280;
}

.decision-reasoning {
    font-size: 13px;
    color: #374151;
    line-height: 1.5;
}

/* AI Agents Grid */
.ai-agents-grid {
    padding: 0 20px 20px 20px;
}

.ai-agents-grid h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

/* Agent Card */
.agent-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    transition: box-shadow 0.2s;
}

.agent-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.agent-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.agent-icon {
    font-size: 20px;
}

.agent-name {
    flex: 1;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
}

.signal-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.signal-badge.success,
.signal-badge.bullish {
    background: #dcfce7;
    color: #16a34a;
}

.signal-badge.danger,
.signal-badge.bearish {
    background: #fee2e2;
    color: #dc2626;
}

.signal-badge.neutral {
    background: #f3f4f6;
    color: #6b7280;
}

/* Confidence Bar */
.agent-confidence {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.confidence-bar {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.confidence-fill.success {
    background: #22c55e;
}

.confidence-fill.danger {
    background: #ef4444;
}

.confidence-fill.neutral {
    background: #6b7280;
}

.confidence-text {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    min-width: 40px;
    text-align: right;
}

/* Agent Reasoning */
.agent-reasoning-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-top: 10px;
    background: #f9fafb;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #6b7280;
    transition: background 0.2s;
}

.agent-reasoning-toggle:hover {
    background: #f3f4f6;
}

.toggle-icon {
    font-size: 10px;
    transition: transform 0.2s;
}

.agent-reasoning {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.5;
    margin-top: 10px;
    padding: 10px;
    background: #f9fafb;
    border-radius: 4px;
    max-height: 500px;
    overflow-y: auto;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.agent-reasoning.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.reasoning-category {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.reasoning-category:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.reasoning-text {
    padding: 10px;
    background: #f9fafb;
    border-radius: 4px;
    font-size: 12px;
    color: #374151;
    line-height: 1.6;
    white-space: pre-wrap;
}

.reasoning-details {
    padding: 8px;
    margin-top: 8px;
    background: #f3f4f6;
    border-radius: 4px;
    font-size: 11px;
    color: #4b5563;
    line-height: 1.5;
}

.reasoning-item {
    padding: 8px 0;
    font-size: 12px;
    color: #374151;
    line-height: 1.5;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.category-header strong {
    color: #374151;
    font-size: 13px;
}

.confidence-badge {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    background: #e5e7eb;
    color: #6b7280;
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}

.metric-container {
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.metric-container:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

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

.metric-container .metric-value {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 6px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.metric-container .metric-signal {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-container .metric-signal.buy {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.metric-container .metric-signal.sell {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
}

.metric-container .metric-signal.hold {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.metric-container .metric-signal.neutral {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    color: #374151;
}

.metric-container .metric-signal.distribution,
.metric-container .metric-signal.accumulation {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    background: white;
    border-radius: 3px;
    font-size: 11px;
}

.metric-label {
    color: #6b7280;
    font-weight: 500;
}

.metric-value {
    color: #374151;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.reasoning-list {
    margin: 0;
    padding-left: 20px;
}

.reasoning-list li {
    margin-bottom: 5px;
}

.reasoning-list strong {
    color: #374151;
}

/* Statistical Analysis Sections */
.analysis-summary {
    padding: 20px;
    margin-bottom: 15px;
    background: #f9fafb;
    border-radius: 8px;
}

.analysis-summary h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.recommendation-reason {
    margin-top: 10px;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.5;
}

.stat-section {
    margin-bottom: 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.stat-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #f9fafb;
    cursor: pointer;
    transition: background 0.2s;
}

.stat-section-header:hover {
    background: #f3f4f6;
}

.stat-section-title {
    font-weight: 600;
    font-size: 13px;
    color: #374151;
}

.stat-section-content {
    padding: 15px;
    background: white;
    max-height: 500px;
    overflow-y: auto;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

.stat-section-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0 15px;
    overflow: hidden;
}

.no-data {
    text-align: center;
    color: #9ca3af;
    font-size: 12px;
    padding: 10px;
}

/* Metric Details (Collapsible) */
.metric-container {
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.metric-container .metric {
    border: none;
    margin: 0;
}

.metric-container .metric:hover {
    background: #f9fafb;
}

.metric-details {
    padding: 10px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    font-size: 11px;
    max-height: 300px;
    overflow-y: auto;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.metric-details.collapsed {
    max-height: 0;
    padding: 0 10px;
    overflow: hidden;
}

.metric-full-width {
    grid-column: 1 / -1;
    padding: 10px;
    background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
    border-radius: 6px;
    margin-top: 8px;
    border-left: 3px solid #667eea;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    line-height: 1.5;
    font-size: 12px;
}

.metric-full-width strong {
    color: #667eea;
    font-weight: 600;
}

.detail-row {
    margin-bottom: 6px;
    line-height: 1.4;
    color: #374151;
    font-size: 11px;
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-row strong {
    color: #111827;
    font-weight: 600;
}


/* ========================================
   INVESTOR ANALYSIS REPORT STYLES
   ======================================== */

.investor-analysis-report {
    padding: 0;
}

.report-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    margin: -20px -20px 20px -20px;
}

.report-header h3 {
    margin: 0 0 5px 0;
    font-size: 1.5em;
}

.report-subtitle {
    margin: 0;
    opacity: 0.9;
    font-size: 0.9em;
}

/* Stock Summary Cards */
.stock-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stock-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stock-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.stock-symbol {
    font-weight: bold;
    font-size: 1.1em;
    color: #1f2937;
}

.stock-price {
    font-size: 1.2em;
    font-weight: bold;
    color: #10b981;
}

.stock-card-metrics {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stock-card-metrics .metric {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
}

.stock-card-metrics .metric-label {
    color: #6b7280;
}

.stock-card-metrics .metric-value {
    font-weight: 600;
    color: #1f2937;
}

/* Consensus Section */
.consensus-section {
    margin-bottom: 24px;
}

.consensus-section h4 {
    margin: 0 0 12px 0;
    color: #1f2937;
}

.consensus-table-wrapper {
    overflow-x: auto;
}

.consensus-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.consensus-table th {
    background: #f3f4f6;
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
}

.consensus-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e5e7eb;
}

.investor-name {
    font-weight: 500;
    color: #1f2937;
}

.signal-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.signal-icon {
    font-size: 1.1em;
}

.signal-text {
    font-weight: 500;
}

.signal-bullish .signal-text {
    color: #10b981;
}

.signal-bearish .signal-text {
    color: #ef4444;
}

.signal-neutral .signal-text {
    color: #6b7280;
}

.confidence-badge {
    background: #e5e7eb;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    color: #374151;
}

.consensus-row {
    background: #fef3c7;
    font-weight: 600;
}

.consensus-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9em;
}

.consensus-bullish {
    background: #d1fae5;
    color: #065f46;
}

.consensus-bearish {
    background: #fee2e2;
    color: #991b1b;
}

.consensus-mixed {
    background: #e5e7eb;
    color: #374151;
}

/* Detailed Analysis Section */
.detailed-analysis-section {
    margin-top: 24px;
}

.detailed-analysis-section h4 {
    margin: 0 0 12px 0;
    color: #1f2937;
}

.stock-detail-card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.stock-detail-header {
    background: #f9fafb;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.stock-detail-header:hover {
    background: #f3f4f6;
}

.expand-icon {
    transition: transform 0.3s;
    color: #6b7280;
}

.stock-detail-card.expanded .expand-icon {
    transform: rotate(90deg);
}

.stock-symbol-large {
    font-weight: bold;
    font-size: 1.1em;
    color: #1f2937;
}

.stock-price-large {
    margin-left: auto;
    font-size: 1.2em;
    font-weight: bold;
    color: #10b981;
}

.stock-detail-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.stock-detail-card.expanded .stock-detail-content {
    max-height: 2000px;
    padding: 16px;
}

/* Risk Metrics Section */
.risk-metrics-section {
    margin-bottom: 20px;
}

.risk-metrics-section h5 {
    margin: 0 0 12px 0;
    color: #374151;
    font-size: 1em;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.metric-item {
    background: #f9fafb;
    padding: 10px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-item .metric-label {
    font-size: 0.85em;
    color: #6b7280;
}

.metric-item .metric-value {
    font-size: 1.1em;
    font-weight: 600;
    color: #1f2937;
}

/* Investor Opinions Section */
.investor-opinions-section h5 {
    margin: 0 0 12px 0;
    color: #374151;
    font-size: 1em;
}

.investor-opinion {
    border-left: 4px solid #e5e7eb;
    padding: 12px;
    margin-bottom: 12px;
    background: #f9fafb;
    border-radius: 4px;
}

.investor-opinion.opinion-bullish {
    border-left-color: #10b981;
    background: #ecfdf5;
}

.investor-opinion.opinion-bearish {
    border-left-color: #ef4444;
    background: #fef2f2;
}

.investor-opinion.opinion-neutral {
    border-left-color: #6b7280;
    background: #f9fafb;
}

.opinion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.opinion-icon {
    font-size: 1.2em;
}

.opinion-investor {
    font-weight: 600;
    color: #1f2937;
}

.opinion-signal {
    font-size: 0.75em;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: #e5e7eb;
    color: #374151;
}

.opinion-confidence {
    margin-left: auto;
    font-weight: 600;
    color: #6b7280;
}

.opinion-reasoning {
    font-size: 0.9em;
    line-height: 1.5;
    color: #4b5563;
    font-style: italic;
}
