/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Georgia', 'Times New Roman', Times, serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 0;
    color: #000;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: #fff;
    min-height: 100vh;
}

/* Header - WSJ Style Masthead */
header {
    background: #fff;
    border-bottom: 4px solid #000;
    padding: 30px 40px 20px;
    margin-bottom: 0;
    text-align: center; /* Center the header */
    position: relative; /* For absolute positioning of toggle */
}

.dark-mode-toggle {
    position: absolute;
    top: 30px;
    right: 40px;
    width: 60px;
    height: 30px;
    background: #e0e0e0;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
    z-index: 10;
}

.dark-mode-toggle::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    left: 3px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.dark-mode-toggle i {
    position: absolute;
    font-size: 0.9em;
    top: 50%;
    transform: translateY(-50%);
    transition: all 0.3s ease;
}

.dark-mode-toggle .fa-moon {
    right: 8px;
    color: #666;
}

.dark-mode-toggle .fa-sun {
    left: 8px;
    color: #fdb813;
    opacity: 0;
}

/* Dark mode active state */
body.dark-mode .dark-mode-toggle {
    background: #4a4a4a;
}

body.dark-mode .dark-mode-toggle::before {
    left: 33px; /* Slide to right */
    background: #fff;
}

body.dark-mode .dark-mode-toggle .fa-moon {
    opacity: 0;
}

body.dark-mode .dark-mode-toggle .fa-sun {
    opacity: 1;
}

.dark-mode-toggle:hover {
    background: #d0d0d0;
}

body.dark-mode .dark-mode-toggle:hover {
    background: #5a5a5a;
}

header h1 {
    font-size: 2.8em;
    color: #000;
    margin-bottom: 5px;
    font-weight: 700;
    letter-spacing: -1px;
    font-family: 'Georgia', serif;
    text-transform: none;
}

header h1 i {
    display: inline; /* Show the eye icon */
    margin-right: 10px;
}

.subtitle {
    color: #666;
    font-size: 0.95em;
    font-style: italic;
    letter-spacing: 0;
    font-family: Georgia, serif;
    border-top: 1px solid #ddd;
    padding-top: 8px;
    margin-top: 8px;
    display: inline-block; /* Center the subtitle border */
}

/* Search Section */
.search-section {
    background: #f9f9f9;
    border-bottom: 1px solid #ddd;
    padding: 25px 40px;
    margin-bottom: 0;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    max-width: 800px;
}

#ticker-input {
    flex: 1;
    padding: 12px 15px;
    font-size: 1em;
    font-family: Georgia, serif;
    font-weight: 600;
    border: 2px solid #000;
    background: #fff;
    outline: none;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#ticker-input:focus {
    border-color: #0274b6;
    box-shadow: 0 0 0 2px rgba(2, 116, 182, 0.1);
}

#analyze-btn {
    padding: 12px 30px;
    background: #000;
    color: #fff;
    border: 2px solid #000;
    font-size: 0.95em;
    font-family: Georgia, serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
    text-transform: uppercase;
}

#analyze-btn:hover {
    background: #0274b6;
    border-color: #0274b6;
}

#analyze-btn:active {
    transform: scale(0.98);
}

