/* Option 2: Clean Minimalist / SaaS Design */
:root {
    --bg-color: #f7f9fc;
    --card-bg: #ffffff;
    --text-primary: #1a1f36;
    --text-secondary: #697386;
    --accent: #5469d4;
    --border: #e3e8ee;
    --success: #32d583;
    --success-bg: #ecfdf5;
    --success-text: #047857;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --danger-text: #b91c1c;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background: var(--card-bg);
    padding: 0 2rem;
    height: 64px;
    /* Fixed height for alignment */
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Vertically align items */
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    height: 100%;
}

.brand-icon {
    width: 30px;
    height: 30px;
    background: var(--text-primary);
    color: white;
    border-radius: 6px;
    display: grid;
    place-items: center;
}

.nav-links {
    display: flex;
    gap: 2rem;
    height: 100%;
    align-items: center;
    /* Vertically align links */
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    position: relative;
    /* For Pseudo-element positioning */
    height: 100%;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: transparent;
    transition: background-color 0.2s;
}

.nav-link.active,
.nav-link:hover {
    color: var(--text-primary);
}

.nav-link.active::after,
.nav-link:hover::after {
    background-color: var(--text-primary);
}

/* Mobile Navigation & Layout Fixes */
@media (max-width: 768px) {
    body {
        padding-bottom: 80px;
        /* Space for bottom nav */
        overflow-x: hidden;
        /* Prevent horizontal scroll */
    }

    .container {
        padding: 0 1rem;
        width: 100%;
        overflow-x: hidden;
    }

    .navbar {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        width: 100%;
        height: 60px;
        padding: 0 1rem;
        background: var(--card-bg);
        border-top: 1px solid var(--border);
        border-bottom: none;
        justify-content: center;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    }

    .brand {
        display: none;
        /* Hide brand on mobile bottom nav */
    }

    .nav-links {
        width: 100%;
        justify-content: space-around;
        gap: 0;
    }

    .nav-link {
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        font-size: 0.7rem;
        border-bottom: none;
        padding-top: 0;
        color: var(--text-secondary);
        opacity: 0.8;
    }

    .nav-link::before {
        font-family: 'bootstrap-icons';
        font-size: 1.2rem;
        content: '\F432';
        /* Default icon */
    }

    /* Specific Icons for Nav Items */
    /* Specific Icons for Nav Items */
    .nav-link[href="/client/"]::before {
        content: '\F474';
    }

    /* Grid/Overview */
    .nav-link[href="/client/investments/"]::before {
        content: '\F630';
    }

    /* List/Investments */
    .nav-link[href="/client/portfolio/"]::before {
        content: '\F509';
    }

    /* Pie/Portfolio */
    .nav-link[href="/client/forecasting/"]::before {
        content: '\F3E5';
    }

    /* Logout */
    .nav-link#logoutBtn::before {
        content: '\F1C2';
        /* box-arrow-right */
    }

    /* Graph/Forecasting */

    .nav-link.active {
        color: var(--accent);
        border-bottom: none;
        opacity: 1;
    }
}

/* Container */
.container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
}

/* Stats Row */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02), 0 1px 2px rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.02);
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-title {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    background: var(--success-bg);
    color: var(--success-text);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Content Section */
.section-card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    padding: 2rem;
    margin-bottom: 2rem;
}

.card-header h2,
.chart-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
    color: var(--text-primary);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
    /* Removed min-height as baseline alignment should suffice */
}

/* Minimal Table */
.min-table {
    width: 100%;
    border-collapse: collapse;
}

.min-table th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: 500;
    padding-bottom: 0.3rem;
    /* Reduced from 1rem default or previous override */
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.min-table td {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    color: var(--text-primary);
}

.min-table tr:last-child td {
    border-bottom: none;
}

/* Portfolio Layout Styles */
.portfolio-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.portfolio-chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
    flex-shrink: 0;
}

.portfolio-table-wrapper {
    width: 100%;
    overflow-y: auto;
    /* Mobile: ~6 rows (approx 350px) */
    max-height: 350px;
    border-top: 1px solid var(--border);
    /* Visual separator on mobile */
    /* Removed padding-top here to prevent content scrolling 'above' the sticky header in the padding box */
}

