/* === COMPLETE REPORT STYLES === */

/* === FONT AWESOME FALLBACK STYLES === */
/* Fallback styles for Font Awesome icons if CDN fails */
.fa, .fas, .far, .fal, .fab {
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Pro', 'Font Awesome 5 Free', 'Font Awesome 5 Pro', 'Font Awesome 6 Brands', sans-serif !important;
    font-weight: 900;
    font-style: normal;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === MAIN LAYOUT === */
#report-container {
    @media (min-width: 480px) {
        #report-container section {
            margin-bottom: 1.5rem;
            padding: 0.5rem 0;
            border-radius: 0.5rem;
            background: transparent;
            width: 100%;
            box-shadow: none;
        }
    }
}
#report-container section {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    background: var(--bg-secondary);
    box-shadow: var(--card-shadow);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
#report-container h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#report-container h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#report-container h4 {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}
#report-container li,
#report-container p {
    line-height: 1.6;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

#report-container strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Monospace for numbers */
#report-container .number,
#report-container .price,
#report-container .percentage {
    font-family: var(--font-mono, 'Monaco', 'Menlo', 'Ubuntu Mono', monospace);
    font-weight: 500;
}

/* === CARD SYSTEM === */
#report-container .report-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    transition: all 0.15s ease;
    height: 100%;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#report-container .report-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

#report-container .sub-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    transition: all 0.15s ease;
    height: 100%;
}

#report-container .sub-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

#report-container .wide-card {
    grid-column: 1 / -1;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    transition: all 0.15s ease;
    height: 100%;
}

/* === GRID LAYOUTS === */
#report-container .content-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column for mobile by default */
    gap: 1.5rem;
    align-items: start;
    width: 100%; /* Ensure grid doesn't exceed container */
    max-width: 100%;
    box-sizing: border-box;
}

#report-container .content-grid .report-card,
#report-container .content-grid .sub-card {
    grid-column: span 1; /* Allow 2 cards per row */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* If there's an odd card at the end, make it span full width */
#report-container .content-grid .report-card:last-child:nth-child(odd),
#report-container .content-grid .sub-card:last-child:nth-child(odd) {
    grid-column: 1 / -1; /* Span full width if it's the last odd card */
}

#report-container .stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

/* === CHART CONTAINERS === */
#report-container .chart-container {
    background-color: var(--bg-secondary); /* A lighter background for charts */
    border-radius: 0.5rem;
    padding: 1rem;
    /*! border: 1px solid var(--border-color); */
    margin-top: 1rem;
    margin-bottom: 1rem;
    min-height: 200px; /* Ensure charts have some height */
    display: flex; /* To center chart if needed by JS */
    justify-content: center;
    align-items: center;
    color: var(--text-primary); /* Ensure chart labels/text are readable */
}
#report-container .gauge-container,
#report-container .doughnut-container,
#report-container .line-chart-container,
#report-container .bar-chart-container {
    position: relative;
    width: 100%;
    min-height: 200px;
    height: auto;
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

#report-container .chart-legend {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

#report-container .chart-value {
    font-family: var(--font-mono, 'Monaco', 'Menlo', 'Ubuntu Mono', monospace);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.125rem;
}

#report-container .chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
    font-style: italic;
}

/* === COMPONENT STYLES === */
#report-container .card-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

#report-container .impact-tag {
    display: inline-block;
    width: 90%;           /* primary width limit relative to its container */
    max-width: 90%;       /* ensure it doesn't exceed container */
    overflow: hidden;     /* hide overflowed content */
    text-overflow: ellipsis; /* show ellipsis for overflow */
    white-space: nowrap;  /* keep on single line */
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 1px solid var(--card-border);
    border-radius: 0.5rem;
}


#report-container .analysis-text {
    margin-top: 1rem;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

#report-container .analysis-text ul {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

#report-container .analysis-text li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
}

#report-container .analysis-text li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--accent-color);
    font-weight: bold;
    font-size: 1.25rem;
    line-height: 1;
}

/* === STAT ITEMS === */
#report-container .stat-item {
    background-color: var(--bg-primary);
    border: 1px solid var(--card-border);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    transition: all 0.2s ease;
}