/* Popular Stocks */
.popular-stocks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.popular-label {
    color: #666;
    font-weight: 700;
    margin-right: 5px;
    font-size: 0.9em;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.stock-tag {
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #000;
    cursor: pointer;
    font-weight: 700;
    font-family: Georgia, serif;
    color: #000;
    transition: all 0.2s;
    letter-spacing: 1px;
    font-size: 0.85em;
}

.stock-tag:hover {
    background: #000;
    color: #fff;
}

/* Popular Commodities */
.popular-commodities {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.commodity-tag {
    padding: 6px 12px;
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    border: 1px solid #f39c12;
    cursor: pointer;
    font-weight: 700;
    font-family: Georgia, serif;
    color: #fff;
    transition: all 0.2s;
    letter-spacing: 0.5px;
    font-size: 0.85em;
    box-shadow: 0 2px 4px rgba(243, 156, 18, 0.2);
}

.commodity-tag:hover {
    background: linear-gradient(135deg, #fda085 0%, #f6d365 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(243, 156, 18, 0.3);
}

/* Individual commodity colors */
.commodity-tag:nth-child(2) {
    /* Gold - keep default golden gradient */
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    border-color: #f39c12;
}

.commodity-tag:nth-child(3) {
    /* Silver - shiny silver gradient */
    background: linear-gradient(135deg, #e8e8e8 0%, #c0c0c0 100%);
    border-color: #a8a8a8;
    color: #333;
    box-shadow: 0 2px 4px rgba(192, 192, 192, 0.3);
}

.commodity-tag:nth-child(3):hover {
    background: linear-gradient(135deg, #f5f5f5 0%, #d3d3d3 100%);
    box-shadow: 0 4px 8px rgba(192, 192, 192, 0.5);
}

.commodity-tag:nth-child(4) {
    /* Oil - black with white text */
    background: #1a1a1a;
    border-color: #000;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.commodity-tag:nth-child(4):hover {
    background: #000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6);
}

.commodity-tag:nth-child(5) {
    /* Natural Gas - gassy green */
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    border-color: #4a9928;
    color: #fff;
    box-shadow: 0 2px 4px rgba(86, 171, 47, 0.3);
}

.commodity-tag:nth-child(5):hover {
    background: linear-gradient(135deg, #4a9928 0%, #7cb342 100%);
    box-shadow: 0 4px 8px rgba(86, 171, 47, 0.5);
}

.commodity-tag:nth-child(6) {
    /* Bitcoin - orange crypto */
    background: linear-gradient(135deg, #f7931a 0%, #ffb347 100%);
    border-color: #f7931a;
    color: #fff;
    box-shadow: 0 2px 4px rgba(247, 147, 26, 0.3);
}

.commodity-tag:nth-child(6):hover {
    background: linear-gradient(135deg, #e68a00 0%, #f7931a 100%);
    box-shadow: 0 4px 8px rgba(247, 147, 26, 0.5);
}

.commodity-tag:nth-child(7) {
    /* Ethereum - purple crypto */
    background: linear-gradient(135deg, #627eea 0%, #8a9ff5 100%);
    border-color: #627eea;
    color: #fff;
    box-shadow: 0 2px 4px rgba(98, 126, 234, 0.3);
}

.commodity-tag:nth-child(7):hover {
    background: linear-gradient(135deg, #5469d4 0%, #627eea 100%);
    box-shadow: 0 4px 8px rgba(98, 126, 234, 0.5);
}

.popular-commodities .popular-label i {
    margin-right: 5px;
    color: #f39c12;
}

/* Loading Indicator */
.loading {
    background: #fff;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    padding: 60px 40px;
    text-align: center;
}

.loading p {
    font-size: 1.2em;
    font-weight: 600;
    margin: 0 auto 30px auto;
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #f0f0f0;
    border-top: 3px solid #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px auto;
    display: block;
}

.loading small {
    display: block;
    margin: 0 auto;
    text-align: center;
    font-style: italic;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes wave {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 1;
    }
    30% {
        transform: translateY(-8px);
        opacity: 0.7;
    }
}

.loading-dots {
    display: inline-block;
}

.loading-dots span {
    display: inline-block;
    animation: wave 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.loading p {
    font-size: 1.1em;
    color: #000;
    margin-bottom: 8px;
    font-weight: 700;
    font-family: Georgia, serif;
}

.loading small {
    color: #666;
    font-size: 0.95em;
    font-style: italic;
}

/* Error Message */
.error-message {
    background: #fff5f5;
    border-left: 4px solid #d32f2f;
    border-top: 1px solid #ffcdd2;
    border-bottom: 1px solid #ffcdd2;
    padding: 20px 40px;
    color: #b71c1c;
    margin-bottom: 0;
    text-align: left;
    font-size: 1em;
    font-weight: 600;
}

/* Top Stocks Section */
.top-stocks-section {
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 30px 40px;
    margin-bottom: 0;
}

.section-title {
    color: #000;
    font-size: 1.4em;
    margin-bottom: 20px;
    font-weight: 700;
    font-family: Georgia, serif;
    letter-spacing: -0.3px;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
}

.top-stocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

/* Force 3 columns on larger screens for cleaner 18-stock layout */
@media (min-width: 1200px) {
    .top-stocks-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 2 columns on tablets */
@media (min-width: 768px) and (max-width: 1199px) {
    .top-stocks-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 1 column on mobile */
@media (max-width: 767px) {
    .top-stocks-grid {
        grid-template-columns: 1fr;
    }
}

.stock-card {
    background: #f5f6f7; /* Lighter grey - closer to white */
    border: 1px solid #e0e3e6;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* Soft, appealing shadow */
}

.stock-card:hover {
    background: #fafbfc; /* Very light grey on hover */
    border-color: #1a2332;
    box-shadow: 0 8px 20px rgba(26, 35, 50, 0.25);
    transform: translateY(-8px) scale(1.02); /* Pop out effect */
}

.stock-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.stock-card-info h3 {
    font-size: 1.2em;
    font-weight: 700;
    color: #000;
    margin-bottom: 3px;
    font-family: Georgia, serif;
}

.stock-card-info .stock-symbol {
    font-size: 0.85em;
    color: #666;
    font-weight: 600;
    letter-spacing: 1px;
}

.stock-card-price {
    text-align: right;
}

.stock-price {
    font-size: 1.3em;
    font-weight: 700;
    color: #000;
    font-family: Georgia, serif;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15); /* Subtle shadow for depth */
}

.stock-change {
    font-size: 0.9em;
    font-weight: 600;
    margin-top: 2px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); /* Lighter shadow */
}

.stock-change.positive {
    color: #2e7d32;
    text-shadow: 0 1px 3px rgba(46, 125, 50, 0.3); /* Green-tinted shadow */
}

.stock-change.negative {
    color: #c62828;
    text-shadow: 0 1px 3px rgba(198, 40, 40, 0.3); /* Red-tinted shadow */
}

.stock-chart-mini {
    width: 100%;
    height: 90px;
    margin-top: 10px;
    border-top: 1px solid #ddd;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a2332;
    border-radius: 4px;
}

.stock-chart-mini canvas {
    width: 100% !important;
    height: 100% !important;
}

.loading-stocks {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 40px;
    min-height: 200px;
}

.mini-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f0f0f0;
    border-top: 3px solid #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 0 20px 0;
}

.loading-stocks p {
    color: #666;
    font-size: 1em;
    font-style: italic;
    margin: 0;
}

.stock-card-loading {
    background: #f9f9f9;
    border: 1px solid #ddd;
    padding: 15px;
    text-align: center;
    color: #999;
    font-size: 0.9em;
}

/* Company Header */
.company-header {
    background: #fff;
    border-bottom: 3px double #000;
    padding: 30px 40px;
    margin-bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.company-info h2 {
    color: #000;
    font-size: 2.2em;
    margin-bottom: 8px;
    font-weight: 700;
    font-family: Georgia, serif;
    letter-spacing: -0.5px;
}

.ticker-badge {
    display: inline-block;
    padding: 4px 10px;
    background: #000;
    color: #fff;
    font-weight: 700;
    font-size: 0.8em;
    letter-spacing: 1px;
    font-family: Georgia, serif;
}

.current-price {
    text-align: right;
}

.price-label {
    color: #666;
    font-size: 0.85em;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
    font-weight: 600;
    text-transform: uppercase;
    font-family: Georgia, serif;
}

.price-value {
    font-size: 2.8em;
    font-weight: 700;
    color: #000;
    font-family: Georgia, serif;
    letter-spacing: -1px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); /* Stronger shadow for big price */
}

.price-change {
    font-size: 1.2em;
    font-weight: 700;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); /* Shadow for price change */
    margin-top: 5px;
    font-family: Georgia, serif;
}

.price-change.positive {
    color: #2e7d32;
}

.price-change.negative {
    color: #c62828;
}

/* Section Containers */
.metrics-container,
.charts-container,
.analysis-container {
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 30px 40px;
    margin-bottom: 0;
}

.metrics-container h3,
.charts-container h3,
.analysis-container h3 {
    color: #000;
    font-size: 1.4em;
    margin-bottom: 20px;
    font-weight: 700;
    font-family: Georgia, serif;
    letter-spacing: -0.3px;
    text-transform: none;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
    display: block;
}

.metrics-container h3 i,
.charts-container h3 i,
.analysis-container h3 i {
    display: none; /* Hide icons for cleaner look */
}

/* AI Analysis Text Styling */
#ai-analysis {
    line-height: 1.8;
    color: #333;
    font-size: 1em;
}

#ai-analysis p {
    margin-bottom: 15px;
    text-indent: 2em; /* Indent first line of each paragraph */
}

#ai-analysis p:first-child {
    text-indent: 0; /* Don't indent TL;DR */
}

#ai-analysis strong {
    color: #000;
    font-weight: 700;
}

#ai-analysis em {
    font-style: italic;
    color: #2c3e50;
}

/* Ask AI Section */
.ask-ai-compact {
    padding: 15px 20px;
}

.ask-ai-prompt {
    margin: 0;
    color: #666;
    font-size: 0.95em;
}

.ask-ai-prompt a {
    color: #0274b6;
    font-weight: 600;
    text-decoration: none;
}

.ask-ai-prompt a:hover {
    text-decoration: underline;
}

.ask-ai-expanded {
    padding: 20px;
    overflow: hidden;
    box-sizing: border-box;
}

.ask-ai-expanded h3 {
    font-family: Georgia, serif;
    font-size: 1.3em;
    margin-bottom: 8px;
    color: #000;
}

.ask-ai-expanded h3 i {
    margin-right: 8px;
    color: #0274b6;
}

.ai-disclaimer {
    font-size: 0.85em;
    color: #666;
    margin: 0 0 15px 0;
    padding: 8px 12px;
    background: #f8f8f8;
    border-left: 3px solid #999;
    border-radius: 4px;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
}

/* Dark Mode - AI Disclaimer */
body.dark-mode .ai-disclaimer {
    background: rgba(255, 255, 255, 0.05);
    border-left-color: #666;
    color: #aaa;
}

/* Chat History */
.chat-history {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 15px;
    padding: 10px;
    background: #fafafa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.chat-history:empty {
    display: none;
}

.chat-message {
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease;
}

.chat-message:last-child {
    margin-bottom: 0;
}

.chat-message-user {
    text-align: right;
}

.chat-message-user .message-bubble {
    background: #0274b6;
    color: white;
    display: inline-block;
    padding: 10px 15px;
    border-radius: 18px 18px 4px 18px;
    max-width: 80%;
    text-align: left;
    word-wrap: break-word;
}

.chat-message-ai {
    text-align: left;
}

.chat-message-ai .message-bubble {
    background: white;
    color: #333;
    display: inline-block;
    padding: 15px;
    border-radius: 4px 18px 18px 18px;
    max-width: 85%;
    text-align: left;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.chat-message-ai .message-bubble ul {
    margin: 10px 0;
    padding-left: 20px;
}

.chat-message-ai .message-bubble li {
    margin: 8px 0;
    line-height: 1.6;
}

.chat-message-ai .message-bubble strong {
    color: #000;
}

.chat-message-ai .message-bubble em {
    font-style: italic;
    color: #555;
}

.chat-message-loading {
    text-align: left;
}

.chat-message-loading .message-bubble {
    background: white;
    color: #999;
    display: inline-block;
    padding: 10px 15px;
    border-radius: 4px 18px 18px 18px;
    border: 1px solid #e0e0e0;
    font-style: italic;
}

.message-timestamp {
    font-size: 0.75em;
    color: #999;
    margin-top: 4px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ask-ai-input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#ai-question-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 0.95em;
    resize: vertical;
    transition: border-color 0.2s ease;
}

#ai-question-input:focus {
    outline: none;
    border-color: #0274b6;
}

#ask-ai-button {
    padding: 12px 24px;
    background: #0274b6;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
    align-self: flex-end;
}

#ask-ai-button:hover {
    background: #025a8f;
}

#ask-ai-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#ask-ai-button i {
    margin-right: 5px;
}

.collapse-ask-ai {
    background: none;
    border: 1px solid #ddd;
    padding: 8px 16px;
    border-radius: 4px;
    color: #666;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s ease;
    width: 100%;
}

.collapse-ask-ai:hover {
    background: #f5f5f5;
    border-color: #bbb;
}

.collapse-ask-ai i {
    margin-right: 5px;
}

/* Chart Time Period Controls */
.chart-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.time-period-btn {
    background: #fff;
    border: 1px solid #ddd;
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: 600;
    font-family: Georgia, serif;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.time-period-btn:hover {
    background: #f5f5f5;
    border-color: #999;
    color: #000;
}

.time-period-btn.active {
    background: #000;
    color: #fff;
    border-color: #000;
}

/* Metrics Grid - WSJ Data Table Style */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border: 1px solid #ddd;
    margin-top: 20px;
}

.metric-item {
    padding: 15px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    border-right: 1px solid #ddd;
    transition: all 0.3s ease;
}

.metric-item:hover {
    background: #fff;
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    z-index: 10;
    position: relative;
}

.metric-item:nth-child(4n) {
    border-right: none;
}

.metric-item:nth-last-child(-n+4) {
    border-bottom: none;
}

.metric-label {
    color: #666;
    font-size: 0.8em;
    margin-bottom: 6px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: Georgia, serif;
}

.metric-value {
    color: #000;
    font-size: 1.3em;
    font-weight: 700;
    font-family: Georgia, serif;
}

/* Charts */
#chart-image {
    width: 100%;
    border: 1px solid #ddd;
    margin-top: 20px;
}

