/* 
   Premium Portfolio Design System
   Modern, Dark Mode first, Fluid Design
*/

:root {
    --primary: #007AFF;
    --primary-hover: #005BBF;
    --bg-dark: #0A0A0B;
    --bg-card: #161618;
    --text-main: #FFFFFF;
    --text-muted: #A1A1AA;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(22, 22, 24, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --container-width: 95%;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout Heights */
    --nav-height: 70px;
    --explorer-header-height: 100px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.6;
}

/* Force document scroll for Analysis page to ensure sticky works */
html.page-fund_analysis, 
body.page-fund_analysis {
    height: auto !important;
    overflow: visible !important;
}

body.page-fund_analysis .container {
    max-width: 1900px !important;
    width: 95%;
    margin: 0 auto;
}

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header & Navigation */
.main-header {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 3000;
    /* Max z-index for main nav */
    background: var(--bg-dark);
    /* Ensure opaque */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    padding: 0;
    height: var(--nav-height);
    display: flex;
    align-items: center;
}

.main-header nav {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    background: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-main);
}



/* Landing Page Hero */
.hero {
    padding: 8rem 0 4rem;
    text-align: center;
}

.hero h1 {
    font-size: 4.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 2.5rem;
}

/* Project Grid */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2.5rem;
    padding: 4rem 0;
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    text-decoration: none;
    color: inherit;
}

.project-card:hover {
    border-color: var(--primary);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.project-image {
    width: 100%;
    aspect-ratio: 16/10;
    background: #252529;
    /* Placeholder color */
    object-fit: cover;
}

.project-info {
    padding: 2rem;
}

.project-info h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.project-info p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.project-tag {
    display: inline-block;
    padding: 0.4rem 1rem;
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary);
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

/* Footer */
.main-footer {
    padding: 6rem 0 3rem;
    border-top: 1px solid var(--border-color);
    margin-top: 4rem;
    text-align: center;
}

.main-footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Utility */
.btn-primary {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 1rem 2.5rem;
    border-radius: 0.8rem;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}


/* Layout for Fixed Application Dashboard (Funds Page) */
body.page-funds {
    height: 100vh !important;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
}

body.page-funds main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 0 !important;
    min-height: 0;
}

/* Standard scroll for Analysis page */
body.page-fund_analysis main {
    overflow: visible !important;
    height: auto !important;
    display: block !important;
}

.page-funds .with-footer {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 0 !important;
    min-height: 0;
}

/* Financial Data Table */
.table-wrapper {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    margin-top: 2rem;
    /* Keep regular margin for non-funds pages */
    overflow-x: visible !important;
    /* Contain horizontal scroll at body level */
    background: var(--bg-card);
    margin-bottom: 20px !important;
}

.page-funds .table-wrapper {
    flex: 1;
    overflow: auto !important; /* ONLY this scrolls vertically */
    width: 100%;
    max-width: 100vw;
    margin-top: 0;
    position: relative;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    min-height: 0;
}

.data-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
    background: var(--bg-card);
    border-radius: 1rem;
    table-layout: fixed;
    /* Help with layout stability */
}

.data-table th {
    background: var(--bg-card);
    background-clip: padding-box;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    height: 60px;
    /* Fixed height for headers to ensure predictable alignment */
}

.page-funds .data-table th {
    position: sticky;
    top: 0 !important;
    /* Sticks to the top of table-wrapper */
    background: #0A0A0B !important;
    z-index: 1500;
}

/* Sort Links and Icons */
.sort-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.sort-link:hover {
    color: var(--text-main);
}

.sort-icon {
    font-size: 0.8rem;
    opacity: 0.3;
    transition: var(--transition);
}

.sort-link:hover .sort-icon,
.sort-link.active .sort-icon {
    opacity: 1;
}

.sort-link.active {
    color: #3b82f6;
    /* Tailwind Blue 500 */
}

/* Column Filters */
.column-filter {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 6px 8px;
    font-size: 0.75rem;
    font-family: inherit;
    background: var(--bg-dark);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--text-main);
    border-radius: 4px;
    transition: var(--transition);
}

.column-filter:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 191, 166, 0.2);
}

.column-filter::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.column-filter.active {
    color: var(--primary);
    /* Green color to indicate active filter */
    border-color: var(--primary);
    font-weight: 600;
}

/* Explorer Header Elements */
.explorer-header {
    background: #0A0A0B !important;
    position: relative;
    width: 100%;
    z-index: 2050;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.explorer-body, .explorer-card, .card {
    overflow: visible !important;
}

.data-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    color: var(--text-main);
    text-align: right;
}

/* Sticky Checkbox Column */
.page-funds .data-table th.col-check,
.page-funds .data-table td.col-check {
    position: sticky;
    left: 0;
    z-index: 110;
    width: 35px;
    min-width: 35px;
    max-width: 35px;
    background-color: var(--bg-card);
    text-align: center;
    padding: 0;
    border-right: 1px solid var(--border-color);
}

.page-funds .data-table th.col-check {
    top: 0 !important;
    z-index: 1600;
    background-color: #0A0A0B;
}

/* Sticky Second Column (Nom / ISIN) */
.page-funds .data-table th.col-nom {
    position: sticky;
    left: 35px;
    top: 0 !important;
    z-index: 1550;
    min-width: 300px;
    background-color: #0A0A0B;
    background-clip: padding-box;
    box-shadow: 5px 0 10px rgba(0, 0, 0, 0.3);
    border-right: 2px solid var(--border-color);
}

