/**
 * FIIT Index — Shared Component Styles
 * =====================================
 * Styles used across multiple browse/listing pages:
 * institutions.html, investors.html, countries.html, funds.html, data-lab.html
 *
 * Includes: search bar, clickable cards/rows, filter system, analytics view,
 * toolbar/export, badges, column headers, pagination, column info popovers.
 */

/* ======= SEARCH BAR OVERRIDE ======= */
.search-box input { padding: 0.85rem 1.15rem 0.85rem 2.75rem; font-size: 1.0625rem; font-weight: 500; border: 2px solid #e0e0e0; border-radius: 10px; }
.search-box input:focus { border-color: #6B5CA5; box-shadow: 0 2px 8px rgba(107, 92, 165, 0.12); }
.search-box input::placeholder { color: #999; font-weight: 500; }
.search-box::before { font-size: 1.125rem; left: 0.95rem; }

/* ======= CLICKABLE CARDS & ROWS ======= */
.clickable-row { cursor: pointer; transition: background-color 0.2s ease; }
.clickable-row:hover { background-color: #f8f9fa; }
.clickable-row:active { background-color: #e9ecef; }
.clickable-card { text-decoration: none; color: inherit; display: block; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.clickable-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
.clickable-card h3 { text-align: center; }
.clickable-card .card-detail { text-align: center; }

/* ======= TILE INDICATORS & BADGES ======= */
.tile-indicators { display: flex; justify-content: center; gap: 0.375rem; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid #f0f0f0; flex-wrap: wrap; }
.tile-badge { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.2rem 0.45rem; border-radius: 4px; font-size: 0.7rem; font-weight: 600; }
.tile-badge.yes { background: #dcfce7; color: #166534; }
.tile-badge.no { background: #fee2e2; color: #991b1b; }
.tile-badge.partial { background: #fef9c3; color: #854d0e; }
.tile-badge.unchecked { background: #f3f4f6; color: #6b7280; }

/* ======= IMPACT BADGES ======= */
.impact-badge { display: inline-block; padding: 0.25rem 0.75rem; border-radius: 4px; font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.impact-badge.yes { background: #d4edda; color: #155724; }
.impact-badge.no { background: #f8d7da; color: #721c24; }
.impact-badge.partial { background: #fff3cd; color: #856404; }
.impact-badge.unchecked { background: #e9ecef; color: #6c757d; }

/* ======= REGION BADGES ======= */
.region-badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 500; white-space: nowrap; }
.region-badge.africa { background: #fef3c7; color: #92400e; }
.region-badge.asia-pacific { background: #dbeafe; color: #1e40af; }
.region-badge.latam { background: #d1fae5; color: #065f46; }
.region-badge.eeca { background: #ede9fe; color: #5b21b6; }
.region-badge.mena { background: #fce7f3; color: #9d174d; }
.region-badge.other { background: #f3f4f6; color: #6b7280; }

/* ======= COLUMN GROUP HEADERS ======= */
.column-group-header { background: #f5f3f7 !important; color: #6B5CA5; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.75px; font-weight: 600; text-align: center; border-bottom: 2px solid #e0dce5 !important; padding: 0.6rem 1rem !important; border-left: 2px solid #e0dce5 !important; z-index: 11 !important; }
.column-group-child { border-top: none !important; font-size: 0.75rem; background: white !important; }
thead th[rowspan="2"] { vertical-align: middle; }

/* ======= ANALYTICS VIEW ======= */
.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.75rem; }
.analytics-stat { background: #f8f9fa; border-radius: 8px; padding: 0.875rem; text-align: center; border: 1px solid #f0f0f0; }
.analytics-stat .stat-value { font-size: 1.5rem; font-weight: 700; color: #1a1a1a; line-height: 1.2; }
.analytics-stat .stat-value.highlight-green { color: #166534; }
.analytics-stat .stat-value.highlight-accent { color: #5a3d7a; }
.analytics-stat .stat-value.highlight-amber { color: #854d0e; }
.analytics-stat .stat-label { font-size: 0.75rem; color: #666; margin-top: 0.25rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; }
.analytics-bar-chart { margin-top: 0.75rem; }
.analytics-bar-chart h4 { font-size: 0.75rem; font-weight: 600; color: #666; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.5rem; }
.pie-chart-container { display: flex; align-items: center; gap: 1.25rem; margin-top: 0.5rem; }
.pie-chart-svg { flex-shrink: 0; }
.pie-chart-legend { display: flex; flex-direction: column; gap: 0.3rem; }
.pie-legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: #444; }
.pie-legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.bar-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.375rem; }
.bar-label { font-size: 0.75rem; color: #666; min-width: 120px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; background: #f0f0f0; border-radius: 4px; height: 18px; position: relative; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; min-width: 2px; display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; }
.bar-fill span { font-size: 0.65rem; font-weight: 700; color: white; text-shadow: 0 0 2px rgba(0,0,0,0.3); }
.bar-count { font-size: 0.7rem; color: #999; min-width: 32px; text-align: right; }

/* ======= FILTER SYSTEM (collapsible) ======= */
.filter-system { background: #faf8ff; border: 1px solid #d4d0e0; border-left: 3px solid #6B5CA5; border-radius: 0 10px 10px 0; padding: 0; margin-bottom: 0.75rem; overflow: hidden; box-shadow: 0 2px 8px rgba(90,61,122,0.08); }
.filter-header { display: flex; justify-content: space-between; align-items: center; padding: 0.625rem 1rem; cursor: pointer; user-select: none; transition: background 0.15s; gap: 0.5rem; }
.filter-header:hover { background: #fafafa; }
.filter-header h3 { font-size: 0.875rem; font-weight: 600; color: #1a1a1a; margin: 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: nowrap; min-width: 0; overflow: hidden; }
.filter-header h3 svg { opacity: 0.6; flex-shrink: 0; }
.filter-header-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.filter-toggle-icon { transition: transform 0.3s; color: #999; flex-shrink: 0; }
.filter-toggle-icon.open { transform: rotate(180deg); }
.filter-body { display: none; padding: 0 1rem 0.75rem; }
.filter-body.open { display: block; }
.filter-chips-inline { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; margin-left: 0.25rem; }
.filter-chips-inline .chip-inline { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.15rem 0.45rem; background: #ede9fe; color: #5a3d7a; border-radius: 3px; font-size: 0.7rem; font-weight: 500; }
.filter-rules { display: flex; flex-direction: column; gap: 0.5rem; }
.filter-rule { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem; background: #f8f9fa; border-radius: 8px; flex-wrap: wrap; }
.filter-rule-prefix { font-size: 0.8125rem; font-weight: 500; color: #666; min-width: 50px; }
.filter-rule select, .filter-rule input[type="text"], .filter-rule input[type="number"], .filter-rule input[type="date"] { padding: 0.5rem 0.75rem; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 0.875rem; background: white; transition: all 0.2s; }
.filter-rule select:focus, .filter-rule input:focus { outline: none; border-color: #6B5CA5; box-shadow: 0 0 0 3px rgba(107, 92, 165, 0.1); }
.filter-rule .field-select { min-width: 160px; }
.filter-rule .operator-select { min-width: 100px; }
.filter-rule .value-input { min-width: 120px; }
.filter-rule .value-select { min-width: 140px; }
.value-pills { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; }
.value-pill { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.3rem 0.6rem; background: #ede9fe; color: #5a3d7a; border-radius: 4px; font-size: 0.8125rem; font-weight: 500; cursor: pointer; transition: all 0.15s; border: 1px solid transparent; }
.value-pill:hover { background: #d2e3fc; }
.value-pill.selected { background: #5a3d7a; color: white; }
.value-pill.yes.selected { background: #155724; color: white; }
.value-pill.no.selected { background: #721c24; color: white; }
.value-pill.partial.selected { background: #856404; color: white; }
.value-pill.unchecked.selected { background: #6c757d; color: white; }
.remove-filter-btn { background: none; border: none; color: #999; cursor: pointer; padding: 0.375rem; border-radius: 4px; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.remove-filter-btn:hover { background: #fee2e2; color: #dc2626; }
.add-filter-btn { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.5rem 0.875rem; background: none; border: 1px dashed #ccc; border-radius: 6px; color: #666; font-size: 0.8125rem; font-weight: 500; cursor: pointer; transition: all 0.15s; margin-top: 0.5rem; }
.add-filter-btn:hover { border-color: #6B5CA5; color: #6B5CA5; background: #f8f7fa; }
.clear-filters-btn { padding: 0.375rem 0.75rem; background: none; border: 1px solid #e0e0e0; border-radius: 6px; color: #666; font-size: 0.8125rem; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.clear-filters-btn:hover { border-color: #dc2626; color: #dc2626; background: #fef2f2; }
.active-filters-count { background: #6B5CA5; color: white; font-size: 0.75rem; padding: 0.125rem 0.5rem; border-radius: 10px; margin-left: 0.5rem; }
.filter-rule input[type="number"] { width: 100px; }
.country-multiselect { cursor: pointer; }
.selected-countries { margin-left: 0; }
.selected-countries .value-pill { font-size: 0.75rem; padding: 0.2rem 0.5rem; }

/* ======= AND/OR CONNECTOR ======= */
.connector-select { min-width: 70px; padding: 0.5rem 0.75rem; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 0.875rem; background: white; transition: all 0.2s; cursor: pointer; }
.connector-select:focus { outline: none; border-color: #6B5CA5; box-shadow: 0 0 0 3px rgba(107, 92, 165, 0.1); }

/* ======= TOOLBAR (export, columns) ======= */
.toolbar-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.toolbar-left { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 0.5rem; }
.export-btn, .columns-btn { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.45rem 0.875rem; background: white; border: 1px solid #e0e0e0; border-radius: 6px; color: #555; font-size: 0.8125rem; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.export-btn:hover { border-color: #5a3d7a; color: #5a3d7a; background: #f8f7fa; }
.columns-btn:hover { border-color: #6B5CA5; color: #6B5CA5; background: #f8f7fa; }
.columns-dropdown { display: none; position: absolute; top: 100%; right: 0; background: white; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 0.5rem; z-index: 100; min-width: 200px; }
.columns-dropdown.open { display: block; }
.columns-dropdown label { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.5rem; border-radius: 4px; font-size: 0.8125rem; color: #333; cursor: pointer; transition: background 0.1s; white-space: nowrap; }
.columns-dropdown label:hover { background: #f8f9fa; }
.columns-dropdown input[type="checkbox"] { accent-color: #6B5CA5; }
.columns-wrapper { position: relative; }

/* ======= PCT BAR (inline progress bars) ======= */
.pct-bar-wrapper { display: flex; align-items: center; gap: 0.4rem; min-width: 90px; }
.pct-bar-track { flex: 1; background: #f0f0f0; border-radius: 3px; height: 8px; overflow: hidden; min-width: 50px; }
.pct-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s ease; }
.pct-bar-fill.green { background: #22c55e; }
.pct-bar-fill.amber { background: #f59e0b; }
.pct-bar-fill.red { background: #ef4444; }
.pct-bar-fill.blue { background: #3b82f6; }
.pct-bar-label { font-size: 0.75rem; font-weight: 600; color: #555; min-width: 36px; text-align: right; }

/* ======= COLUMN INFO POPOVERS ======= */
.col-info-btn { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; background: #e9e5f0; color: #7c6b9a; font-size: 0.6rem; font-weight: 700; cursor: pointer; border: none; margin-left: 0.3rem; vertical-align: middle; line-height: 1; transition: background 0.15s, color 0.15s; position: relative; font-style: italic; font-family: Georgia, serif; }
.col-info-btn:hover { background: #6B5CA5; color: white; }
.col-info-popover { display: none; position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: #1a1a2e; color: #e8e8e8; font-size: 0.75rem; font-weight: 400; line-height: 1.45; padding: 0.6rem 0.75rem; border-radius: 8px; width: 220px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); z-index: 200; text-transform: none; letter-spacing: normal; white-space: normal; text-align: left; pointer-events: auto; }
.col-info-popover.open { display: block; }
.col-info-popover::before { content: ''; position: absolute; top: -5px; left: 50%; transform: translateX(-50%); width: 10px; height: 10px; background: #1a1a2e; rotate: 45deg; }
th { position: relative; }

/* ======= PAGINATION ======= */
.pagination-bar { display: flex; justify-content: center; align-items: center; gap: 0.5rem; padding: 1rem 0; flex-wrap: wrap; }
.pagination-bar button { padding: 0.4rem 0.75rem; border: 1px solid #e0e0e0; border-radius: 6px; background: white; color: #555; font-size: 0.8125rem; cursor: pointer; transition: all 0.15s; }
.pagination-bar button:hover:not(:disabled) { border-color: #6B5CA5; color: #6B5CA5; background: #f8f7fa; }
.pagination-bar button:disabled { opacity: 0.4; cursor: default; }
.pagination-bar button.active { background: #6B5CA5; color: white; border-color: #6B5CA5; }
.pagination-bar .page-info { font-size: 0.8125rem; color: #666; }
.pagination-bar .page-size-select { padding: 0.4rem 0.5rem; border: 1px solid #e0e0e0; border-radius: 6px; font-size: 0.8125rem; background: white; color: #555; }

/* ======= TABLE SCROLL ======= */
.table-view { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-view table { min-width: 900px; }

/* ======= FUNDER TOGGLE IN TABLE ======= */
.funder-toggle { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.8rem; color: #5a3d7a; font-weight: 500; cursor: pointer; padding: 0.2rem 0.5rem; border-radius: 5px; transition: background 0.15s; user-select: none; }
.funder-toggle:hover { background: #f3effb; }
.funder-toggle .funder-chevron { display: inline-block; font-size: 0.6rem; transition: transform 0.2s ease; line-height: 1; }
.funder-toggle.open .funder-chevron { transform: rotate(90deg); }
.funder-list { display: none; margin-top: 0.4rem; }
.funder-list.open { display: flex; flex-direction: column; gap: 0.25rem; }
.funder-list-item { display: inline-flex; align-items: center; font-size: 0.72rem; color: #444; padding: 0.2rem 0.5rem; background: #f8f7fa; border-radius: 4px; border: 1px solid #ede9fe; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; transition: background 0.1s; text-decoration: none; }
a.funder-list-item { color: #5a3d7a; cursor: pointer; }
a.funder-list-item:hover { background: #ede9fe; color: #3d2a5c; }
.funder-cell-wrapper { min-width: 100px; }

/* ======= CARD INVESTOR PILLS ======= */
.card-investors { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem; margin-top: 0.5rem; }
.card-investors .investor-tag { font-size: 0.65rem; }

/* ======= LOADING & ERROR ======= */
.loading { text-align: center; padding: 4rem 2rem; color: #666; }
.loading h2 { font-size: 1.125rem; font-weight: 500; color: #999; }
.error { text-align: center; padding: 4rem 2rem; color: #dc3545; }

/* ======= RESPONSIVE ======= */
@media (max-width: 768px) {
    .filter-rule { flex-direction: column; align-items: stretch; }
    .filter-rule-prefix { min-width: auto; }
    .filter-rule select, .filter-rule input { width: 100%; }
    .value-pills { width: 100%; }
    .filter-chips-inline { display: none; }
    .analytics-grid { grid-template-columns: repeat(2, 1fr); }
    .toolbar-row { flex-direction: column; align-items: stretch; }
    .toolbar-right { justify-content: flex-end; }
    #analyticsCharts, #dashboardAnalyticsCharts { grid-template-columns: 1fr !important; }
    .pie-chart-container { flex-direction: column; align-items: flex-start; }
    .pagination-bar { gap: 0.25rem; }
    .pagination-bar button { padding: 0.3rem 0.5rem; font-size: 0.75rem; }
}
