/* Financial Reports Page Styles with result-screener structure */

/* Main container styling với overflow visible cho tooltips */
.container-fluid.main {
    /* Allow tooltips to extend outside main container if needed */
    overflow: visible !important;
}

.box-content.market-table {
    /* Allow tooltips to extend outside market-table container */
    overflow: visible !important;
}

/* Fixed height table with scrollable body */
.result-screener .box-result {
    position: relative;
    /* Allow tooltips to extend outside */
    overflow: visible;
}

.result-screener .table-container {
    height: 770px; /* Tăng height để hiển thị 10 rows thay vì 7 rows */
    min-height: 600px;
    max-height: 800px; /* Tăng giới hạn chiều cao tối đa */
    overflow: visible !important; /* Allow tooltips to extend outside */
    border-radius: 8px;
    /* Allow tooltips to extend outside container */
    position: relative;
}

.result-screener .table-scrollable {
    height: 100%;
    overflow-y: auto;
    overflow-x: auto;
    /* Ensure tooltips can extend outside scrollable area */
    position: relative;
}

.result-screener .table-scrollable::-webkit-scrollbar {
    width: 3px;
}

.result-screener .table-scrollable table {
    margin-bottom: 0;
}

/* Fixed header - override market-table styles */
.box-content.market-table .result-screener .table-container .table-scrollable table thead {
    position: sticky;
    top: 0px !important;
    z-index: 10;
}