/* Specific table adjustments for portfolio and currency */
/* Specific table adjustments for portfolio and currency */
#portfolioTable th,
#currencyTable th,
#recentInvestmentsTable th,
#transactionsTable th,
#capitalCallsTable th {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 20;
    /* box-shadow: 0 1px 0 var(--border); */
    vertical-align: middle;
    padding: 0.15rem 0;
    line-height: 1.2;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

#portfolioTable td,
#currencyTable td,
#recentInvestmentsTable td,
#transactionsTable td,
#capitalCallsTable td {
    padding: 0.75rem 0;
    /* Slightly tighter than 1rem but looser than 0.5rem */
    font-size: 0.85rem;
    /* Unified font size */
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

/* Align right columns */
#portfolioTable th:last-child,
#portfolioTable td:last-child,
#currencyTable th:last-child,
#currencyTable td:last-child,
#recentInvestmentsTable th:last-child,
#recentInvestmentsTable td:last-child,
#transactionsTable th:last-child,
#transactionsTable td:last-child,
#capitalCallsTable th:last-child,
#capitalCallsTable td:last-child {
    text-align: right;
}

/* Date Column Layout - prevent wrapping */
#recentInvestmentsTable td:first-child,
#transactionsTable td:first-child {
    white-space: nowrap;
    width: 1%;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Remove last border */
#recentInvestmentsTable tr:last-child td,
#transactionsTable tr:last-child td {
    border-bottom: none;
}

/* Spacing between columns */
#recentInvestmentsTable th,
#recentInvestmentsTable td,
#transactionsTable th,
#transactionsTable td {
    padding-right: 1rem;
}

/* Asset Name Column */
.asset-name-cell {
    display: flex;
    align-items: center;
}

.asset-name-text {
    font-weight: 500;
    line-height: 1.2;
    /* Tighter line height for wrapped text */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    /* Limit to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    /* Allow wrapping */
}

/* Desktop Responsive Layout */
/* Desktop Responsive Layout */
@media (min-width: 900px) {
    .charts-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }

    .portfolio-container {
        display: flex;
        flex-direction: column;
        height: auto;
    }

    .portfolio-chart-wrapper {
        height: 300px;
        width: 100%;
        display: flex;
        justify-content: center;
        margin-bottom: 0.2rem;
    }

    .portfolio-table-wrapper {
        border-top: none;
        padding-top: 0;
        border-left: none;
        padding-left: 0;
        width: 100%;
        max-height: 250px;
        /* Increased to fit Currency table */
    }

    /* Larger fonts for Currency Allocation on Desktop */
    #currencyTable td:nth-child(1) .asset-name-text {
        font-size: 0.95rem;
    }

    #currencyTable td:nth-child(2) {
        font-size: 0.95rem;
    }
}

.currency-dot {
    height: 10px;
    width: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 10px;
}

/* Badge Styles for Transactions */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    line-height: 1;
}

.bg-blue {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.bg-green {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.bg-red {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.bg-gray {
    background: rgba(107, 114, 128, 0.1);
    color: #4b5563;
}

.bg-yellow {
    background: rgba(245, 158, 11, 0.1);
    color: #b45309;
}

.text-danger {
    color: #dc2626;
    font-weight: 600;
}

.text-success {
    color: #059669;
    font-weight: 600;
}

.font-monospace {
    font-family: 'SF Mono', 'Roboto Mono', monospace;
}

/* Specific Transaction Table Styling */
#transactionsTable th:last-child,
#transactionsTable td:last-child {
    text-align: right;
}

/* Recent Activity Layout and Table Spacing */
.recent-activity-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.capital-calls.section-card {
    margin-top: 2rem;
}

.recent-investments.section-card,
.recent-transactions.section-card {
    padding-bottom: 0.5rem;
}

.recent-investments .card-header,
.recent-transactions .card-header {
    margin-bottom: 2rem;
}

.recent-investments .table-container,
.recent-transactions .table-container {
    max-height: 280px;
    /* Approx 5 rows */
    overflow-y: auto;
}

#recentInvestmentsTable td,
#transactionsTable td {
    padding: 1rem 0.5rem;
    /* Increased vertical padding */
    border-bottom: 1px solid var(--border);
    /* Separator line */
}

#recentInvestmentsTable tr:last-child td,
#transactionsTable tr:last-child td {
    border-bottom: none;
}

@media (min-width: 900px) {
    .recent-activity-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
        align-items: start;
    }

    /* Ensure containers have same height if needed, or align top */
    .recent-investments,
    .recent-transactions {
        height: 100%;
    }
}