#report-container .stat-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#report-container .stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

#report-container .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono, 'Monaco', 'Menlo', 'Ubuntu Mono', monospace);
}

#report-container .stat-change {
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font-mono, 'Monaco', 'Menlo', 'Ubuntu Mono', monospace);
}

/* === LEVEL INDICATORS === */
#report-container .level-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

#report-container .level-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid;
    transition: all 0.2s ease;
}

#report-container .level-item:hover {
    transform: translateX(4px);
}

#report-container .level-label {
    font-weight: 500;
    color: var(--text-secondary);
}

#report-container .level-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    font-family: var(--font-mono, 'Monaco', 'Menlo', 'Ubuntu Mono', monospace);
}

/* === TABLE SYSTEM === */
#report-container .table-container {
    overflow-x: auto;
    width: 100%;
    margin-top: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    -webkit-overflow-scrolling: touch;
}

#report-container table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--card-bg);
    border-width: 1px 0 0 0;
}
#report-container thead {
    border-width: 5px 0 4px 0;
}
#report-container th, 
#report-container td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#report-container th {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

#report-container td {
    color: var(--text-primary);
}

#report-container tbody tr {
    transition: background-color 0.2s ease;
    border-width: 2px 0 2px 0;
}

#report-container tbody tr:hover {
    background-color: var(--table-row-hover-bg, rgba(0, 0, 0, 0.02));
}

#report-container td i.fa-fw {
    margin-right: 0.5rem;
}

/* === INTERACTIVE ELEMENTS === */
#report-container .interactive-element {
    cursor: pointer;
    transition: all 0.2s ease;
}

#report-container .interactive-element:hover {
    opacity: 0.8;
}

#report-container .tooltip {
    position: absolute;
    background-color: var(--tooltip-bg, rgba(0, 0, 0, 0.9));
    color: var(--tooltip-text, white);
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    z-index: 1000;
    pointer-events: none;
}

/* === LOADING STATES === */
#report-container .skeleton {
    background: linear-gradient(90deg, var(--skeleton-base, #f0f0f0) 25%, var(--skeleton-highlight, #e0e0e0) 50%, var(--skeleton-base, #f0f0f0) 75%);
    background-size: 200% 100%;
    /* animation: skeleton-loading 1.5s infinite; */ /* Disabled for performance */
    border-radius: 0.25rem;
}

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

/* === RESPONSIVE DESIGN === */

/* Tablet */
@media (min-width: 768px) {
    #report-container {
        padding: 2rem;
    }
    
    #report-container .content-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    #report-container .stat-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* === RESPONSIVE DESIGN === */

/* Only mobile-specific styles for max-width: 580px 
   Note: For crypto-table to work properly in card mode, 
   HTML should include data-label attributes on each td element.
   Example: <td data-label="Coin Name">Bitcoin</td>
*/
@media (max-width: 580px) {
    #report-container .content-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0;
    }
    #report-container {
        padding: 0.75rem;
        gap: 1rem;
    }
    #report-container h1 {
        font-size: 1.5rem;
    }
    #report-container h2 {
        font-size: 1.25rem;
    }
    #report-container .wide-card,
    #report-container .report-card,
    #report-container .sub-card {
        padding: 0.75rem !important;
    }
    #report-container section {
        margin-bottom: 1.5rem !important;
        padding: 0.5rem 0 !important;
        border-radius: 0.5rem;
        box-shadow: none;
        background: transparent;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden;
    }
    /* Crypto table card layout for mobile */
    .crypto-table {
        font-size: 0.8rem;
    }
    
    /* General table mobile responsiveness */
    #report-container table {
        font-size: 0.8rem;
    }
    
    #report-container th,
    #report-container td {
        word-wrap: break-word;
        white-space: normal;
        overflow-wrap: break-word;
    }
    
    .crypto-table thead {
        display: none; /* Hide table header on mobile */
    }
    
    .crypto-table tbody {
        display: block;
    }
    
    .crypto-table tbody tr {
        display: block;
        background-color: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 0.75rem;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: var(--card-shadow);
        transition: all 0.3s ease;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .crypto-table tbody tr:hover {
        box-shadow: var(--card-shadow-hover);
        transform: translateY(-2px);
    }
    
    .crypto-table tbody td {
        display: block;
        padding: 0.75rem 0 !important;
        border-bottom: 1px solid var(--border-color);
        text-align: left;
        word-wrap: break-word;
        white-space: normal;
        overflow-wrap: break-word;
        min-height: 2rem;
    }
    
    .crypto-table tbody td:before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.875rem;
        line-height: 1.5;
        margin-bottom: 0.5rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .crypto-table tbody td .td-content {
        flex: 1;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .crypto-table tbody td:last-child {
        margin-bottom: 0;
        border-bottom: none;
    }
    
    /* Adjust table container for mobile card layout */
    .crypto-table .table-container {
        border: none;
        overflow: visible;
    }
    
    /* General table card layout for mobile - applies to all tables */
    #report-container table:not(.crypto-table) thead {
        display: none; /* Hide table header on mobile for all tables */
    }
    
    #report-container table:not(.crypto-table) tbody {
        display: block;
    }
    
    #report-container table:not(.crypto-table) tbody tr {
        display: block;
        background-color: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 0.75rem;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: var(--card-shadow);
        transition: all 0.3s ease;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    #report-container table:not(.crypto-table) tbody tr:hover {
        box-shadow: var(--card-shadow-hover);
        transform: translateY(-2px);
    }
    
    #report-container table:not(.crypto-table) tbody td {
        display: block;
        padding: 0.75rem 0 !important;
        border-bottom: 1px solid var(--border-color);
        text-align: left;
        word-wrap: break-word;
        white-space: normal;
        overflow-wrap: break-word;
        min-height: 2rem;
    }
    
    #report-container table:not(.crypto-table) tbody td:before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.875rem;
        line-height: 1.5;
        margin-bottom: 0.5rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    #report-container table:not(.crypto-table) tbody td:last-child {
        margin-bottom: 0;
        border-bottom: none;
    }
    
    #report-container .table-container {
        border: none;
        overflow: visible;
    }
    
    .chart-container {
        min-height: 200px !important;
    }
    .horizontal-layout {
        flex-direction: column !important;
    }
}


