/* --- Tom Select Styles --- */
.bq-ratio-adder .ts-wrapper {
    width: 100%;
}

.bq-ratio-adder .ts-control {
    border: 1px solid #dee2e6 !important;
    border-radius: 6px !important;
    height: 38px !important;
    padding: 8px 12px !important;
    box-sizing: border-box;
    font-size: 14px !important;
    box-shadow: none !important;
    background-image: none !important;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out !important;
}

.bq-ratio-adder .ts-wrapper.focus .ts-control,
.bq-ratio-adder .ts-wrapper.input-active .ts-control {
    border-color: #0073aa !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 115, 170, 0.25) !important;
    outline: none;
}

.bq-ratio-adder .ts-dropdown {
    z-index: 100 !important;
    border-radius: 0 0 6px 6px;
    border: 1px solid #dee2e6;
    border-top: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.bq-ratio-adder .ts-dropdown .ts-dropdown-content {
    max-height: 300px;
}

.bq-ratio-adder .ts-dropdown .option {
    padding: 8px 12px;
    font-size: 14px;
}

.bq-ratio-adder .ts-dropdown .option:hover,
.bq-ratio-adder .ts-dropdown .active {
    background-color: #f0f2f5;
}
/* --- End of Added Styles --- */

/* --- Layout Spacing --- */
.bq-secondary-nav-container {
    margin-bottom: 25px;
}

/* --- Styles for the Stock Overview Page --- */

/* Company Header Block */
.bq-company-header-block {
    margin-bottom: 30px;
}
.bq-page-header h1 {
    margin: 0;
}
.bq-key-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    font-size: 14px;
    color: #555;
    margin-top: 10px;
}

/* Header Card Layout */
.bq-header-card-grid {
    display: grid;
    grid-template-columns: 70% 1fr;
    gap: 40px;
}

.bq-header-about-col h2 {
    font-size: 16px;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 15px;
}
.description-fade-wrapper {
    position: relative;
    max-height: 150px;
    overflow: hidden;
    margin-bottom: 15px;
}
.description-fade-wrapper p {
    margin: 0;
    line-height: 1.6;
    color: #555;
}
.bq-read-more {
    display: inline-block;
    font-weight: 600;
    color: #0073aa;
    text-decoration: none;
    cursor: pointer;
}
.bq-read-more:hover {
    text-decoration: underline;
}

/* Multi-column Metrics Table */
.bq-metrics-table {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0 60px;
    font-size: 14px;
}
.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f2f5;
    background-color: #fff; /* Default background for desktop */
}

.metric-item span:first-child {
    color: #555;
}
.metric-item span:last-child {
    font-weight: 600;
    text-align: right;
}

/* Ratio Adder & Edit Button Controls */
.bq-ratios-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
}
.bq-ratio-adder {
    position: relative;
    flex-grow: 1;
    max-width: 300px;
}

.btn-edit-ratios {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s;
    margin-left: auto;
}
.btn-edit-ratios:hover {
    background-color: #f0f2f5;
    color: #333;
}
.btn-edit-ratios svg {
    margin-top: -2px;
}

/* Chart styles */
.bq-chart-period-selector {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
    margin-top: 20px;
}
.bq-chart-period-selector .bq-period-btn {
    background-color: #f0f2f5;
    border: 1px solid #dee2e6;
    color: #555;
    padding: 5px 15px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.bq-chart-period-selector .bq-period-btn:hover {
    background-color: #e9ecef;
}
.bq-chart-period-selector .bq-period-btn.active {
    background-color: #0073aa;
    color: white;
    border-color: #005a87;
}
.bq-loader-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Analysis styles */
.bq-analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}
.bq-analysis-col h3 {
    font-size: 16px;
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}
.bq-analysis-list {
    list-style-type: none;
    padding-left: 20px;
    margin: 0;
}
.bq-analysis-list li {
    position: relative;
    padding-bottom: 12px;
    line-height: 1.5;
}
.bq-pros-list li::before {
    content: '✅';
    position: absolute;
    left: -20px;
}
.bq-cons-list li::before {
    content: '❌';
    position: absolute;
    left: -20px;
}


/* Peers Table Styles */
#peers-table {
    border-collapse: collapse;
    border-spacing: 0;
}

#peers-table th, #peers-table td {
    padding: 8px 10px;
}
#peers-table .peer-sno-col {
    width: 45px;
    min-width: 45px;
}
#peers-table th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 20px !important;
}
#peers-table th.sortable::before,
#peers-table th.sortable::after {
    content: "";
    position: absolute;
    right: 8px;
    border: 4px solid transparent;
    opacity: 0.3;
}
#peers-table th.sortable::before { top: 50%; margin-top: -9px; border-bottom-color: #666; }
#peers-table th.sortable::after { top: 50%; margin-top: 1px; border-top-color: #666; }
#peers-table th.sorted-asc::before,
#peers-table th.sorted-desc::after { opacity: 1; }