@media (max-width: 768px) {

    /* Summary Cards Carousel */
    .stats-grid {
        display: flex;
        overflow-x: auto;
        gap: 1rem;
        padding-bottom: 0.5rem;
        /* Space for hidden scrollbar */
        margin-right: -1rem;
        /* Extend to edge */
        margin-left: -1rem;
        /* Extend to edge */
        padding-left: 1rem;
        padding-right: 1rem;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        /* Firefox */
    }

    .stats-grid::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari */
    }

    .stat-card {
        min-width: 80%;
        scroll-snap-align: center;
        /* Ensure distinct cards */
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
        margin-bottom: 0.5rem;
        /* preserve shadow visibility */
    }

    .recent-transactions .table-container {
        padding: 0;
    }

    /* Transform Transactions Table to Card List on Mobile */
    #transactionsTable thead {
        display: none;
    }

    #transactionsTable tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "name amount"
            "date type";
        gap: 4px 12px;
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
    }

    #transactionsTable td {
        display: block;
        padding: 0;
        border: none;
        width: auto !important;
    }

    /* Map columns to grid areas */
    /* 1: Date, 2: Name, 3: Type, 4: Amount */

    #transactionsTable td:nth-child(2) {
        grid-area: name;
        font-weight: 600;
        font-size: 0.95rem;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #transactionsTable td:nth-child(4) {
        grid-area: amount;
        text-align: right;
        font-size: 0.95rem;
        font-weight: 600;
    }

    #transactionsTable td:nth-child(1) {
        grid-area: date;
        font-size: 0.8rem;
        color: var(--text-secondary);
        align-self: end;
    }

    #transactionsTable td:nth-child(3) {
        grid-area: type;
        text-align: right;
    }

    /* Adjust Badge size for mobile */
    #transactionsTable .badge {
        font-size: 0.7rem;
        padding: 2px 6px;
    }

    /* Transform Recent Investments Table to Card List */
    #recentInvestmentsTable thead {
        display: none;
    }

    #recentInvestmentsTable tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "name amount"
            "date platform";
        gap: 4px 12px;
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
    }

    #recentInvestmentsTable td {
        display: block;
        padding: 0;
        border: none;
        width: auto !important;
    }

    /* Map columns: 1: Date, 2: Name, 3: Platform, 4: Amount */
    #recentInvestmentsTable td:nth-child(2) {
        grid-area: name;
        font-weight: 600;
        font-size: 0.95rem;
        color: var(--text-primary);
    }

    #recentInvestmentsTable td:nth-child(4) {
        grid-area: amount;
        grid-area: amount;
        text-align: right;
        font-size: 0.95rem;
        font-weight: 600;
    }

    #recentInvestmentsTable td:nth-child(1) {
        grid-area: date;
        font-size: 0.8rem;
        color: var(--text-secondary);
    }

    #recentInvestmentsTable td:nth-child(3) {
        grid-area: platform;
        text-align: right;
        font-size: 0.8rem;
        color: var(--text-secondary);
    }

    /* Capital Calls Mobile Layout */
    #capitalCallsTable thead {
        display: none;
    }

    #capitalCallsTable tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        /* Name/Platform | Amounts */
        grid-template-areas:
            "name remaining"
            "platform committed"
            "platform invested";
        gap: 2px 12px;
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
    }

    #capitalCallsTable td {
        display: block;
        padding: 0;
        border: none;
        width: auto !important;
    }

    /* 1: Name, 2: Platform, 3: Committed, 4: Invested, 5: Remaining */

    #capitalCallsTable td:nth-child(1) {
        grid-area: name;
        font-weight: 600;
        font-size: 0.85rem;
        /* Reduced to prevent wrapping */
        color: var(--text-primary);
        word-break: break-word;
        /* Handle very long words safely */
    }

    #capitalCallsTable td:nth-child(5) {
        grid-area: remaining;
        text-align: right;
        font-weight: 600;
        font-size: 0.95rem;
        color: var(--text-primary);
        align-self: end;
        /* Fix for large gap when Name wraps */
        padding-bottom: 2px;
    }

    #capitalCallsTable td:nth-child(5)::before {
        content: "Rem: ";
        font-weight: 400;
        font-size: 0.8rem;
        color: var(--text-secondary);
    }

    #capitalCallsTable td:nth-child(2) {
        grid-area: platform;
        font-size: 0.85rem;
        color: var(--text-secondary);
        align-self: start;
        margin-top: 2px;
    }

    #capitalCallsTable td:nth-child(3) {
        grid-area: committed;
        text-align: right;
        font-size: 0.8rem;
        color: var(--text-secondary);
    }

    #capitalCallsTable td:nth-child(3)::before {
        content: "Comm: ";
    }

    #capitalCallsTable td:nth-child(4) {
        grid-area: invested;
        text-align: right;
        font-size: 0.8rem;
        color: var(--text-secondary);
    }

    #capitalCallsTable td:nth-child(4)::before {
        content: "Inv: ";
    }
}

