/* Custom styles for Finance AI Agent */

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Dark scrollbar for sidebar */
#sidebar ::-webkit-scrollbar-track {
    background: #1f2937;
}

#sidebar ::-webkit-scrollbar-thumb {
    background: #4b5563;
}

/* Message bubble styles */
.message-bubble {
    max-width: 85%;
}

.message-user {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.message-assistant {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    width: 100%;
    max-width: none;
}

/* Markdown content styling */
.markdown-content {
    line-height: 1.7;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

.markdown-content h1 { font-size: 1.5em; }
.markdown-content h2 { font-size: 1.3em; }
.markdown-content h3 { font-size: 1.1em; }

.markdown-content p {
    margin-bottom: 0.75em;
}

.markdown-content ul,
.markdown-content ol {
    margin-left: 1.5em;
    margin-bottom: 0.75em;
}

.markdown-content li {
    margin-bottom: 0.25em;
}

.markdown-content code {
    background: #f1f5f9;
    padding: 0.125em 0.375em;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Consolas', 'Monaco', monospace;
}

.markdown-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1em;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.75em 0;
}

.markdown-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.markdown-content blockquote {
    border-left: 4px solid #3b82f6;
    padding-left: 1em;
    margin: 0.75em 0;
    color: #64748b;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75em 0;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid #e2e8f0;
    padding: 0.5em 0.75em;
    text-align: left;
}

.markdown-content th {
    background: #f8fafc;
    font-weight: 600;
}

.markdown-content a {
    color: #3b82f6;
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

/* Chart container */
.chart-container-wrapper {
    width: 100%;
}

.chart-container {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.chart-container > div[id^="chart-"] {
    width: 100% !important;
    min-height: 200px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.chart-title {
    font-weight: 600;
    color: #1e293b;
}

.chart-actions {
    display: flex;
    gap: 8px;
}

.chart-btn {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-btn-primary {
    background: #3b82f6;
    color: white;
    border: none;
}

.chart-btn-primary:hover {
    background: #2563eb;
}

.chart-btn-secondary {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.chart-btn-secondary:hover {
    background: #e2e8f0;
}

/* News list */
.news-list {
    margin: 12px 0;
}

.news-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

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

.news-source {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.news-source-sina {
    background: #fee2e2;
    color: #dc2626;
}

.news-source-eastmoney {
    background: #fef3c7;
    color: #92400e;
}

.news-source-jinshi {
    background: #dbeafe;
    color: #1e40af;
}

.news-title {
    color: #1e293b;
    font-size: 14px;
}

.news-title:hover {
    color: #3b82f6;
}

.news-date {
    flex-shrink: 0;
    color: #94a3b8;
    font-size: 12px;
}

/* Status indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 8px;
    margin: 8px 0;
    font-size: 14px;
    color: #64748b;
}

.status-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Technical levels */
.tech-levels {
    display: flex;
    gap: 16px;
    margin: 12px 0;
    flex-wrap: wrap;
}

.tech-level {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: 14px;
}

.tech-level-support {
    border-left: 3px solid #22c55e;
}

.tech-level-resistance {
    border-left: 3px solid #ef4444;
}

.tech-level-label {
    color: #64748b;
}

.tech-level-value {
    font-weight: 600;
    color: #1e293b;
}

/* Session item in sidebar */
.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
}

.session-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.session-item.active {
    background: rgba(59, 130, 246, 0.2);
}

.session-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.session-item-delete {
    opacity: 0;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.session-item:hover .session-item-delete {
    opacity: 1;
}

.session-item-delete:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Session group header */
.session-group-header {
    padding: 8px 12px;
    font-size: 12px;
    color: #9ca3af;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Typing cursor */
.typing-cursor::after {
    content: '|';
    animation: blink 1s infinite;
    color: #3b82f6;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chart-container {
        padding: 12px;
        margin: 8px 0;
    }

    .chart-container > div[id^="chart-"] {
        height: 300px !important;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .chart-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .tech-levels {
        flex-direction: column;
        gap: 8px;
    }

    .message-bubble {
        max-width: 95%;
    }

    .message-assistant {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Input area mobile fix */
    #input-area {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        position: sticky;
        bottom: 0;
    }

    #message-input {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Add padding to chat area to prevent content being hidden */
    #chat-area {
        padding-bottom: 100px;
    }

    #messages {
        padding-bottom: 20px;
    }

    #welcome-screen {
        padding-bottom: 80px;
    }
}

/* Copy button */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.message-assistant:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: #e2e8f0;
}

/* Network status */
.offline-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: #ef4444;
    color: white;
    border-radius: 8px;
    font-size: 14px;
    z-index: 100;
    display: none;
}

body.offline .offline-indicator {
    display: block;
}

/* Chart empty placeholder */
.chart-empty-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin: 12px 0;
}

.chart-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.chart-empty-text {
    font-size: 16px;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 8px;
}

.chart-empty-hint {
    font-size: 13px;
    color: #94a3b8;
}

/* Safe area for mobile browsers */
.safe-area-bottom {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* Mobile input area fix */
#input-area {
    position: sticky;
    bottom: 0;
    z-index: 10;
}