/* Analysis Content - Article Style */
.analysis-content {
    line-height: 1.8;
    color: #000;
    white-space: pre-wrap;
    font-size: 1.05em;
    margin-top: 20px;
    font-family: Georgia, serif;
    text-align: justify;
    column-count: 1;
}

.analysis-content::first-letter {
    font-size: 3em;
    font-weight: 700;
    float: left;
    line-height: 0.9;
    margin: 5px 8px 0 0;
    color: #000;
}

.analysis-content h4 {
    color: #000;
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 700;
    font-size: 1.2em;
    font-family: Georgia, serif;
}

/* Footer - WSJ Style */
footer {
    background: #f9f9f9;
    border-top: 3px double #000;
    padding: 20px 40px;
    text-align: center;
    color: #666;
    font-size: 0.85em;
}

footer p {
    text-align: center;
    margin: 0 auto;
}

footer i {
    color: #000;
    margin-right: 5px;
}

footer strong {
    color: #000;
    font-weight: 700;
}

/* Responsive Design */
@media (max-width: 768px) {
    header,
    .search-section,
    .company-header,
    .metrics-container,
    .charts-container,
    .analysis-container,
    footer {
        padding: 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .search-box {
        flex-direction: column;
    }

    .company-header {
        flex-direction: column;
        text-align: center;
    }

    .current-price {
        text-align: center;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .metric-item:nth-child(4n) {
        border-right: 1px solid #ddd;
    }

    .metric-item:nth-child(2n) {
        border-right: none;
    }

    .metric-item:nth-last-child(-n+4) {
        border-bottom: 1px solid #ddd;
    }

    .metric-item:nth-last-child(-n+2) {
        border-bottom: none;
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .metric-item {
        border-right: none;
    }

    .metric-item:nth-child(2n) {
        border-right: none;
    }

    .metric-item:last-child {
        border-bottom: none;
    }

    .analysis-content {
        column-count: 1;
    }
}

/* Print Styles - Very WSJ */
@media print {
    body {
        background: #fff;
    }

    .search-section,
    footer {
        display: none;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#results > * {
    animation: fadeIn 0.6s ease-out;
}

/* WSJ Blue Link Color */
a {
    color: #0274b6;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Dotted separators (WSJ style) */
.search-section::after {
    content: '';
    display: block;
    margin-top: 15px;
    border-bottom: 1px dotted #ccc;
}

/* Info Button - Inline with text */
.info-button-inline {
    background: none;
    border: none;
    color: #666;
    font-size: 0.85em;
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
    transition: color 0.2s ease;
    vertical-align: middle;
    position: relative;
    top: -2px;
}

.info-button-inline:hover {
    color: #000;
}

.info-button-inline i {
    display: inline !important;
}

/* Section Subtitles */
.section-subtitle {
    color: #666;
    font-size: 0.95em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 15px 0;
    font-family: Georgia, serif;
}

.ratios-section {
    margin-bottom: 30px;
}

.market-data-section {
    margin-bottom: 0;
}

/* Ratio Item with Dropdown */
.ratio-item {
    position: relative;
    cursor: pointer;
}

.ratio-header {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.ratio-header:hover {
    background-color: #f5f5f5;
}

body.dark-mode .ratio-header:hover {
    background-color: #2a2a2a;
}

.ratio-toggle {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
    color: #666;
    transition: transform 0.3s ease;
}

body.dark-mode .ratio-toggle {
    color: #aaa;
}

.ratio-item.expanded .ratio-toggle {
    transform: translateY(-50%) rotate(180deg);
}

.ratio-analysis {
    display: none;
    padding: 15px;
    background-color: #f9f9f9;
    border-top: 1px solid #ddd;
    font-size: 0.9em;
    line-height: 1.6;
    color: #333;
}

.ratio-analysis.visible {
    display: block;
    animation: slideDown 0.3s ease;
}

.ratio-analysis-loading {
    text-align: center;
    color: #999;
    font-style: italic;
}

.ratio-comparison {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.ratio-comparison strong {
    color: #000;
}

.score-indicator {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: 600;
    margin-left: 5px;
}

.score-good {
    background-color: #d4edda;
    color: #155724;
}

.score-neutral {
    background-color: #fff3cd;
    color: #856404;
}

.score-poor {
    background-color: #f8d7da;
    color: #721c24;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #888;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 8px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    background: #000;
    color: #fff;
    padding: 20px 30px;
    margin: 0;
    font-family: Georgia, serif;
    font-size: 1.5em;
    border-radius: 8px 8px 0 0;
}

.modal-close {
    color: #fff;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 20px;
    cursor: pointer;
}

.modal-close:hover {
    opacity: 0.7;
}

.metrics-guide {
    padding: 30px;
}

.metric-explanation {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.metric-explanation:last-child {
    border-bottom: none;
}

.metric-explanation h4 {
    color: #000;
    font-family: Georgia, serif;
    font-size: 1.1em;
    margin-bottom: 8px;
    font-weight: 700;
}

.metric-explanation p {
    color: #333;
    line-height: 1.6;
    margin: 0;
    font-size: 0.95em;
}

/* Mobile responsive for modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10% auto;
        max-height: 85vh;
    }
    
    .modal-content h2 {
        padding: 15px 20px;
        font-size: 1.3em;
    }
    
    .metrics-guide {
        padding: 20px;
    }
    
    .metric-explanation h4 {
        font-size: 1em;
    }
    
    .metric-explanation p {
        font-size: 0.9em;
    }
}

/* Dark Mode Styles */
body.dark-mode {
    background: #1a1a1a;
    color: #e0e0e0;
}

body.dark-mode header {
    background: #2a2a2a;
    border-bottom-color: #444;
}

body.dark-mode header h1 {
    color: #fff;
}

body.dark-mode .subtitle {
    color: #aaa;
    border-top-color: #444;
}

body.dark-mode .dark-mode-toggle {
    background: #2a2a2a;
    border-color: #666;
    color: #fff;
}

body.dark-mode .dark-mode-toggle:hover {
    background: #444;
    border-color: #888;
}

body.dark-mode .search-section {
    background: #2a2a2a;
    border-bottom-color: #444;
}

body.dark-mode #ticker-input {
    background: #1a1a1a;
    border-color: #444;
    color: #fff;
}

body.dark-mode #analyze-btn {
    background: #fff;
    color: #000;
}

body.dark-mode #analyze-btn:hover {
    background: #000;
    color: #fff;
    border-color: #fff;
}

body.dark-mode .stock-tag {
    background: #2a2a2a;
    border-color: #666;
    color: #fff;
}

body.dark-mode .stock-tag:hover {
    background: #fff;
    color: #000;
}

body.dark-mode .loading {
    background: #2a2a2a;
    border-color: #444;
    color: #fff !important; /* Force white text */
}

body.dark-mode .loading p,
body.dark-mode .loading small,
body.dark-mode #loading-message {
    color: #fff !important; /* Force white text for all loading text */
}

body.dark-mode .spinner {
    border-color: #444;
    border-top-color: #fff; /* White spinner */
}

body.dark-mode #results {
    background: #2a2a2a;
}

body.dark-mode .company-header {
    background: #1a1a1a;
    border-bottom-color: #444;
    color: #fff;
}

body.dark-mode .company-header h1 {
    color: #fff !important; /* Force white company name */
}

body.dark-mode .company-info h2 {
    color: #fff !important; /* Force white company title */
}

body.dark-mode .company-header .ticker-badge {
    background: #fff !important; /* White badge */
    color: #000 !important; /* Black text */
    border-color: #fff;
}

body.dark-mode .price-info {
    color: #fff;
}

body.dark-mode .current-price-label {
    color: #aaa;
}

body.dark-mode .current-price {
    color: #fff;
}

body.dark-mode .tldr-section {
    background: #2a2a2a; /* Dark background */
    border-color: #444;
    color: #fff;
}

body.dark-mode .tldr-section h2 {
    color: #fff;
}

body.dark-mode .tldr-section p,
body.dark-mode .tldr-section strong,
body.dark-mode .tldr-section em {
    color: #fff !important;
}

body.dark-mode .metrics-grid {
    background: #2a2a2a; /* Grey background like popular stocks section */
}

body.dark-mode .metric-item {
    background: #1a1a1a !important; /* Black tiles like stock cards */
    border-color: #444;
    transform: translateY(0);
    transition: all 0.3s ease;
}

body.dark-mode .metric-item:hover {
    background: #1a1a1a !important; /* Keep dark background */
    border-color: #666;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    transform: translateY(-8px) scale(1.02); /* Pop out effect like stock cards */
}

body.dark-mode .metric-label {
    color: #aaa; /* Light grey labels */
}

body.dark-mode .metric-value {
    color: #fff; /* White values */
}

body.dark-mode .analysis-section {
    background: #2a2a2a; /* Dark background */
    border-color: #444;
    color: #fff;
}

body.dark-mode .analysis-section h2,
body.dark-mode .analysis-section h3,
body.dark-mode .analysis-section h4 {
    color: #fff !important;
}

body.dark-mode .analysis-section p,
body.dark-mode .analysis-section li,
body.dark-mode .analysis-section strong,
body.dark-mode .analysis-section em {
    color: #fff !important;
}

body.dark-mode .analysis-section .section-title {
    color: #fff;
    border-bottom-color: #444;
}

body.dark-mode .error-message {
    background: #3a1a1a;
    border-color: #d32f2f;
    color: #ffcdd2;
}

body.dark-mode .ask-ai-container,
body.dark-mode .ask-ai-section {
    background: #2a2a2a !important;
    border-color: #444;
}

body.dark-mode .chat-history {
    background: #1a1a1a;
}

/* ========================================
   AI SECTION - GLASSMORPHISM FLOATING PANEL
   ======================================== */

/* Light Mode - Frosted Glass Effect */
.ask-ai-container,
.ask-ai-section {
    background: rgba(255, 255, 255, 0.7) !important; /* Semi-transparent white */
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid transparent;
    border-radius: 8px;
    margin: 20px 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.7)),
                      linear-gradient(135deg, #0284C7, #9333ea, #ec4899, #0284C7);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1),
                0 0 40px rgba(2, 132, 199, 0.1);
    position: relative;
    will-change: transform;
    overflow: hidden; /* Prevent content from extending outside */
}

/* Breathing only when collapsed */
.ask-ai-container.collapsed,
.ask-ai-section.collapsed {
    animation: breathingFloat 6s ease-in-out infinite !important;
}

@keyframes breathingFloat {
    0%, 100% { 
        transform: translateY(0px) scale(1);
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1),
                    0 0 40px rgba(2, 132, 199, 0.1);
    }
    50% { 
        transform: translateY(-5px) scale(1.005);
        box-shadow: 0 22px 55px rgba(0, 0, 0, 0.12),
                    0 0 50px rgba(2, 132, 199, 0.15);
    }
}

.ask-ai-container:hover,
.ask-ai-section:hover {
    background-image: linear-gradient(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.7)),
                      linear-gradient(135deg, #ec4899, #0284C7, #9333ea, #ec4899);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15),
                0 0 50px rgba(147, 51, 234, 0.2);
}

/* Header with Shimmer Effect */
.ask-ai-container h3,
.ask-ai-section h3 {
    background: linear-gradient(90deg, #0284C7 0%, #9333ea 50%, #0284C7 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite; /* Shimmer effect */
    margin: -30px -40px 20px -40px;
    padding: 20px 40px;
    position: relative;
}

@keyframes shimmer {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

/* Breathing Glow Animation */
.ask-ai-container::before,
.ask-ai-section::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, #0284C7, #9333ea, #ec4899);
    border-radius: inherit;
    z-index: -1;
    opacity: 0;
    animation: breathe 8s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: 0; filter: blur(20px); }
    50% { opacity: 0.3; filter: blur(25px); }
}

/* AI Spark Icon - Gradient */
.ask-ai-container h3 i,
.ask-ai-section h3 i {
    background: linear-gradient(135deg, #0284C7 0%, #9333ea 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-right: 8px;
    animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Light Mode Chat History */
.chat-history {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
}

/* Light Mode Bubbles */
.chat-message-user .message-bubble {
    background: linear-gradient(135deg, #0284C7 0%, #0369a1 100%) !important;
    color: #fff !important;
    box-shadow: 0 4px 15px rgba(2, 132, 199, 0.3);
}

.chat-message-ai .message-bubble {
    background: rgba(248, 250, 252, 0.9) !important;
    color: #000 !important;
    border: 1px solid rgba(226, 232, 240, 0.8);
    backdrop-filter: blur(8px);
}

/* Minimalist Expanding Input Box */
#ai-question-input {
    background: rgba(255, 255, 255, 0.8);
    border: none;
    border-bottom: 2px solid #E2E8F0;
    color: #000;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); /* Spring animation */
    padding: 10px 0;
}

#ai-question-input:focus {
    border-bottom-color: #0284C7;
    box-shadow: 0 8px 20px rgba(2, 132, 199, 0.15);
    transform: scaleY(1.1);
    outline: none;
}

/* Ask Button - Premium CTA */
.ask-ai-button,
button[onclick*="askAI"] {
    background: linear-gradient(135deg, #0284C7 0%, #0369a1 100%) !important;
    color: #fff !important;
    border: none;
    padding: 12px 24px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(2, 132, 199, 0.3);
    transition: all 0.3s ease;
}

.ask-ai-button:hover,
button[onclick*="askAI"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(2, 132, 199, 0.4);
}

/* Monospace for Financial Numbers */
.message-bubble code,
.message-bubble .financial-number {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.95em;
}

/* ========================================
   DARK MODE - NEON GLASSMORPHISM
   ======================================== */

body.dark-mode .ask-ai-container,
body.dark-mode .ask-ai-section {
    background: rgba(17, 24, 39, 0.6) !important;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    background-image: linear-gradient(rgba(17, 24, 39, 0.6), rgba(17, 24, 39, 0.6)),
                      linear-gradient(135deg, #00D4FF, #9333ea, #ec4899, #00D4FF);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5),
                0 0 60px rgba(0, 212, 255, 0.2);
    will-change: transform;
}

/* Breathing only when collapsed */
body.dark-mode .ask-ai-container.collapsed,
body.dark-mode .ask-ai-section.collapsed {
    animation: breathingFloatDark 6s ease-in-out infinite !important;
}

@keyframes breathingFloatDark {
    0%, 100% { 
        transform: translateY(0px) scale(1);
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5),
                    0 0 60px rgba(0, 212, 255, 0.2);
    }
    50% { 
        transform: translateY(-5px) scale(1.005);
        box-shadow: 0 22px 55px rgba(0, 0, 0, 0.55),
                    0 0 70px rgba(0, 212, 255, 0.25);
    }
}

body.dark-mode .ask-ai-container:hover,
body.dark-mode .ask-ai-section:hover {
    background-image: linear-gradient(rgba(17, 24, 39, 0.6), rgba(17, 24, 39, 0.6)),
                      linear-gradient(135deg, #ec4899, #00D4FF, #9333ea, #ec4899);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6),
                0 0 80px rgba(147, 51, 234, 0.3);
}

body.dark-mode .ask-ai-container h3,
body.dark-mode .ask-ai-section h3 {
    background: linear-gradient(90deg, #00D4FF 0%, #9333ea 50%, #00D4FF 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite;
    margin: -30px -40px 20px -40px;
    padding: 20px 40px;
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
}

body.dark-mode .ask-ai-container h3 i,
body.dark-mode .ask-ai-section h3 i {
    display: inline-block;
    margin-right: 8px;
}

body.dark-mode .chat-history {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.8) 0%, rgba(31, 41, 55, 0.8) 100%);
    backdrop-filter: blur(10px);
    box-shadow: inset 0 4px 15px rgba(0, 0, 0, 0.4);
}

body.dark-mode .chat-message-ai .message-bubble,
body.dark-mode .chat-message-user .message-bubble {
    background: rgba(17, 24, 39, 0.9) !important;
    color: #fff !important;
    border: 1px solid rgba(0, 212, 255, 0.2);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

body.dark-mode .chat-message-user .message-bubble {
    background: linear-gradient(135deg, #00D4FF 0%, #0284C7 100%) !important;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4);
}

body.dark-mode .chat-message-ai .message-bubble strong,
body.dark-mode .chat-message-user .message-bubble strong {
    color: #fff !important;
    font-weight: 700;
}

body.dark-mode .chat-message-ai .message-bubble em,
body.dark-mode .chat-message-user .message-bubble em {
    color: #fff !important;
}

body.dark-mode .message-bubble code,
body.dark-mode .message-bubble .financial-number {
    background: rgba(0, 212, 255, 0.1);
    color: #00D4FF;
    border: 1px solid rgba(0, 212, 255, 0.2);
}

/* Dark Mode Input */
body.dark-mode #ai-question-input {
    background: rgba(17, 24, 39, 0.8);
    border-bottom: 2px solid #374151;
    color: #fff;
}

body.dark-mode #ai-question-input:focus {
    border-bottom-color: #00D4FF;
    box-shadow: 0 8px 25px rgba(0, 212, 255, 0.3);
}

/* AI Thinking State - Animated Wave */
.ai-thinking-wave {
    display: flex;
    gap: 4px;
    padding: 15px;
    justify-content: center;
}

.ai-thinking-wave span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0284C7, #9333ea);
    animation: wave 1.4s ease-in-out infinite;
}

.ai-thinking-wave span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-thinking-wave span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes wave {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-15px) scale(1.3);
        opacity: 1;
    }
}

