@font-face {
    font-family: 'Michroma';
    src: url('../fonts/Michroma-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Raleway';
    src: url('../fonts/Raleway-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Raleway';
    src: url('../fonts/Raleway-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'Raleway';
    src: url('../fonts/Raleway-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
}

@font-face {
    font-family: 'Raleway';
    src: url('../fonts/Raleway-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Raleway';
    src: url('../fonts/Raleway-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
}

:root {
    --primary-color: #132960;
    --secondary-color: #027DFC;
    --accent-color: #FF5713;
    --accent-hover: #AB582F;
    --bg-color: #E8E7E5;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-light: #7f8c8d;
    --sidebar-width: 250px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

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

body {
    font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', 'Raleway', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Michroma', sans-serif;
}

/* Layout Wrapper */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 2rem 0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.logo-area {
    padding: 0 2rem 2rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1rem;
}

.logo-area h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.sidebar-banner {
    margin: 1rem 1.25rem 0;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-banner-icon {
    flex: 0 0 auto;
    line-height: 0;
}

.sidebar-banner-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-banner:hover {
    background: rgba(255, 255, 255, 0.10);
}

.sidebar-banner-title {
    font-family: 'Raleway', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.2;
    display: block;
}

.sidebar-banner-sub {
    font-family: 'Raleway', sans-serif;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 0.25rem;
    display: block;
}

.nav-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 1rem 2rem;
    text-align: left;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    font-family: 'Raleway', sans-serif;
}

.nav-btn:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent-color);
}

/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: hidden; 
    background-color: rgba(0,0,0,0.6); 
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #fefefe;
    margin: 2% auto; 
    padding: 20px;
    border: 1px solid #888;
    width: 90%; 
    height: 90%;
    border-radius: 8px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.close-btn {
    color: #aaa;
    align-self: flex-end;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 10px;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#modal-body-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 4px;
}
.main-content {
    flex-grow: 1;
    overflow: visible;
    padding: 2rem;
    background-color: var(--bg-color);
}

.section-header {
    margin-bottom: 2rem;
    border-bottom: 2px solid #ddd;
    padding-bottom: 1rem;
}

.section-header h1 {
    font-size: 2rem;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Tab Content Visibility */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

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

/* News Layout (Panorama) */
.news-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Highlight News */
.news-highlight {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    min-height: 300px;
    position: relative;
    display: flex;
    flex-direction: column;
}

.highlight-content {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.highlight-tag {
    background-color: var(--accent-color);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    align-self: flex-start;
    margin-bottom: 1rem;
    text-transform: uppercase;
    font-weight: bold;
}

.highlight-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.highlight-summary {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 1.5rem;
}

/* Secondary News Grid */
.news-secondary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.news-card-small {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform 0.2s;
    border-top: 4px solid var(--secondary-color);
}

.news-card-small:hover {
    transform: translateY(-3px);
}

.small-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.small-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

/* Subscribe Box */
.subscribe-box {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: white;
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.subscribe-box h2 {
    margin-bottom: 0.5rem;
}

.subscribe-form {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.subscribe-form input {
    padding: 0.8rem;
    border-radius: 4px;
    border: none;
    width: 300px;
    font-size: 1rem;
}

.subscribe-form button {
    padding: 0.8rem 2rem;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.subscribe-form button:hover {
    background-color: var(--accent-hover);
}

/* Video Section */
.video-box {
    margin-bottom: 2rem;
}

.video-box h2 {
    margin-bottom: 1rem;
    color: var(--secondary-color);
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    background-color: #000;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}


.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Charts Grid (Reused) */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 1.5rem;
}

.chart-card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    min-height: 400px;
}

.full-width {
    grid-column: 1 / -1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.card-header h2 {
    font-size: 1.2rem;
    color: var(--secondary-color);
    text-align: left;
    flex: 1;
}

/* Market select styling */
.card-header select {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #fff;
    color: var(--text-color);
    font-size: 0.95rem;
}

.card-header button {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.08);
    background: var(--secondary-color);
    color: white;
    cursor: pointer;
    font-weight: 600;
}

.card-header button:hover {
    filter: brightness(0.92);
    transform: translateY(-1px);
}

.card-header label { font-size: 0.9rem; color: var(--text-light); }

.card-header-stacked {
    display: block;
}

.card-header-stacked .card-header-title-row {
    width: 100%;
    margin-bottom: 0.5rem;
}

.card-header-stacked .card-header-title-row h2 {
    margin: 0;
}

.card-header-stacked .card-header-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    width: 100%;
}

.market-section { margin-bottom: 1.5rem; }
.chart-card { margin-bottom: 0.75rem; }

/* Mercado sub-tabs (Brasil / Global / FIIS) */
.market-subtabs {
    display: flex;
    gap: 10px;
    margin: 0.75rem 0 1rem;
    flex-wrap: wrap;
}

.market-subtab-btn {
    border: 1px solid rgba(0,0,0,0.12);
    background: #fff;
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
}

.market-subtab-btn.active {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #fff;
}

.market-subtab-panel { display: none; }
.market-subtab-panel.active { display: block; }

/* Commodities sub-tabs (Duplicated from Market) */
.commodities-subtabs {
    display: flex;
    gap: 10px;
    margin: 0.75rem 0 1rem;
    flex-wrap: wrap;
}

.commodities-subtab-btn {
    border: 1px solid rgba(0,0,0,0.12);
    background: #fff;
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
}

.commodities-subtab-btn.active {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    color: #fff;
}

.commodities-subtab-panel { display: none; }
.commodities-subtab-panel.active { display: block; }

/* Grouped charts inside MERCADO/CRIPTO: 2 charts per row */
.market-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}

.market-charts-grid .chart-card {
    margin-bottom: 0;
}

@media (max-width: 1100px) {
    .market-charts-grid {
        grid-template-columns: 1fr;
    }
}

/* PANORAMA (novo layout) */
.panorama-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    align-items: start;
}

.panorama-left {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    /* Make items in the same row have equal height */
    align-items: stretch;
}

/* When a PANORAMA card stretches to match row height, keep its content layout stable. */
.panorama-left .chart-card {
    display: flex;
    flex-direction: column;
}

.panorama-left .chart-card .chart-content {
    flex: 1 1 auto;
}

/* Keep the plot area fixed for cards with tables so row stretching does not distort the chart. */
.panorama-left .chart-card.panorama-fixed-plot-card .chart-content {
    flex: 0 0 auto;
    overflow: hidden;
}

.panorama-left .chart-card.panorama-fixed-plot-card .card-header {
    min-height: 52px;
    align-items: flex-start;
}

.panorama-right {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Make PANORAMA cards less tall to reduce empty space */
.panorama-grid .chart-card {
    min-height: 320px;
}

/* Section titles (PANORAMA) */
.panorama-section-title {
    padding: 0;
    margin: 0;
}

.panorama-left .panorama-section-title {
    grid-column: 1 / -1;
}

.panorama-section-title h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--secondary-color);
}

/* News column uses the same list styles */

.panorama-news-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.panorama-news-loading {
    color: var(--text-light);
    font-size: 0.85rem;
    padding: 0.5rem;
}

.panorama-news-card {
    display: block;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid #ddd;
    padding: 0.75rem;
}

.panorama-news-thumb {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    overflow: hidden;
    background: #eef2f7;
    border: 1px solid #ddd;
}

.panorama-news-meta {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.panorama-news-title {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
}

.panorama-news-title a {
    color: var(--text-color);
    text-decoration: none;
}

.panorama-news-title a:hover {
    text-decoration: underline;
}

.panorama-news-desc {
    font-size: 0.85rem;
    line-height: 1.3;
    color: var(--text-light);
    margin: 0;
}

.panorama-placeholder {
    min-height: 180px;
}

/* Give more vertical room to the returns chart and align it with FX movers (520px). */
#panorama_returns_assets.panorama-placeholder {
    height: 520px;
    min-height: 520px;
}

/* Keep ETFs Base 100 slightly shorter to match the design grid. */
#etfs-base100-plot.panorama-placeholder {
    height: 440px;
    min-height: 440px;
}

/* FX movers chart: increased height */
#fx-movers-plot {
    height: 520px;
    min-height: 520px;
}

/* Commodities index chart: increased height */
#panorama_returns_commodities {
    height: 520px;
    min-height: 520px;
}

/* Keep both returns cards the same height even when the right title wraps */
.panorama-returns-card .card-header {
    min-height: 72px;
    align-items: flex-start;
}

@media (max-width: 1100px) {
    .panorama-grid {
        grid-template-columns: 1fr;
    }
    .panorama-left {
        grid-template-columns: 1fr;
    }
}

.badge {
    background-color: #eef2f7;
    color: var(--text-light);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
}

.chart-timestamp {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-left: auto;
    white-space: nowrap;
}

.empty-state {
    text-align: center;
    padding: 4rem;
    color: var(--text-light);
    font-size: 1.2rem;
    border: 2px dashed #ccc;
    border-radius: var(--radius);
}

/* Top Gainers Table (Panorama) */
.top-gainers-table-wrapper {
    max-height: 520px;
    overflow: auto;
    border: 1px solid #ddd;
    border-radius: var(--radius);
    background: #fff;
}

.top-gainers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.top-gainers-table thead th {
    position: sticky;
    top: 0;
    background-color: var(--card-bg);
    z-index: 1;
    text-align: left;
    padding: 0.75rem;
    border-bottom: 2px solid #ddd;
}

.top-gainers-table tbody td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

.top-gainers-table tbody tr:hover td {
    background-color: rgba(2, 125, 252, 0.06);
}

/* Variation tables under PANORAMA charts (no scroll; 2 assets per row) */
.variation-table-wrapper {
    max-height: none;
    overflow: visible;
    margin-top: 18px;
}

.variation-table-wrapper .top-gainers-table {
    font-size: 0.9rem;
}

.variation-table-wrapper .top-gainers-table thead th,
.variation-table-wrapper .top-gainers-table tbody td {
    padding: 0.5rem 0.65rem;
}

/* Responsive */
@media (max-width: 768px) {
    .app-wrapper {
        flex-direction: column;
        height: auto;
    }

    .sidebar {
        width: 100%;
        padding: 1rem;
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .nav-btn {
        padding: 0.5rem 1rem;
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .nav-btn.active {
        border-left: none;
        border-bottom-color: var(--accent-color);
    }

    .main-content {
        overflow-y: visible;
    }

    .subscribe-form {
        flex-direction: column;
    }

    .subscribe-form input {
        width: 100%;
    }
}

/* Mobile Specific Optimizations */
@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem;
    }

    .section-header h1 {
        font-size: 1.5rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .card-header > div {
        margin-left: 0 !important;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: space-between;
    }

    .card-header h2 {
        font-size: 1.1rem;
        width: 100%;
    }

    .card-header-stacked .card-header-controls {
        justify-content: flex-start;
    }

    /* Reduce chart heights for small screens so users can see more context */
    #panorama_returns_assets.panorama-placeholder,
    #world-indices-plot.panorama-placeholder,
    #etfs-base100-plot.panorama-placeholder, 
    .chart-content {
        height: 320px !important; /* Force override of inline styles or IDs */
        min-height: 320px !important;
    }
    
    /* Exceptions for smaller charts that don't need to be huge */
    #fx-base100-plot,
    #world-indices-plot {
        height: 320px !important;
    }

    /* Adjust table fonts and padding */
    .top-gainers-table {
        font-size: 0.8rem;
    }

    .top-gainers-table thead th, 
    .top-gainers-table tbody td {
        padding: 0.5rem 0.25rem;
    }

    /* Make logo smaller */
    #home-btn {
        max-height: 40px;
        width: auto; 
    }

    /* Compact Sidebar Nav */
    .nav-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .sidebar-banner {
        display: none; /* Hide banner on mobile to save space */
    }
}

/* Tooltip for Sector Baskets */
.tooltip-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.tooltip-content {
    visibility: hidden;
    width: 280px;
    background-color: #2c3e50;
    color: #fff;
    text-align: left;
    border-radius: 4px;
    padding: 10px;
    position: absolute;
    z-index: 9999;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 11px;
    line-height: 1.4;
    font-weight: normal;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    pointer-events: none;
    white-space: normal;
}

.tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #2c3e50 transparent transparent transparent;
}

.tooltip-container:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