.page-funds .data-table td.col-nom {
    position: sticky;
    left: 35px;
    /* width of col-check */
    z-index: 5;
    background-color: var(--bg-card);
    min-width: 300px;
    box-shadow: 5px 0 10px rgba(0, 0, 0, 0.3);
    border-right: 2px solid var(--border-color);
    text-align: left;
}

.data-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.03);
}

.data-table tr:hover td:first-child {
    background-color: #1c1c1e;
}

.perf-positive {
    color: #4ADE80;
}

.perf-negative {
    color: #F87171;
}

.perf-orange {
    color: #FB923C;
}

/* SRI Color Gradient */
.sri-1 { color: #4ADE80; font-weight: 800; } /* Vert clair */
.sri-2 { color: #22C55E; font-weight: 800; } /* Vert */
.sri-3 { color: #84CC16; font-weight: 800; } /* Lime */
.sri-4 { color: #FACC15; font-weight: 800; } /* Jaune */
.sri-5 { color: #F97316; font-weight: 800; } /* Orange */
.sri-6 { color: #EF4444; font-weight: 800; } /* Rouge */
.sri-7 { color: #991B1B; font-weight: 800; } /* Rouge sombre */

/* Redesigned Fixed Footer Pagination */
.pagination-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #0f1117;
    /* Very dark background from mockup */
    border-top: 1px solid #2d3139;
    padding: 0.6rem 5%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1.5rem;
    z-index: 3000;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.6);
    color: #9ca3af;
    font-size: 0.95rem;
}

.pagination-footer form {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.pagination-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.pg-input {
    background: #1e222d;
    border: 1px solid #374151;
    color: white;
    padding: 0.35rem 0.5rem;
    border-radius: 0.4rem;
    width: 70px;
    text-align: center;
    font-size: 0.95rem;
}

.pg-select {
    background: #1e222d;
    border: 1px solid #374151;
    color: white;
    padding: 0.35rem 2rem 0.35rem 0.6rem;
    border-radius: 0.4rem;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='7 15 12 20 17 15'%3E%3C/polyline%3E%3Cpolyline points='7 9 12 4 17 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    font-size: 0.95rem;
}

.pg-btn-go {
    background: #374151 !important;
    border: none !important;
    color: white !important;
    padding: 0.4rem 1.2rem !important;
    border-radius: 0.4rem !important;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.pg-btn-go:hover {
    background: #4b5563 !important;
}

.pg-numbers {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.pg-num {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    background: #1e222d;
    border: 1px solid #374151;
    color: white;
    border-radius: 0.4rem;
    text-decoration: none;
    font-size: 0.9rem;
    transition: 0.15s;
}

.pg-num.active {
    background: #3b82f6 !important;
    border-color: #3b82f6 !important;
}

.pg-num:hover:not(.active) {
    border-color: #60a5fa;
}

.pg-ellipsis {
    color: #4b5563;
    padding: 0 0.2rem;
}

/* Custom Liquid Glass Tooltip */
/* Tooltip stylings applied inside the global container */
.glass-tooltip-title {
    color: #f59e0b; /* Amber 400 */
    display: block;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.glass-tooltip-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Slim scrollbar for tooltip */
.glass-tooltip-list::-webkit-scrollbar {
    width: 4px;
}
.glass-tooltip-list::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
}
.glass-tooltip-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

.glass-tooltip-item {
    margin-bottom: 0.8rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.glass-tooltip-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.glass-tooltip-fund {
    color: var(--primary);
    font-weight: 700;
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.9rem;
}

.glass-tooltip-years {
    color: rgba(255,255,255,0.6);
    font-size: 0.8rem;
    font-style: italic;
}

/* Dynamic Arrow for Smart Tooltip */
.tooltip-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    pointer-events: none;
}
/* If tooltip is ABOVE icon, arrow is at BOTTOM of tooltip pointing DOWN */
.arrow-to-bottom {
    border-top: 8px solid rgba(15, 17, 23, 0.95);
    top: 100%;
}
/* If tooltip is BELOW icon, arrow is at TOP of tooltip pointing UP */
.arrow-to-top {
    border-bottom: 8px solid rgba(15, 17, 23, 0.95);
    bottom: 100%;
}

.glass-tooltip-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.glass-tooltip-fund {
    font-weight: 700;
    display: block;
    color: #fff;
}

.glass-tooltip-years {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Floating Contextual Actions Bar */
.floating-bulk-actions {
    position: fixed;
    bottom: 85px; /* Above the pagination footer */
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(22, 22, 24, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.8rem 1.5rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    z-index: 2500;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    opacity: 0;
}

.floating-bulk-actions.active {
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
    opacity: 1;
}

#global-selection-banner {
    position: sticky;
    top: calc(var(--nav-height) + var(--explorer-header-height));
    z-index: 1800; /* Under explorer header, above table headers */
}

/* Layout adjustment to prevent content being hidden under fixed footer */
/* Pagination footer adjust - Locked and Right Aligned */
.page-funds .pagination-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 2.5rem;
    background: #0A0A0B;
    border-top: 1px solid var(--border-color);
    padding: 0.8rem 2rem;
    width: 100%;
}

.page-funds .pagination-numbers {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.page-funds .pagination-footer form {
    display: flex;
    align-items: center;
    gap: 2rem;
    width: auto;
}

.page-funds .pagination-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}