body.dark-mode .ai-thinking-wave span {
    background: linear-gradient(135deg, #00D4FF, #9333ea);
}

/* Particle Field Effect (Advanced) */
.ai-processing-particles {
    position: relative;
    height: 60px;
    overflow: hidden;
}

.ai-processing-particles::before,
.ai-processing-particles::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #0284C7;
    animation: particles 3s linear infinite;
}

.ai-processing-particles::after {
    background: #9333ea;
    animation-delay: 1.5s;
}

@keyframes particles {
    0% {
        transform: translate(0, 0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 0.5;
    }
    100% {
        transform: translate(100vw, -50px) scale(2);
        opacity: 0;
    }
}

/* Typewriter Effect for AI Response */
.message-typewriter {
    overflow: hidden;
    border-right: 2px solid #0284C7;
    white-space: nowrap;
    animation: typing 2s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: #0284C7; }
}

body.dark-mode .message-typewriter {
    border-right-color: #00D4FF;
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: #00D4FF; }
}

/* Interactive Input Focus - Vivid Cyan */
body.dark-mode #ai-question-input {
    background: #1a1a1a;
    border: 2px solid #4B5563; /* Dull grey default */
    color: #fff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

body.dark-mode #ai-question-input:focus {
    border-color: #00D4FF !important; /* Vivid cyan on focus */
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
    outline: none;
}