/* Table header styling - match result-screener header color */
.box-content.market-table .result-screener .table-container .table-scrollable table thead tr td {
    background-color: var(--bg-thead);
    font-weight: 600;
    padding-bottom: 12px;
    padding-top: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Sort column styling */
.box-content.market-table .result-screener .table-container .table-scrollable table thead tr td.sort-col {
    cursor: pointer;
    transition: color 0.2s ease;
}

.box-content.market-table .result-screener .table-container .table-scrollable table thead tr td.sort-col:hover {
    background-color: var(--border-main);
}

/* Sort indicators */
.result-screener .sort-col svg path {
    fill: #999999;
    transition: fill 0.2s ease;
}

.result-screener .sort-col.sort-asc svg path:first-child {
    fill: #666666;
}

.result-screener .sort-col.sort-desc svg path:last-child {
    fill: #666666;
}

/* Table cell styling - giống stock-industry */
.result-screener .table-scrollable table td {
    min-width: 80px;
    text-align: center; /* Center align all table cells */
}

.result-screener .table-scrollable table td[data-sort="revenue"],
.result-screener .table-scrollable table td[data-sort="revenue_yoy"],
.result-screener .table-scrollable table td[data-sort="net_profit"],
.result-screener .table-scrollable table td[data-sort="net_profit_yoy"] {
    min-width: 105px !important;
}

/* Table cell padding - giống result-screener */
.market-table .result-screener .table-scrollable table tr td {
    padding-top: 12px;
    padding-bottom: 12px;
    vertical-align: middle !important; /* Ensure all cells have consistent vertical alignment */
    min-height: 60px; /* Consistent minimum height for all cells */
}

/* Market symbol column styling với improved tooltip positioning */
.result-screener .table-scrollable table td.market-symbol {
    text-align: center;
    position: relative; /* Important for tooltip positioning with flexbox */
    /* Ensure tooltip positioning context */
    overflow: visible;
    vertical-align: middle !important; /* Ensure consistent vertical alignment */
    /* Force same height as other cells */
    height: auto !important;
    min-height: 60px !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
}

/* Tooltip positioning fix for flexbox cells */
.result-screener .table-scrollable table td.market-symbol.d-flex {
    position: relative;
    overflow: visible;
    align-items: center !important; /* Center content vertically */
    justify-content: center !important; /* Center content horizontally */
    /* Ensure flexbox doesn't change height */
    height: auto !important;
    min-height: 60px !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    z-index: 5;
}

/* STT column styling - match result-screener */
.box-content.market-table .result-screener table td:first-child,
.box-content.market-table .result-screener table thead td:first-child {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
}

.result-screener .table-scrollable table td.market-symbol img {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    margin-right: 8px;
    object-fit: cover;
}

.result-screener .table-scrollable table td.market-symbol p {
    margin: 0;
    line-height: 1.2;
}

.result-screener .table-scrollable table td.market-symbol p.exchange {
    font-size: 10px;
    color: var(--text-normal);
    margin-top: 2px;
}

/* Market symbol image styling */
.result-screener .table-scrollable table td.market-symbol img {
    width: 30px;
    height: 30px;
    margin-right: 6px;
    background-color: rgb(239, 239, 239);
    object-fit: contain;
    border-radius: 50%;
    padding: 3px;
    flex-shrink: 0; /* Prevent image from shrinking */
}

/* Market symbol text styling */
.result-screener .table-scrollable table td.market-symbol p {
    margin: 0;
    line-height: 1.2;
    flex-grow: 1; /* Allow text to take remaining space */
}

img, svg {
    vertical-align: middle;
}

/* Tooltip styling - copy chính xác từ stock-screener.css */
.result-screener .table-scrollable table tbody td.market-symbol .tooltip-custom {
    display: none;
    background-color: var(--bg-tooltip-ticker);
    color: var(--text-main);
    width: 360px;
    text-align: left;
    border-radius: 10px;
    padding: 5px;
    position: absolute;
    z-index: 1000;
    bottom: 80%;
    left: 20px; /* Closer default position */
    box-shadow: 0px 0px 8px var(--border-soft);
    /* Add transition for smooth positioning */
    transition: all 0.2s ease;
}

/* Add pseudo-element to create hover bridge area */
.result-screener .table-scrollable table tbody td.market-symbol .tooltip-custom::before {
    content: "";
    position: absolute;
    width: 30px;
    height: 30px;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    z-index: -1;
    /* Invisible bridge to maintain hover */
}

.result-screener .table-scrollable table tbody td.market-symbol:hover .tooltip-custom {
    display: block;
}

/* Extended hover area for better UX */
.result-screener .table-scrollable table tbody td.market-symbol {
    position: relative;
}

.result-screener .table-scrollable table tbody td.market-symbol:hover {
    /* Ensure hover state persists */
    z-index: 10;
}

.result-screener .tooltip-custom.hide {
    display: none !important;
}

/* Hide tooltip class for JavaScript control (like stock-screener) */
.result-screener .table-scrollable table .tooltip-custom.hide {
    display: none !important;
}

.result-screener .tooltip-custom .info {
    margin: 6px;
}

.result-screener .tooltip-custom .info .logo-symbol, .result-screener .tooltip-custom .link-symbol {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.result-screener .tooltip-custom .logo-symbol .symbol {
    font-size: 22px;
    line-height: 22px;
    font-weight: bold;
}

.result-screener .tooltip-custom .logo-symbol svg.tooltip-close {
    margin-left: auto;
    cursor: pointer;
}

.result-screener .tooltip-custom .financial {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.result-screener .tooltip-custom .financial .item {
    flex: 1 1 25%;
    background-color: var(--bg-box-white);
    padding: 3px 6px;
    border-radius: 8px;
    text-align: center;
}

.result-screener .tooltip-custom .financial .item p {
    margin: 0;
    line-height: 1.5;
}

.result-screener .tooltip-custom .info .name, .result-screener .tooltip-custom .logo-symbol span:last-child, .result-screener .tooltip-custom .financial .item p:first-child {
    font-size: 14px;
}

.result-screener .tooltip-custom .financial .item p:last-child, .result-screener .tooltip-custom .link-symbol a {
    font-size: 15px;
    font-weight: 500;
}

.result-screener .tooltip-custom .link-symbol {
    margin-top: 10px;
}

.result-screener .tooltip-custom .link-symbol a {
    background-color: var(--border-soft);
    color: var(--bg-link-menu);
    padding: 3px 6px;
    border-radius: 6px;
    transition: all ease-in-out 0.3s;
    text-decoration: none;
}

.result-screener .tooltip-custom .link-symbol a:hover {
    background-color: #f5a504;
    color: #fff;
}

.box-content.market-table .result-screener .table-container .table-scrollable table thead tr td.sort-col {
    border-bottom: none;
    cursor: pointer;
}

.result-screener .table-scrollable table td.sort-col {
    cursor: pointer;
}

/* Ensure proper table layout */
.result-screener .table-scrollable table {
    width: 100%;
}

.pagination-container .pagination.pagination-controls {
    margin-top: 0px;
}

/* Debug pagination container */
.result-screener nav.pagination-container {
    display: flex !important;
    justify-content: center;
    margin-top: 15px;
    padding: 15px 0;
    min-height: 60px; /* Ensure minimum height */
}

.result-screener .pagination-controls {
    display: flex !important;
    flex-wrap: wrap !important;
    padding-left: 0 !important;
    margin-bottom: 0 !important;
    list-style: none !important;
    visibility: visible !important; /* Force visible */
    opacity: 1 !important; /* Force opaque */
    border-radius: 0.25rem;
}

/* Pagination active state styling - white text on active button */
.result-screener .pagination-controls .page-item.active .page-link {
    background-color: #007bff !important;
    border-color: #007bff !important;
    color: #ffffff !important; /* White text for active button */
    font-weight: 600;
}

/* Pagination hover state */
.result-screener .pagination-controls .page-item .page-link:hover {
    background-color: #e9ecef;
    border-color: #dee2e6;
    color: #001f3f;
    text-decoration: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .result-screener .table-container {
        height: 550px; /* Tăng proportional cho mobile - khoảng 8 rows */
        min-height: 450px;
        max-height: 600px;
    }
    
    /* Responsive pagination */
    .result-screener .pagination-container ul li {
        margin-right: 7px;
    }
    
    .result-screener .pagination-container ul li .page-link {
        padding: 3px 8px;
    }
}


/* Mobile Sticky Columns */
@media (max-width: 768px) {
    /* Sticky cột STT (#) */
    .result-screener .table-scrollable table td:nth-child(1),
    .result-screener .table-scrollable table thead td:nth-child(1) {
        z-index: 2;
    }
    
    /* Sticky cột Mã CK */
    .result-screener .table-scrollable table td:nth-child(2),
    .result-screener .table-scrollable table thead td:nth-child(2) {
        position: sticky;
        left: 30px; /* Width của cột STT */
        z-index: 2;
    }
    
    /* Header có background khác */
    .result-screener .table-scrollable table thead td:nth-child(1),
    .result-screener .table-scrollable table thead td:nth-child(2) {
        background-color: var(--bg-thead);
        z-index: 3;
    }
    
    /* Table container scrollable */
    .table-scrollable {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .box-content.market-table .result-screener table td:first-child,
    .box-content.market-table .result-screener table thead td:first-child {
        min-width: 40px;
        max-width: 40px;
        width: 40px;
    }
}

.market-table .box-title {
    padding-bottom: 0;
}

.result-screener .box-title {
    padding-bottom: 10px;
}

.financial-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

@media (max-width: 480px) {
    .list-year label, .list-quarter label, .list-search label, .list-industries label, .list-search input, .select-smoney select {
        font-size: 15px;
    }
    .result-screener .table-container {
        height: 600px;
        min-height: 350px;
        max-height: 600px;
    }
}

/* Enhanced Bootstrap styling for filter dropdowns */
.filter-controls {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.filter-group {
    min-width: 140px;
}

.filter-group .form-label {
    font-weight: 600;
    color: #495057 !important;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group .form-select {
    border: 1.5px solid #ced4da;
    border-radius: 0.375rem;
    background-color: #ffffff;
    transition: all 0.15s ease-in-out;
    font-weight: 500;
    color: #495057;
    min-width: 120px;
}

.filter-group .form-select:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    background-color: #ffffff;
}

.filter-group .form-select:hover {
    border-color: #adb5bd;
    background-color: #f8f9fa;
}

.filter-group .form-select option {
    padding: 0.5rem;
    font-weight: 500;
}

/* Custom dropdown arrow */
.filter-group .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m1 6 7 7 7-7'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
    .filter-controls {
        flex-direction: column;
        gap: 1rem !important;
        padding: 0.75rem 1rem;
    }
    
    .filter-group {
        width: 100%;
        min-width: auto;
    }
    
    .filter-group .form-select {
        width: 100%;
        min-width: 100%;
    }
}

/* Enhanced focus states for accessibility */
.filter-group .form-select:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Loading state styling */
.filter-controls.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Mobile Table Optimization - Complete responsive design */
@media (max-width: 768px) {
    /* Container adjustments */
    .result-screener .box-result {
        padding: 8px;
        margin: 0 -15px;
    }
    
    /* Enable smooth horizontal scrolling */
    .result-screener .table-scrollable {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 6px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    }
    
    /* Table sizing for mobile */
    .result-screener .table-scrollable table {
        min-width: 900px; /* Ensure horizontal scroll is needed */
        margin-bottom: 0;
        font-size: 13px;
    }
    
    /* Sticky column "Mã CK" - Main mobile feature */
    .result-screener .table-scrollable table td.market-symbol {
        position: sticky !important;
        left: 0px;
        z-index: 9;
        min-width: 95px;
        max-width: 95px;
    }
    
    /* Header sticky positioning */
    .result-screener .table-scrollable table thead td:nth-child(2) {
        position: sticky;
        left: 0px;
        background-color: var(--bg-thead);
        z-index: 11!important;
        min-width: 95px;
        max-width: 95px;
    }
    
    /* Other columns minimum width */
    .result-screener .table-scrollable table td:not(:first-child):not(.market-symbol) {
        min-width: 85px;
        padding: 8px 4px;
    }
    
    /* Table header mobile adjustments */
    .result-screener .table-scrollable table thead td {
        padding: 8px 4px;
        font-weight: 600;
        line-height: 1.2;
    }
    
    /* Market symbol content mobile optimization */
    .result-screener .table-scrollable table td.market-symbol img {
        width: 18px;
        height: 18px;
        margin-right: 4px;
    }
    
    .result-screener .table-scrollable table td.market-symbol .exchange {
        font-size: 9px;
        color: #6c757d;
    }
    
    /* Mobile table row hover */
    .result-screener .table-scrollable table tbody tr:hover {
        background-color: #f8f9ff;
    }
}

/* Extra small screens optimization */
@media (max-width: 480px) {
    .result-screener .box-result {
        padding: 4px;
        margin: 0 -8px;
    }
    
    /* Even more compact sticky column */
    .result-screener .table-scrollable table td.market-symbol,
    .result-screener .table-scrollable table thead td:nth-child(2) {
        min-width: 80px;
        max-width: 80px;
    }
    
    /* Smaller text on tiny screens */
    .result-screener .table-scrollable table {
        font-size: 11px;
    }
    
    .result-screener .table-scrollable table thead td {
        padding: 6px 3px;
    }
    
    .result-screener .table-scrollable table tbody td {
        padding: 6px 3px;
    }
    
    /* Tooltip adjustments - copy từ stock-screener */
    .result-screener .table-scrollable table tbody td.market-symbol .tooltip-custom {
        width: calc(100vw - 60px);
    }
}

/* Search input styling */
.list-search {
    min-width: 200px;
    position: relative;
}

.list-search input {
    background-color: var(--bg-thead);
    font-weight: 500;
    padding: 7px 10px;
    border-radius: 6px;
    border: none;
    max-width: 200px;
    width: 100%;
    transition: color 0.3s ease;
}

.list-search input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(57, 97, 251, 0.2);
    background-color: var(--bg-thead);
}

.list-search input:not(:placeholder-shown) {
    color: var(--text-blue);
    text-transform: uppercase;
}

.list-search .help-text {
    display: block;
    font-size: 11px;
    color: #6c757d;
    margin-top: 2px;
    font-style: italic;
}

/* Industry filter styling - giống rs-stock.css */
.list-industries {
    min-width: 200px;
}

.list-industries select {
    background-color: var(--bg-thead);
    color: var(--text-blue);
    font-weight: 500;
    padding: 7px 10px;
    border-radius: 6px;
    border: none;
    max-width: 330px;
    width: 100%;
}

.list-industries select:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(57, 97, 251, 0.2);
}

.list-industries select option {
    padding: 5px;
    font-weight: 500;
}

/* Responsive adjustments for search and industry filters */
@media (max-width: 480px) {
    .list-search {
        width: 100%;
        min-width: auto;
    }
    
    .list-search input {
        max-width: calc(100vw - 20px);
    }
    
    .list-search .help-text {
        font-size: 10px;
    }
    
    .list-industries {
        width: 100%;
        min-width: auto;
    }
    
    .list-industries select {
        max-width: calc(100vw - 20px);
    }
}

/* Qty-stock styling - copied from stock-screener.css */
.box-title p.qty-stock {
    margin-bottom: 0.5rem;
    font-weight: 500;
    justify-content: flex-end !important;
    text-align: right;
}

.box-title p.qty-stock span.qty {
    font-size: 28px;
    color: var(--text-main);
}

.box-title p.qty-stock span.name {
    font-weight: 500;
    font-style: italic;
    color: var(--text-muted);
}

.box-title p.qty-stock span {
    font-size: 18px;
    color: var(--text-muted);
}

/* Mobile responsive for qty-stock */
@media (max-width: 768px) {
    .box-title p.qty-stock span.qty {
        font-size: 24px;
    }
    
    .box-title p.qty-stock span {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .box-title p.qty-stock span.qty {
        font-size: 20px;
    }

    .box-title p.qty-stock span {
        font-size: 14px;
    }
}