/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .report-card,
    .sub-card,
    .stats-card,
    .chart-container * {
        transition: none !important;
        animation: none !important;
    }
}

/* ===== IFRAME SANDBOX SPECIFIC STYLES ===== */

/* Reset and base styles for iframe content */
.sandboxed-report body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Enhanced body layout for better left navigation - mobile responsive */
@media (max-width: 768px) {
    .sandboxed-report body {
        padding: 0 !important;
    }
}

/* Content should flow naturally in full width */
.sandboxed-report section {
    break-inside: auto;
    width: 100%;
    margin-bottom: 1.5rem;
}

/* Chart containers should not break across columns */
.sandboxed-report .chart-container,
.sandboxed-report .gauge-container,
.sandboxed-report .doughnut-container,
.sandboxed-report .line-chart-container,
.sandboxed-report .bar-chart-container {
    break-inside: avoid;
}

/* Theme-aware styling for iframe */
.dark-theme {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.light-theme {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Language switching */
.lang-content {
    display: none;
}

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

/* Bridge shared CSS selectors to iframe content */
.sandboxed-report-container {
    width: 100%;
    max-width: 100%;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* ===== SANDBOXED REPORT LAYOUT OVERRIDES ===== */

/* Override report-layout for sandboxed iframe - make it full width */
.sandboxed-report .report-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
    max-width: 100%;
    width: 100%;
    padding: 1rem;
    min-height: 100vh;
    margin: 0;
    box-sizing: border-box;
}

/* Sandboxed navigation sidebar adjustments */
.sandboxed-report .navigation-sidebar {
    position: sticky;
    top: 1rem;
    height: fit-content;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    width: 100%;
    max-width: 300px;
    box-sizing: border-box;
}

/* Sandboxed content area - full width within container */
.sandboxed-report .content-area {
    min-width: 0;
    width: 100%;
    flex: 1;
    box-sizing: border-box;
}

/* Sandboxed report container full width */
.sandboxed-report #report-container {
    width: 100%;
    max-width: none;
    padding: 0;
    box-sizing: border-box;
}

/* Mobile responsiveness for sandboxed reports */
@media (max-width: 768px) {
    .sandboxed-report .report-layout {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 0.75rem;
    }
    
    .sandboxed-report .navigation-sidebar {
        display: none;
    }
    
    .sandboxed-report .content-area {
        width: 100%;
        max-width: 100%;
    }
    
    .sandboxed-report .content-area #report-container {
        padding: 0.5rem;
    }
}