/* AI Thinking Animation */
.chat-message-loading {
    position: relative;
    overflow: hidden;
}

.chat-message-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(148, 163, 184, 0.2) 50%, 
        transparent 100%
    );
    animation: ghostLine 2s infinite;
}

@keyframes ghostLine {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Fix current price color in dark mode */
body.dark-mode .price-value,
body.dark-mode #current-price {
    color: #fff !important;
}

/* AI Analysis Text Dark Mode */
body.dark-mode #ai-analysis {
    color: #fff !important; /* White analysis text */
}

body.dark-mode #ai-analysis p {
    color: #fff !important;
}

body.dark-mode #ai-analysis strong {
    color: #fff !important; /* Bolded white */
    font-weight: 700;
}

body.dark-mode #ai-analysis em {
    color: #fff !important; /* Italic white */
}

body.dark-mode canvas {
    filter: brightness(0.9);
}

/* Dark Mode - Commodities Section */
body.dark-mode .popular-commodities {
    border-top-color: #444;
}

body.dark-mode .popular-label {
    color: #fff !important; /* White text for POPULAR and COMMODITIES labels */
}

body.dark-mode .popular-commodities .popular-label i {
    color: #f39c12;
}

body.dark-mode .commodity-tag {
    /* Keep commodity colors vibrant in dark mode */
    opacity: 0.9;
}

