/* Market Overview Page Styles - Table styling for market data pages WITHOUT RATING COLUMN */
/* Exact copy of market-overview.css but with rating column removed and width distributed */

/* Main container for market tables */
.market-container {
    max-width: 1230px;
    margin: 0 auto;
    padding: 20px 15px;
}

/* Table styling to match existing design */
.market-table-wrapper {
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    padding: 0;
    overflow-x: auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Add scroll indicator for mobile */
@media (max-width: 767px) {
    .market-table-wrapper:has(.forecast-table) {
        position: relative;
    }
    
    .market-table-wrapper:has(.forecast-table)::after {
        content: "← Scroll →";
        position: absolute;
        bottom: 0;
        right: 0;
        background: rgba(0, 115, 170, 0.9);
        color: white;
        padding: 2px 8px;
        font-size: 10px;
        border-radius: 4px 0 0 0;
        pointer-events: none;
        opacity: 0.8;
    }
}

/* Prevent horizontal scroll on forecast table - desktop only */
@media (min-width: 768px) {
    .forecast-table {
        table-layout: fixed;
        width: 100%;
    }
}

/* Set column widths for forecast table WITHOUT RATING - only on desktop */
/* Original rating column was 4%, distributed evenly among 7 remaining columns (approx 0.57% each) */
@media (min-width: 768px) {
    /* Column 1: Name - was 26%, now 26.57% */
    .forecast-table th:nth-child(1),
    .forecast-table td:nth-child(1) {
        width: 27%; /* Name column - increased by ~0.57% */
    }
    
    /* Column 2: FX Rate/Price - was 10%, now 10.57% */
    .forecast-table th:nth-child(2),
    .forecast-table td:nth-child(2) {
        width: 11%; /* Price column - increased by ~0.57% */
        text-align: right; /* Right align price on desktop */
    }
    
    /* Ensure price header is also right-aligned */
    #th-price {
        text-align: right;
    }
    
    /* Columns 3-6: Percentage forecasts (7d, 3m, 1y, 5y) - were 10%, now 10.57% */
    .forecast-table th:nth-child(3),
    .forecast-table td:nth-child(3),
    .forecast-table th:nth-child(4),
    .forecast-table td:nth-child(4),
    .forecast-table th:nth-child(5),
    .forecast-table td:nth-child(5),
    .forecast-table th:nth-child(6),
    .forecast-table td:nth-child(6) {
        width: 10.5%; /* Percentage columns - increased by ~0.57% */
    }

    /* Column 7: Price Graph - was 20%, now 20.5% */
    .forecast-table th:last-child,
    .forecast-table td:last-child {
        width: 21%; /* Price Graph column - increased by ~0.5% */
    }
}

.market-table-wrapper table {
    margin: 0;
    border: none;
    width: 100%;
    border-collapse: collapse;
}

.market-table-wrapper th {
    background: #0073aa;
    color: #fff;
    font-weight: 600;
    padding: 12px 15px;
    border: none;
    white-space: nowrap;
    text-align: left;
}

/* Override for forecast tables to allow wrapping */
.forecast-table th {
    white-space: normal;
}

/* Allow word break for forecast table headers */
.forecast-table th {
    word-break: break-word;
    overflow-wrap: break-word;
}

.market-table-wrapper th:first-child {
    border-top-left-radius: 8px;
}

.market-table-wrapper th:last-child {
    border-top-right-radius: 8px;
}