/* Investments Page Specifics - Filter Bar Polish */
.filters-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.5rem 0 1rem 0;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
    align-items: center;
}

/* Search Group styling */
.search-group {
    position: relative;
    flex: 1;
    min-width: 250px;
    display: flex;
    align-items: center;
}

.search-group .input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-tertiary, #94a3b8);
    pointer-events: none;
    z-index: 10;
    font-size: 0.95rem;
    display: flex;
}

.search-group input.form-control {
    width: 100%;
    height: 42px;
    /* Slightly taller for modern feel */
    padding-left: 2.8rem;
    /* Space for icon */
    padding-right: 1rem;
    background: #f8fafc;
    /* Very light grey, almost white */
    border: 1px solid var(--border);
    /* Subtle border */
    border-radius: 8px;
    /* Consistent radius */
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    font-family: inherit;
}

.search-group input.form-control:focus {
    outline: none;
    background: #ffffff;
    border-color: var(--accent, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-group input.form-control::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Filter Group styling */
.filter-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Custom Select styling */
.form-select {
    height: 42px;
    padding: 0 2.5rem 0 1rem;
    background-color: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    min-width: 140px;
    transition: all 0.2s ease;

    /* Custom Arrow - Darker grey for visibility */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 10px;
}

.form-select:hover {
    background-color: #f1f5f9;
    /* Slightly darker hover */
    border-color: var(--text-secondary);
}

.form-select:focus {
    outline: none;
    background-color: #ffffff;
    border-color: var(--accent, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Optional: Group filters on mobile */
@media (max-width: 768px) {

    /* Filters Mobile Optimization */
    .filters-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .filter-group {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .form-select,
    .search-group input.form-control,
    #clearFiltersBtn {
        width: 100%;
        min-width: 0;
    }

    #clearFiltersBtn {
        margin-top: 0.5rem;
    }

    /* Table Mobile Card View */
    .table-container {
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }

    #investmentsTable,
    #investmentsTable tbody,
    #investmentsTable tr,
    #investmentsTable td {
        display: block;
        width: 100%;
    }

    #investmentsTable thead {
        display: none;
        /* Hide standard headers */
    }

    #investmentsTable tr {
        background: var(--card-bg);
        border: 1px solid var(--border);
        border-radius: 12px;
        margin-bottom: 1rem;
        padding: 1rem;
        position: relative;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    #investmentsTable td {
        padding: 0.25rem 0;
        border: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
    }

    /* First column (Name) specific adjustment */
    #investmentsTable td:first-child {
        margin-bottom: 0.5rem;
        padding-bottom: 1rem;
        border-bottom: 1px solid var(--border);
    }

    /* Label pseudo-elements for mobile context */
    #investmentsTable td:nth-child(2)::before {
        content: "Type";
        font-size: 0.8rem;
        color: var(--text-secondary);
    }

    #investmentsTable td:nth-child(3)::before {
        content: "Status";
        font-size: 0.8rem;
        color: var(--text-secondary);
    }

    #investmentsTable td:nth-child(4)::before {
        content: "Invested";
        font-size: 0.8rem;
        color: var(--text-secondary);
    }

    #investmentsTable td:nth-child(5)::before {
        content: "Current Value";
        font-size: 0.8rem;
        color: var(--text-secondary);
    }

    #investmentsTable td:nth-child(6)::before {
        content: "ROI";
        font-size: 0.8rem;
        color: var(--text-secondary);
    }

    /* Hide empty pseudo-elements if cell is empty/special key */

    /* Adjust alignment for values */
    #investmentsTable td:nth-child(4),
    #investmentsTable td:nth-child(5),
    #investmentsTable td:nth-child(6) {
        text-align: right;
    }
}