body.dark-mode .commodity-tag:hover {
    opacity: 1;
}

/* Ensure commodity-specific colors remain in dark mode */
body.dark-mode .commodity-tag:nth-child(3) {
    /* Silver - adjust for dark mode */
    background: linear-gradient(135deg, #d0d0d0 0%, #a8a8a8 100%);
    border-color: #888;
}

body.dark-mode .commodity-tag:nth-child(3):hover {
    background: linear-gradient(135deg, #e0e0e0 0%, #c0c0c0 100%);
}

/* Dark Mode - Stock Tag Buttons (AAPL, TSLA, etc.) */
body.dark-mode .stock-tag {
    background: #fff !important;
    border-color: #666;
    color: #000 !important; /* Black text on white background */
}

body.dark-mode .stock-tag:hover {
    background: #e0e0e0 !important;
    color: #000 !important;
    border-color: #888;
}

/* Dark Mode - Popular Stocks Section (Top 18) - Background */
body.dark-mode .top-stocks-section,
body.dark-mode #top-stocks-section {
    background: #2a2a2a !important; /* Grey background */
}

body.dark-mode .section-title {
    color: #fff; /* White title text */
    border-bottom-color: #fff !important; /* White underline */
}

/* Dark Mode - Stock Cards (Black tiles with white text) */
body.dark-mode .stock-card {
    background: #1a1a1a !important; /* Black tiles */
    border-color: #444;
    transform: translateY(0);
    transition: all 0.3s ease;
}

body.dark-mode .stock-card:hover {
    border-color: #666;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    transform: translateY(-8px) scale(1.02); /* Pop out effect */
}

body.dark-mode .stock-card-info h3 {
    color: #fff; /* White text */
}

body.dark-mode .stock-card-info .stock-symbol {
    color: #aaa; /* Light gray text */
}

body.dark-mode .stock-price {
    color: #fff; /* White price */
}

body.dark-mode .stock-change.positive {
    color: #4caf50; /* Bright green */
}

body.dark-mode .stock-change.negative {
    color: #f44336; /* Bright red */
}

body.dark-mode .stock-card canvas {
    filter: brightness(1.1); /* Slightly brighter charts */
}

body.dark-mode .loading-stocks,
body.dark-mode .stock-card-loading {
    color: #fff;
}

/* Dark Mode - Footer */
body.dark-mode footer {
    background: #1a1a1a;
    border-top-color: #444;
    color: #aaa;
}

body.dark-mode footer i {
    color: #fff;
}

body.dark-mode footer strong {
    color: #fff;
}

/* Dark Mode - Section Containers and Headers */
body.dark-mode .analysis-container,
body.dark-mode .metrics-container,
body.dark-mode .charts-container {
    background: #2a2a2a !important;
    color: #fff !important;
}

body.dark-mode .analysis-container h3,
body.dark-mode .metrics-container h3,
body.dark-mode .charts-container h3,
body.dark-mode .ask-ai-section h3 {
    color: #fff !important;
    border-bottom-color: #444 !important;
}

body.dark-mode .analysis-container h3 i,
body.dark-mode .metrics-container h3 i,
body.dark-mode .charts-container h3 i,
body.dark-mode .ask-ai-section h3 i {
    color: #fff;
}

/* ========================================
   NEWSPAPER TYPOGRAPHY & PROFESSIONAL STYLING
   ======================================== */

/* Masthead Date Line */
.masthead-date {
    font-size: 0.75em;
    color: #666;
    font-family: Georgia, serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 5px;
    font-style: normal;
    text-align: center;
}

body.dark-mode .masthead-date {
    color: #aaa;
}

/* Analysis Section - Professional Newspaper Style */
.analysis-container h3 {
    border-top: 4px solid #000 !important;
    border-bottom: 1px solid #000 !important;
    padding-top: 15px !important;
    padding-bottom: 15px !important;
    margin-top: 0 !important;
}

body.dark-mode .analysis-container h3 {
    border-top-color: #fff !important;
    border-bottom-color: #666 !important;
}

/* Justified Text for Analysis */
#ai-analysis {
    text-align: justify;
    hyphens: auto;
}