.market-table-wrapper th a {
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.market-table-wrapper th a:hover {
    opacity: 0.8;
}

.market-table-wrapper td {
    padding: 12px 15px;
    border-bottom: 1px solid #e1e1e1;
    vertical-align: middle;
}

/* Ensure all table cells are vertically centered - only for forecast tables */
.forecast-table th,
.forecast-table td {
    vertical-align: middle !important;
}

/* Ensure images in cells are also centered - only needed for forecast tables */
.forecast-table td img {
    vertical-align: middle;
    display: inline-block;
}

.market-table-wrapper tbody tr {
    transition: background-color 0.2s ease;
}

.market-table-wrapper tbody tr:hover {
    background: #f9f9f9;
}

/* Make clickable rows more obvious */
.market-table-wrapper tbody tr[onclick] {
    cursor: pointer;
}

.market-table-wrapper tbody tr[onclick]:hover {
    background: #f0f7ff;
}

.market-table-wrapper tbody tr:last-child td {
    border-bottom: none;
}

/* Asset name column */
.asset-name-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
    word-break: break-word;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.asset-name-link:hover {
    color: #0073aa;
}

.asset-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

/* Symbol/ticker styling */
.asset-symbol {
    color: #999;
    font-weight: 400;
    text-transform: uppercase;
    font-size: 0.9em;
}

/* Specific styles for forecast tables */
.forecast-table .asset-name-link {
    flex-wrap: wrap !important;
    line-height: 1.4 !important;
    white-space: normal !important;
    word-break: break-word !important;
}

/* Force text wrapping in name cells (now FIRST column) */
.forecast-table td:nth-child(1) {
    white-space: normal !important;
    text-align: left;
}

/* On desktop, keep some control over name column width (now FIRST column) */
@media (min-width: 768px) {
    .forecast-table td:nth-child(1) {
        max-width: 250px;
        min-width: 150px;
    }
}

/* Price styling */
.price-cell {
    text-align: right;
    font-weight: 500;
}

/* Change percentage styling */
.change-cell {
    text-align: right;
}

.change-value {
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
}

.change-value.green {
    color: #0da059;
    background: rgba(13, 160, 89, 0.1);
}

.change-value.red {
    color: #ea3323;
    background: rgba(234, 51, 35, 0.1);
}

/* Chart cell styling */
.chart-cell,
.chart-link-cell {
    text-align: center;
}

.chart-link {
    font-size: 12px;
    color: #0073aa;
    text-decoration: none;
    padding: 4px 8px;
    border: 1px solid #0073aa;
    border-radius: 4px;
    transition: all 0.2s;
    display: inline-block;
}

.chart-link:hover {
    background: #0073aa;
    color: #fff;
}

.no-chart {
    font-size: 12px;
    color: #999;
}

/* Pagination styling */
.pagination-wrapper {
    text-align: center;
    margin: 30px 0;
}

.pagination {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    list-style: none;
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.pagination a, .pagination span {
    padding: 8px 12px;
    border: 1px solid #ddd;
    text-decoration: none;
    color: #333;
    background: #fff;
    border-radius: 4px;
    transition: all 0.2s;
    min-width: 40px;
    text-align: center;
    display: inline-block;
}

.pagination a:hover {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.pagination .current,
.pagination span.current {
    background: #0073aa;
    color: #fff !important;
    border-color: #0073aa;
    font-weight: 600;
    cursor: default;
}

.pagination .prev, .pagination .next {
    font-weight: 500;
    padding: 8px 16px;
}

/* Button styling */
.btn {
    display: inline-block;
    padding: 6px 12px;
    margin-bottom: 0;
    font-size: 14px;
    font-weight: normal;
    line-height: 1.42857143;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 4px;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    line-height: 1.5;
    border-radius: 3px;
}

.btn-primary {
    color: #fff;
    background-color: #0073aa;
    border-color: #0073aa;
}

.btn-primary:hover {
    color: #fff;
    background-color: #005177;
    border-color: #004766;
    text-decoration: none;
}

/* Responsive - MOBILE STYLES */
@media (max-width: 991px) {
    .market-table-wrapper {
        font-size: 14px;
    }
    
    .market-table-wrapper th, 
    .market-table-wrapper td {
        padding: 10px 12px;
    }
}

@media (max-width: 767px) {
    .market-container {
        padding: 10px;
    }
    
    .market-table-wrapper {
        font-size: 12px;
        border-radius: 0;
        overflow-x: auto; /* Enable horizontal scroll on mobile */
    }
    
    .market-table-wrapper th, 
    .market-table-wrapper td {
        padding: 12px 8px;
    }
    
    /* FORECAST TABLE MOBILE STYLES - WITHOUT RATING */
    /* Remove fixed table layout to allow natural sizing */
    .forecast-table {
        table-layout: auto;
        min-width: 100%;
    }
    
    /* Allow horizontal scroll for forecast tables */
    .market-table-wrapper:has(.forecast-table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Smaller headers for forecast table on mobile */
    .forecast-table th {
        font-size: 11px;
        padding: 8px 2px;
        white-space: normal;
        word-break: normal; /* Natural word breaking */
        overflow-wrap: normal;
        line-height: 1.15;
        vertical-align: middle;
    }
    
    /* Force line break after first word in percentage headers - adjusted for no rating column */
    .forecast-table th:nth-child(3) a,
    .forecast-table th:nth-child(4) a,
    .forecast-table th:nth-child(5) a,
    .forecast-table th:nth-child(6) a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        line-height: 1;
        gap: 2px;
    }
    
    /* Make the last header (Price Graph) also break nicely */
    .forecast-table th:last-child {
        line-height: 1.1;
    }
    
    /* Forecast table cells */
    .forecast-table td {
        padding: 6px 2px;
        font-size: 12px;
        vertical-align: middle !important;
    }
    
    /* Name column (now first) - wider since no rating */
    .forecast-table th:nth-child(1) {
        min-width: 80px;
        max-width: 100px;
        white-space: normal;
        word-break: break-word;
        text-align: center; /* Center the Name header on mobile */
        padding: 6px 3px;
    }
    
    .forecast-table td:nth-child(1) {
        min-width: 80px;
        max-width: 100px;
        white-space: normal;
        word-break: break-word;
        text-align: left; /* Keep name data left-aligned */
        padding: 6px 3px;
    }
    
    /* FX Rate/Price column (now second) - center aligned */
    .forecast-table th:nth-child(2),
    .forecast-table td:nth-child(2) {
        min-width: 50px;
        max-width: 65px;
        text-align: center;
        padding: 6px 2px;
    }
    
    /* Percentage columns - optimized for mobile */
    .forecast-table th:nth-child(3),
    .forecast-table th:nth-child(4),
    .forecast-table th:nth-child(5),
    .forecast-table th:nth-child(6) {
        min-width: 45px;
        max-width: 60px;
        text-align: center;
        padding: 8px 2px;
    }
    
    .forecast-table td:nth-child(3),
    .forecast-table td:nth-child(4),
    .forecast-table td:nth-child(5),
    .forecast-table td:nth-child(6) {
        min-width: 45px;
        max-width: 60px;
        text-align: center;
        white-space: normal; /* Allow wrapping for large numbers */
        padding: 6px 2px;
        word-break: break-word;
        line-height: 1.1;
    }
    
    /* Last column (Price Graph) */
    .forecast-table th:last-child {
        min-width: 60px;
        max-width: 75px;
        text-align: center;
        white-space: normal;
        word-break: normal;
        padding: 8px 2px;
    }
    
    .forecast-table td:last-child {
        min-width: 60px;
        max-width: 75px;
        text-align: center;
        padding: 6px 2px;
    }
    
    /* Asset name link - optimized vertical stack */
    .forecast-table .asset-name-link {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        white-space: normal;
        word-break: break-word;
        line-height: 1.15;
        text-align: center;
    }
    
    /* Center the text content */
    .forecast-table .asset-name-link > span {
        text-align: center;
        display: block;
        width: 100%;
    }
    
    /* Special handling for forex double flags */
    #forex-forecast-table .asset-name-link {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    #forex-forecast-table .asset-name-link .asset-icon {
        margin: 0 2px;
    }
    
    #forex-forecast-table .asset-name-link > span {
        width: 100%;
        margin-top: 2px;
    }
    
    /* Smaller icons on mobile */
    .forecast-table .asset-icon {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }
    
    /* Adjust symbol display */
    .forecast-table .asset-symbol {
        font-size: 9px;
        white-space: nowrap;
        display: block;
        margin-top: 1px;
    }
    
    /* Compact change values */
    .forecast-table .change-value {
        font-size: 11px;
        padding: 1px;
        white-space: normal; /* Allow wrapping for large percentages */
        word-break: break-word;
        display: inline-block;
        max-width: 100%;
        line-height: 1.1;
    }
    
    /* Chart images in last column */
    .forecast-table td:last-child img {
        display: block;
        margin: 0 auto;
        max-width: 80px;
        height: auto;
        max-height: 40px;
    }
    
    .pagination a, .pagination span {
        padding: 6px 8px;
        font-size: 14px;
        min-width: 30px;
    }
    
    .pagination .prev, .pagination .next {
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    /* Ensure good padding on very small screens */
    .market-table-wrapper th,
    .market-table-wrapper td {
        padding: 8px 4px;
    }
    
    /* Even tighter for forecast tables */
    .forecast-table th,
    .forecast-table td {
        padding: 5px 2px;
    }
    
    /* FORECAST TABLE - VERY SMALL SCREENS WITHOUT RATING */
    /* Even smaller text but keep all columns visible */
    .forecast-table th {
        font-size: 10px;
        padding: 6px 2px;
    }
    
    .forecast-table td {
        font-size: 11px;
        padding: 5px 2px;
    }
    
    /* Name column on very small screens (now first) */
    .forecast-table th:nth-child(1),
    .forecast-table td:nth-child(1) {
        min-width: 70px;
        max-width: 85px;
    }
    
    /* FX Rate/Price and percentage columns - ultra compact */
    .forecast-table th:nth-child(2),
    .forecast-table td:nth-child(2),
    .forecast-table th:nth-child(3),
    .forecast-table td:nth-child(3),
    .forecast-table th:nth-child(4),
    .forecast-table td:nth-child(4),
    .forecast-table th:nth-child(5),
    .forecast-table td:nth-child(5),
    .forecast-table th:nth-child(6),
    .forecast-table td:nth-child(6) {
        min-width: 40px;
        max-width: 50px;
    }
    
    /* Price Graph column - compact */
    .forecast-table th:last-child,
    .forecast-table td:last-child {
        min-width: 60px;
        max-width: 80px;
    }
    
    /* Even smaller change values */
    .forecast-table .change-value {
        font-size: 10px;
        padding: 0;
        line-height: 1.05;
    }
    
    /* Smaller chart images */
    .forecast-table td:last-child img {
        max-width: 60px;
        max-height: 30px;
    }
    
    .asset-icon {
        width: 20px;
        height: 20px;
    }
}

/* Additional utility classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-weight-500 { font-weight: 500; }
.font-weight-600 { font-weight: 600; }