#peers-table th:nth-child(2),
#peers-table td:nth-child(2) {
    position: -webkit-sticky;
    position: sticky;
    left: 0;
    z-index: 2; 
    box-shadow: 2px 0 5px -2px rgba(0,0,0,0.1);
}
#peers-table thead th:nth-child(2) {
    background-color: #f8f9fa; 
    z-index: 3; 
}
#peers-table td:nth-child(2) {
    background-color: #ffffff;
}
#peers-table tr.highlight-row td:nth-child(2) {
    background-color: #e9f5ff;
}
#peers-table tbody tr:hover td:nth-child(2) {
    background-color: #f1f8ff;
}

#peers-table tr.highlight-row td {
    background-color: #e9f5ff;
}
#peers-table tbody tr:hover td {
    background-color: #f1f8ff;
}
tr.highlight-row, tr.highlight-row a {
    font-weight: 600;
}
.peer-company-link {
    font-weight: 600;
    text-decoration: none;
    color: #0073aa;
}
.peer-company-link:hover { text-decoration: underline; }

/* Description Modal Styles */
.bq-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.bq-modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
.bq-modal-content {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}
.bq-modal-overlay.visible .bq-modal-content {
    transform: scale(1);
}
.bq-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid #dee2e6;
}
.bq-modal-header h2 {
    margin: 0;
    font-size: 18px;
}
.bq-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #888;
    padding: 0 5px;
}
.bq-modal-close:hover {
    color: #333;
}
.bq-modal-body {
    padding: 25px;
    overflow-y: auto;
    line-height: 1.7;
}

/* Scroll to Top Button */
#bq-scroll-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: #0073aa;
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
#bq-scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
}
#bq-scroll-to-top:hover {
    background-color: #005a87;
}

/* --- Industry Comparisons --- */
.bq-percentile-grid-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
}
.bq-percentile-statement-card {
    background-color: #fff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 5px 5px;
}
.bq-percentile-statement-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 15px;
}
.bq-percentile-table {
    width: 100%;
    border-collapse: collapse;
}
.bq-percentile-table th, .bq-percentile-table td {
    padding: 5px 4px;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: middle;
    font-size: 13px;
    white-space: nowrap;
}
.bq-percentile-table tbody tr:last-child td {
    border-bottom: none;
}
.bq-percentile-table th {
    font-weight: 500;
    color: #999;
    font-size: 11px;
    padding-bottom: 10px;
}
.bq-percentile-table td {
    color: #444;
}

/* Column Alignment & Widths */
.bq-percentile-table th:nth-child(1), .bq-percentile-table td:nth-child(1) { width: 45%; text-align: left; }
.bq-percentile-table th:nth-child(2), .bq-percentile-table td:nth-child(2) { width: 15%; text-align: right; }
.bq-percentile-table th:nth-child(3), .bq-percentile-table td:nth-child(3) { width: 15%; text-align: right; }
.bq-percentile-table th:nth-child(4), .bq-percentile-table td:nth-child(4) { width: 25%; text-align: left; }

.metric-name-cell {
    overflow: hidden;
    text-overflow: ellipsis;
}
.percentile-bar-track {
    height: 6px;
    background-color: #e9ecef;
    width: 100%;
    border-radius: 3px;
    overflow: hidden;
}
.percentile-bar-fill {
    height: 100%;
    border-radius: 3px;
}

/* Responsive adjustments */
@media (max-width: 960px) {
    .bq-header-card-grid {
        display: flex;
        flex-direction: column; 
        gap: 30px;
    }
    .bq-metrics-table {
        grid-template-columns: repeat(2, 1fr);
    }
    /* MODIFIED: Reverted to original order for mobile */
    .bq-header-metrics-col {
        order: 1; /* Metrics section (including header) appears first */
    }
    .bq-header-about-col {
        order: 2; /* About section appears second */
    }
}
@media (max-width: 768px) {
    .bq-section {
        padding-left: 15px;
        padding-right: 15px;
    }
    .bq-percentiles-section {
        padding-left: 0;
        padding-right: 0;
    }
     .bq-percentiles-section > h2, .bq-percentile-grid-container {
        padding-left: 3px;
        padding-right: 3px;
    }

    .bq-analysis-grid,
    .bq-metrics-table {
        grid-template-columns: 1fr;
    }
    
    .bq-metrics-table .metric-item:nth-child(odd) {
        background-color: #f8f9fa !important;
    }
    .bq-metrics-table .metric-item:nth-child(even) {
        background-color: #fff !important;
    }

    .bq-modal-content {
        width: calc(100% - 20px);
        margin: 10px;
    }
    .bq-chart-period-selector {
        justify-content: center;
    }

    .bq-historic-data-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .bq-percentile-table th:nth-child(1), .bq-percentile-table td:nth-child(1) { 
        width: 5%; 
        text-align: left; 
    }
    
    .bq-percentile-table th:nth-child(4), .bq-percentile-table td:nth-child(4) {
    width: 10% !important;
    text-align: left;
    }
}

/* Desktop Layout */
@media (min-width: 961px) {
    .bq-percentile-grid-container {
        grid-template-columns: repeat(2, 1fr);
    }
    .bq-percentile-statement-card:nth-child(n+5) {
        display: none;
    }
}