/* Drop Cap for TL;DR */
#ai-analysis p:first-child::first-letter {
    font-size: 3.5em;
    font-weight: 700;
    float: left;
    line-height: 0.8;
    margin: 5px 8px 0 0;
    font-family: Georgia, serif;
    color: #000;
}

body.dark-mode #ai-analysis p:first-child::first-letter {
    color: #fff !important; /* Match paragraph text color */
}

/* Monospace for Financial Numbers */
.metric-value,
.stock-price,
.financial-number,
#current-price {
    font-family: 'SF Mono', 'Monaco', 'Consolas', 'Courier New', monospace !important;
    letter-spacing: 0.5px;
}

/* Muted Professional Colors for Changes */
.stock-change.positive,
.price-change.positive {
    color: #2d5016 !important; /* Forest Green */
}

.stock-change.negative,
.price-change.negative {
    color: #8b1a1a !important; /* Brick Red */
}

body.dark-mode .stock-change.positive,
body.dark-mode .price-change.positive {
    color: #4ade80 !important; /* Brighter green for dark mode */
}

body.dark-mode .stock-change.negative,
body.dark-mode .price-change.negative {
    color: #f87171 !important; /* Brighter red for dark mode */
}

/* Financial Metrics - Increased Data Density */
.metric-item {
    padding: 12px 15px !important; /* Reduced from default */
}

/* Commodity Marquee Effect */
.popular-commodities {
    overflow: hidden;
    position: relative;
}

.commodities-scroll {
    display: inline-flex;
    animation: marquee 30s linear infinite;
    gap: 10px;
}

@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Dark Mode Toggle - Black Border */
.dark-mode-toggle {
    border: 2px solid #000 !important;
}

body.dark-mode .dark-mode-toggle {
    border: 2px solid #fff !important;
}

/* Less Distracting Breathing in Dark Mode */
body.dark-mode .ask-ai-container::before,
body.dark-mode .ask-ai-section::before {
    opacity: 0;
    animation: breatheDark 8s ease-in-out infinite;
}

@keyframes breatheDark {
    0%, 100% { opacity: 0; filter: blur(20px); }
    50% { opacity: 0.15; filter: blur(25px); } /* Reduced from 0.3 */
}

/* Floating Pill Input for Ask AI */
.ask-ai-input-container {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

#ai-question-input {
    border-radius: 25px !important; /* Pill shape */
    padding: 15px 20px !important;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

#ai-question-input:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

#ai-question-input:focus {
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.2);
    transform: translateY(-2px);
}

body.dark-mode #ai-question-input {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-mode #ai-question-input:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

body.dark-mode #ai-question-input:focus {
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.3);
}

#ask-ai-button {
    border-radius: 25px !important;
    padding: 15px 30px !important;
    white-space: nowrap;
}
/* ========================================
   AUTHENTIC NEWSPAPER TYPOGRAPHY
   ======================================== */

/* BASE TYPOGRAPHY */
body {
    font-family: Georgia, 'Times New Roman', serif;
    line-height: 1.3; /* Tighter for newspaper feel */
}

/* HEADLINES - WSJ Style with PT Serif */
h1, h2, h3, 
header h1,
.analysis-container h3,
.metrics-container h3,
.charts-container h3 {
    font-family: 'PT Serif', Georgia, serif !important;
    font-weight: 700;
    letter-spacing: -0.02em; /* Tight, authoritative */
}

/* Masthead Logo */
header h1 {
    font-size: 3.5em;
    font-weight: 700;
    letter-spacing: -2px;
}

