/* Stock News Assistant Styles */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #10b981;
    --background: #f9fafb;
    --surface: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --error-color: #ef4444;
    --success-color: #10b981;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Live ticker tape */
.ticker-tape {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #0f172a;
    color: #f1f5f9;
    overflow: hidden;
    border-bottom: 1px solid #1e293b;
    height: 36px;
    display: flex;
    align-items: center;
}

.ticker-track {
    display: flex;
    gap: 32px;
    width: max-content;
    padding-right: 32px;
    animation: ticker-scroll 90s linear infinite;
    will-change: transform;
}

.ticker-tape:hover .ticker-track {
    animation-play-state: paused;
}

@keyframes ticker-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

.ticker-item {
    display: inline-flex;
    gap: 8px;
    align-items: baseline;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.ticker-symbol {
    font-weight: 700;
    color: #f8fafc;
}

.ticker-price {
    color: #e2e8f0;
}

.ticker-change {
    font-size: 0.85rem;
}

.ticker-change.positive { color: #34d399; }
.ticker-change.negative { color: #f87171; }
.ticker-change.flat     { color: #94a3b8; }

.ticker-item.flash-up    { animation: flash-up 600ms ease-out; }
.ticker-item.flash-down  { animation: flash-down 600ms ease-out; }

@keyframes flash-up {
    0%   { background: rgba(52, 211, 153, 0.35); }
    100% { background: transparent; }
}

@keyframes flash-down {
    0%   { background: rgba(248, 113, 113, 0.35); }
    100% { background: transparent; }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Configuration Section */
.config-section {
    background: var(--surface);
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    cursor: pointer;
    user-select: none;
}

.config-header h3 {
    font-size: 1.2rem;
    margin: 0;
    color: var(--text-primary);
}

.toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: transform 0.3s ease, color 0.2s;
}

.toggle-btn:hover {
    color: var(--text-primary);
}

.toggle-btn svg {
    transition: transform 0.3s ease;
}

.config-header.expanded .toggle-btn svg {
    transform: rotate(180deg);
}

.config-content {
    padding: 0 20px 20px 20px;
    transition: all 0.3s ease;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.config-item label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.config-item input,
.config-item select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.config-item input:focus,
.config-item select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Quick Sentiment Section */
.quick-sentiment-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.quick-sentiment-section h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.sentiment-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.sentiment-input-group input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.sentiment-input-group input[type="date"] {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.sentiment-input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.primary-btn {
    padding: 10px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* Examples Section */
.examples-section {
    margin-bottom: 20px;
}

.examples-section h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.date-toggle {
    display: inline-flex;
    gap: 0;
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 3px;
}

.date-toggle-btn {
    padding: 6px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.date-toggle-btn:hover {
    color: var(--text-primary);
}

.date-toggle-btn.active {
    background: var(--primary-color);
    color: white;
}

.example-btn {
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    white-space: nowrap;
}

.example-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* Chat Container */
.chat-container {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    min-height: 400px;
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.welcome-message h2 {
    color: var(--text-primary);
    margin-bottom: 10px;
}

.welcome-message p {
    margin-bottom: 20px;
}

.available-tools {
    background: var(--background);
    border-radius: 8px;
    padding: 20px;
    text-align: left;
    max-width: 600px;
    margin: 0 auto;
}

.available-tools h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
}

.available-tools ul {
    list-style: none;
}

.available-tools li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.available-tools li:last-child {
    border-bottom: none;
}

/* Sentiment Legend */
.sentiment-legend {
    background: var(--background);
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
}

.sentiment-legend h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.legend-items {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Messages */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.user-message .avatar {
    background: var(--primary-color);
    color: white;
}

.assistant-message .avatar {
    background: var(--secondary-color);
    color: white;
}

.system-message .avatar {
    background: var(--error-color);
    color: white;
}

.tool-message .avatar {
    background: #8b5cf6;
    color: white;
}

/* Collapsible tool messages */
.tool-collapsible {
    cursor: pointer;
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-weight: 500;
    color: var(--text-secondary);
}

.tool-header:hover {
    color: var(--text-primary);
}

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

.tool-collapsible.expanded .tool-toggle {
    transform: rotate(90deg);
}

.tool-label {
    font-size: 13px;
    font-weight: 500;
}

.tool-summary {
    font-family: monospace;
    font-size: 12px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

.tool-content {
    display: none;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.tool-collapsible.expanded .tool-content {
    display: block;
}

.tool-content pre {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
    max-height: 300px;
    overflow-y: auto;
}

/* Collapsible user messages */
.user-collapsible {
    cursor: pointer;
}

.user-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.user-header:hover {
    opacity: 0.85;
}

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

.user-collapsible.expanded .user-toggle {
    transform: rotate(90deg);
}

.user-label {
    font-weight: 500;
    font-size: 13px;
    opacity: 0.9;
}

.user-summary {
    font-size: 12px;
    opacity: 0.65;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.user-collapsible.expanded .user-summary {
    display: none;
}

.user-content {
    display: none;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.user-collapsible.expanded .user-content {
    display: block;
}

.user-content pre {
    margin: 0;
    font-size: 14px;
    max-height: 300px;
    overflow-y: auto;
    color: inherit;
}

.message-content {
    flex: 1;
    padding: 12px 16px;
    background: var(--background);
    border-radius: 8px;
    line-height: 1.6;
}

.user-message .message-content {
    background: var(--primary-color);
    color: white;
}

/* Markdown Styles */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 16px 0 8px 0;
    font-weight: 600;
}

.message-content h1 { font-size: 1.5rem; }
.message-content h2 { font-size: 1.3rem; }
.message-content h3 { font-size: 1.1rem; }

.message-content p {
    margin-bottom: 8px;
}

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-content li {
    margin-bottom: 4px;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

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

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

.message-content a {
    color: #3b82f6;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.message-content a:hover {
    border-bottom-color: #3b82f6;
}

.message-content hr {
    margin: 16px 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

/* Table Styles */
.message-content table,
.markdown-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
}

.message-content th,
.message-content td,
.markdown-table th,
.markdown-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.message-content th,
.markdown-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-primary);
}

.message-content tr:last-child td,
.markdown-table tr:last-child td {
    border-bottom: none;
}

.message-content tr:hover,
.markdown-table tr:hover {
    background: rgba(59, 130, 246, 0.05);
}

/* Better list styling */
.message-content ul {
    list-style-type: disc;
}

.message-content ol {
    list-style-type: decimal;
}

.message-content li {
    margin-bottom: 8px;
    line-height: 1.6;
}

/* Nested lists */
.message-content li ul,
.message-content li ol {
    margin-top: 8px;
    margin-bottom: 0;
}

/* Headers spacing */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    margin: 20px 0 12px 0;
    font-weight: 600;
    color: var(--text-primary);
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child,
.message-content h4:first-child {
    margin-top: 0;
}

.message-content h4 { 
    font-size: 1rem;
}

/* Math equations */
.math-display {
    margin: 16px 0;
    text-align: center;
    overflow-x: auto;
    padding: 8px;
}

.math-inline {
    display: inline-block;
    margin: 0 2px;
}

.katex {
    font-size: 1.1em;
}

.katex-display {
    margin: 0;
}

/* Loading Animation */
.loading {
    color: var(--text-secondary);
    font-style: italic;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Input Section */
.input-section {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#userInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 50px;
    transition: border-color 0.2s;
}

#userInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

#sendBtn {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

#sendBtn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

#sendBtn:active {
    transform: translateY(0);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    padding: 24px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
}

.modal-content p {
    margin-bottom: 20px;
    color: var(--text-secondary);
    white-space: pre-wrap;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    background: var(--background);
    padding: 12px;
    border-radius: 6px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.approve-btn,
.deny-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.approve-btn {
    background: var(--success-color);
    color: white;
}

.approve-btn:hover {
    background: #059669;
}

.deny-btn {
    background: var(--error-color);
    color: white;
}

.deny-btn:hover {
    background: #dc2626;
}

/* Scrollbar */
.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .examples-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }
    
    .chat-container {
        max-height: 400px;
    }
}