/* Small tablet adjustments for sandboxed */
@media (max-width: 480px) {
    .sandboxed-report .report-layout {
        padding: 0;
    }
    
    .sandboxed-report .content-area #report-container {
        padding: 0.25rem;
    }
}

/* Tablet responsiveness for sandboxed */
@media (max-width: 1024px) and (min-width: 769px) {
    .sandboxed-report .report-layout {
        grid-template-columns: 280px 1fr;
        gap: 1.25rem;
    }
}

/* ===== NEW TWO-COLUMN LAYOUT SYSTEM ===== */

/* Main layout container */
.report-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 2rem;
    max-width: 100%;
    width: 100%;
    min-height: 100vh;
}

/* Navigation sidebar */
.navigation-sidebar {
    position: sticky;
    top: 1rem;
    height: fit-content;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    width: 100%;
    box-sizing: border-box; /* Ensure consistent width calculation */
}

/* Content area - full width */
.content-area {
    min-width: 0; /* Allows content to shrink */
    width: 100%;
    flex: 1;
}

#report-container {
    width: 100%;
    max-width: none; /* Remove any max-width restrictions */
}

/* Mobile responsiveness - Hide table of contents */
@media (max-width: 768px) {
    .report-layout {
        grid-template-columns: 1fr; /* Single column on mobile */
        gap: 0;
    }
    
    .navigation-sidebar {
        display: none; /* Hide table of contents on mobile */
    }
    
    .content-area {
        width: 100%;
    }
    
    /* Adjust report container padding for mobile */
    .content-area #report-container {
        padding: 0.5rem;
    }
}

/* Small tablet adjustments */
@media (max-width: 480px) {
    .report-layout {
        padding: 0;
    }
    
    .content-area #report-container {
        padding: 0;
    }
}

/* Tablet responsiveness */
@media (max-width: 1024px) and (min-width: 769px) {
    .report-layout {
        grid-template-columns: 300px 1fr; /* Larger sidebar on tablet */
        gap: 1.5rem;
    }
}

/* ===== NAVIGATION PANEL STYLES ===== */

/* Enhanced Navigation styling for left sidebar */
#report-navigation-panel {
    padding: 1rem;
    background-color: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px var(--shadow);
    width: 100%;
    height: fit-content;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    box-sizing: border-box; /* Ensure padding is included in width calculation */
}

.nav-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--border-color);
}

.nav-title-vi, .nav-title-en {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.1rem;
}

#report-nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

#report-nav-links li {
    margin-bottom: 0.15rem;
}

#report-nav-links a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.3;
    border-left: 3px solid transparent;
}

#report-nav-links a:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-left-color: var(--accent-color);
    transform: translateX(2px);
}

#report-nav-links a.active {
    background-color: #3b82f6;
    color: white;
    font-weight: 600;
    border-left-color: #1e40af;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.25);
}

/* ===== RESPONSIVE DESIGN FOR REPORT LAYOUT ===== */

/* Language switching */
.lang-content {
    display: none;
}

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

/* Enhanced content area styles - these apply to both regular and sandboxed reports */
.content-area #report-container {
    width: 100%;
    max-width: none;
    padding: 1rem;
}

/* Ensure sections take full width */
.content-area section {
    width: 100%;
    max-width: none;
}

/* Cards should expand to full available width */
.content-area .report-card,
.content-area .sub-card,
.content-area .wide-card {
    width: 100%;
    max-width: none;
}

/* Grid layouts should use full width */
.content-area .content-grid {
    width: 100%;
    max-width: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

/* Mobile adjustments for content area */
@media (max-width: 768px) {
    .content-area #report-container {
        padding: 0.75rem;
    }
    
    .content-area .content-grid {
        grid-template-columns: 1fr; /* Single column on mobile */
        gap: 1rem;
    }
}