/* Section Headers */
.analysis-container h3,
.metrics-container h3,
.charts-container h3,
.ask-ai-section h3 {
    font-size: 1.6em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* BODY TEXT - Georgia with tight line-height */
.analysis-content,
#ai-analysis,
.tldr-section,
p {
    font-family: Georgia, 'Times New Roman', serif;
    line-height: 1.3;
    text-align: justify;
}

/* FINANCIAL DATA - Roboto Mono for perfect alignment */
.metric-value,
.stock-price,
.financial-number,
#current-price,
.price-value,
.current-price,
.stock-change,
.price-change {
    font-family: 'Roboto Mono', 'SF Mono', 'Monaco', 'Consolas', monospace !important;
    font-weight: 500;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums; /* Perfect alignment */
}

/* UI Elements - Clean Sans-Serif */
button,
input,
textarea,
.popular-label,
.stock-tag,
.commodity-tag {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Masthead Subtitle - Small caps */
.subtitle {
    font-family: 'PT Serif', Georgia, serif;
    font-size: 0.95em;
    font-style: italic;
    letter-spacing: 0.5px;
}

/* Masthead Date Line - All caps */
.masthead-date {
    font-family: 'Roboto', sans-serif;
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 500;
}

/* Drop Cap Enhancement */
#ai-analysis p:first-child::first-letter {
    font-family: 'PT Serif', Georgia, serif;
    font-size: 4em;
    font-weight: 700;
    line-height: 0.75;
}

/* Times New Roman for Main Headers */
header h1,
.analysis-container h3,
.metrics-container h3,
.charts-container h3,
.section-title {
    font-family: 'Times New Roman', Times, serif !important;
}

/* Center Section Headers */
.analysis-container h3,
.metrics-container h3,
.charts-container h3 {
    text-align: center !important;
}

/* Network Error State for Popular Stocks */
.network-error {
    grid-column: 1 / -1; /* Span all grid columns */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 100px 20px;
    min-height: 400px;
    width: 100%;
    color: #666;
}

.network-error i {
    font-size: 5em;
    color: #ff5252;
    margin-bottom: 30px;
    display: block;
}

.network-error p {
    font-size: 2em;
    font-weight: 700;
    color: #ff5252;
    margin: 20px 0;
    display: block;
}

.network-error small {
    display: block;
    font-size: 1.1em;
    color: #999;
    margin-top: 15px;
    max-width: 500px;
    line-height: 1.5;
}

body.dark-mode .network-error {
    color: #aaa;
}

body.dark-mode .network-error i {
    color: #ff6b6b;
}

body.dark-mode .network-error p {
    color: #ff6b6b;
}

body.dark-mode .network-error small {
    color: #888;
}

/* Dark Mode Text Shadows for Numbers */
body.dark-mode .stock-price {
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); /* Stronger shadow in dark mode */
}

body.dark-mode .stock-change.positive {
    text-shadow: 0 1px 4px rgba(46, 125, 50, 0.5);
}

body.dark-mode .stock-change.negative {
    text-shadow: 0 1px 4px rgba(198, 40, 40, 0.5);
}

body.dark-mode .price-value {
    text-shadow: 0 3px 8px rgba(0, 0, 0, 0.5); /* Even stronger for main price */
}

body.dark-mode .price-change {
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

/* ========================================
   HEADLINE CONSENSUS SECTION
   ======================================== */

.headline-consensus-section {
    background: linear-gradient(135deg, #fefefe 0%, #f8f9fa 100%);
    border: 1px solid #e0e0e0;
    border-left: 4px solid #0274b6;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    font-family: Georgia, serif;
}

.headline-consensus-section p {
    margin: 0 0 15px 0;
    line-height: 1.6;
}

.headline-consensus-section .sentiment-bullish {
    color: #2d5016;
    background: rgba(45, 80, 22, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.headline-consensus-section .sentiment-bearish {
    color: #8b1a1a;
    background: rgba(139, 26, 26, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.headline-consensus-section .sentiment-neutral,
.headline-consensus-section .sentiment-mixed {
    color: #666;
    background: rgba(102, 102, 102, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.headline-themes {
    font-size: 0.9em;
    color: #555;
    margin-bottom: 15px;
    padding: 8px 12px;
    background: rgba(2, 116, 182, 0.05);
    border-radius: 4px;
}

.recent-headlines {
    margin-top: 15px;
}

.recent-headlines > strong {
    display: block;
    margin-bottom: 10px;
    font-size: 0.95em;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.headline-item {
    padding: 8px 12px;
    margin: 6px 0;
    background: #fff;
    border-radius: 4px;
    font-size: 0.9em;
    line-height: 1.5;
    border-left: 3px solid #ddd;
    transition: all 0.2s ease;
}

.headline-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.headline-item.bullish {
    border-left-color: #2d5016;
    background: rgba(45, 80, 22, 0.03);
}

.headline-item.bearish {
    border-left-color: #8b1a1a;
    background: rgba(139, 26, 26, 0.03);
}

.headline-item.neutral {
    border-left-color: #999;
}

.headline-item em {
    font-style: normal;
    color: #333;
}

.headline-source {
    font-size: 0.85em;
    color: #888;
    font-style: italic;
}

/* Dark Mode - Headline Consensus */
body.dark-mode .headline-consensus-section {
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
    border-color: #444;
    border-left-color: #00D4FF;
}

body.dark-mode .headline-consensus-section p {
    color: #e0e0e0;
}

body.dark-mode .headline-consensus-section .sentiment-bullish {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.15);
}

body.dark-mode .headline-consensus-section .sentiment-bearish {
    color: #f87171;
    background: rgba(248, 113, 113, 0.15);
}

body.dark-mode .headline-consensus-section .sentiment-neutral,
body.dark-mode .headline-consensus-section .sentiment-mixed {
    color: #aaa;
    background: rgba(170, 170, 170, 0.15);
}

body.dark-mode .headline-themes {
    color: #bbb;
    background: rgba(0, 212, 255, 0.1);
}

body.dark-mode .recent-headlines > strong {
    color: #ddd;
}

body.dark-mode .headline-item {
    background: #1a1a1a;
    border-left-color: #555;
}

body.dark-mode .headline-item:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .headline-item.bullish {
    border-left-color: #4ade80;
    background: rgba(74, 222, 128, 0.08);
}

body.dark-mode .headline-item.bearish {
    border-left-color: #f87171;
    background: rgba(248, 113, 113, 0.08);
}

body.dark-mode .headline-item.neutral {
    border-left-color: #666;
}

body.dark-mode .headline-item em {
    color: #e0e0e0;
}

body.dark-mode .headline-source {
    color: #888;
}

