/* ==========================================================================
   FORCE OVERRIDE: RADIO BUTTONS
   ========================================================================== */
.custom-radio input[type="radio"] {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    position: absolute !important;
    z-index: -999 !important;
}

.custom-radio {
    display: inline-flex !important;
    align-items: center !important;
    cursor: pointer !important;
    margin-right: 20px !important;
    position: relative !important;
    user-select: none !important;
}

.custom-radio .radio-label-text {
    display: flex !important;
    align-items: center !important;
    font-size: 1rem !important;
    color: #333 !important;
}

.custom-radio .radio-label-text::before {
    content: "" !important;
    display: block !important;
    width: 20px !important;
    height: 20px !important;
    margin-right: 10px !important;
    border: 2px solid #ccc !important;
    border-radius: 50% !important;
    background-color: #fff !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    transition: all 0.2s ease !important;
}

.custom-radio input[type="radio"]:checked + .radio-label-text::before {
    border-color: #0d6efd !important;
    background-color: #0d6efd !important;
    box-shadow: inset 0 0 0 4px #fff !important;
}

/* =========================================
   MOBILE RESPONSIVE CARD TABLE CSS (FIXED)
   ========================================= */
@media screen and (max-width: 768px) {

    /* 1. Kill the scroll container */
    .table-responsive {
        overflow: visible !important;
        display: block !important;
    }

    /* 2. Force Table Elements to act as Blocks */
    table,
    table tbody,
    table tr,
    table td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 3. Hide the Header Row completely */
    table thead {
        display: none !important;
    }

    /* 4. Card Styling for Rows */
    table tr.etf-row-card,
    table tr.cash-row-card,
    table tr.summary-row-card {
        position: relative;
        background: #fff;
        margin-bottom: 20px;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        border: 1px solid #eef2f7;
        padding: 15px;
        clear: both;
    }

    /* 5. Cell Styling (Flex rows inside the card) */
    table td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        border-bottom: 1px solid #f3f6f9;
        text-align: right;
        min-height: 40px;
    }

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

    /* 6. Inject Labels via data-label attribute */
    table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #6c757d;
        font-size: 0.9rem;
        text-align: left;
        margin-right: auto; /* Pushes value to right */
    }

    /* --- SPECIAL ELEMENTS STYLING --- */

    /* Name (Top of Card) */
    table td.name-cell {
        display: block !important;
        text-align: left;
        padding-right: 40px; /* Space for X button */
        border-bottom: 2px solid #eef2f7;
        margin-bottom: 10px;
        padding-bottom: 10px;
    }
    table td.name-cell::before { display: none; }

    /* Remove Button (Positioned Absolute Top-Right) */
    table td.action-cell {
        position: absolute !important;
        top: 10px;
        right: 10px;
        border: none;
        padding: 0;
        width: auto !important;
        background: transparent;
    }
    table td.action-cell::before { display: none; }

    /* Chart (Centered) */
    table td.chart-cell {
        justify-content: center;
        background: #f8f9fa;
        border-radius: 8px;
        margin: 10px 0;
    }
    table td.chart-cell::before { display: none; }

    /* Inputs (Amount/Weight) */
    table input.amount-input,
    table input.weight-input {
        width: 120px !important;
        max-width: 50%;
        text-align: right;
        padding: 8px;
        border: 1px solid #dfe3e7;
        border-radius: 6px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    /* Helper: Hide empty cells on mobile */
    .mobile-hide { display: none !important; }

    /* --- ROW COLORS --- */
    table tr.cash-row-card {
        background: #fffbef;
        border: 1px solid #ffeeba;
    }

    table tr.summary-row-card {
        color: black;
    }
    table tr.summary-row-card td {
        border-bottom: 1px solid rgba(255,255,255,0.2);
    }
    table tr.summary-row-card td::before {
        color: #aab6d3;
    }
}
/* Mobile Optimization: Hide Table Headers */
@media screen and (max-width: 768px) {
    /* Target the table by its class '.data-table' */

    /* 1. Hide the first row (which contains the headers) */
    .data-table tr:first-child {
        display: none !important;
    }

    /* 2. Safety measure: Hide all 'th' elements inside the table on mobile */
    .data-table th {
        display: none !important;
    }
}
/* =========================================
   MOBILE RESPONSIVE KPI CARDS FIX
   ========================================= */
@media screen and (max-width: 768px) {

    /* 1. Fix the container */
    .kpi-circles-row {
        display: flex !important;
        flex-wrap: nowrap !important; /* Keep in one row if possible, or use 'wrap' to stack */
        justify-content: space-between !important; /* Spread them out evenly */
        width: 100% !important;
        gap: 8px !important; /* Small gap between items */
        padding: 0 5px !important; /* Prevent touching screen edges */
        box-sizing: border-box !important;
        overflow-x: hidden !important; /* Prevent page scroll triggers */
    }

    /* 2. Transform Circles into Responsive Cards */
    .kpi-circle {
        width: 32% !important; /* Force 3 items to fit (approx 33% each) */
        min-width: 0 !important; /* Allow shrinking below content size if needed */
        height: auto !important; /* Remove fixed height */
        aspect-ratio: auto !important; /* Remove forced circle shape */
        border-radius: 12px !important; /* Rounded rectangle instead of perfect circle */
        padding: 15px 2px !important; /* Vertical padding good, horizontal tight */
        margin: 0 !important; /* Remove any default margins */
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
    }

    /* 3. Resize Text for Mobile */
    .kpi-value {
        font-size: 1.1rem !important; /* Slightly smaller numbers */
        margin-bottom: 4px !important;
    }

    .kpi-label {
        font-size: 0.75rem !important; /* Smaller label text */
        line-height: 1.1 !important;
        white-space: normal !important; /* Allow text to wrap (e.g. "Return\n1 year") */
        text-align: center !important;
    }
}
.optimizer-upgrade-btn{
    font-size: 1rem !important;
}
/* =========================================
   PORTFOLIO TOOLBAR (DESKTOP & MOBILE)
   ========================================= */

/* 1. Main Container */
.portfolio-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

/* 2. Button Group Wrapper */
.toolbar-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap; /* Allow wrapping */
    width: auto;
}

/* 3. Button Styles - Make them responsive */
.action-btn {
    padding: 8px 16px;
    border-radius: 6px; /* Slightly rounder looks better on mobile */
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;

    /* DESKTOP DEFAULT: No flex grow */
    flex-grow: 0;
}

/* Colors */
.reset-btn {
    background-color: #fff7ed;
    color: #c2410c;
    border: 1px solid #ffedd5;
}
.save-btn, .eq-weight-btn {
    background-color: #2e7d32;
    color: white;
}
.shares-label {
    color: #888;
    font-size: 0.85rem;
}

/* =========================================
   MOBILE SPECIFIC TWEAKS (Max Width 768px)
   ========================================= */
@media screen and (max-width: 768px) {

    /* Stack the buttons area and the "Shares in %" label vertically */
    .portfolio-toolbar {
        flex-direction: column;
        align-items: stretch; /* Stretch container to full width */
        gap: 10px;
    }

    /* Make the button container fill the width */
    .toolbar-buttons {
        width: 100%;
        justify-content: space-between;
    }

    /* KEY FIX: Make buttons stretch to fill gaps */
    .action-btn {
        flex-grow: 1; /* Buttons will expand to fill the row */
        flex-basis: 30%; /* Start at ~30% width, grow from there */
        font-size: 0.85rem; /* Slightly smaller font to fit text */
        padding: 0 10px;
    }

    /* Adjust the "Shares in %" label position */
    .shares-label {
        text-align: right; /* Align to right */
        width: 100%;
        margin-top: -5px; /* Pull it up a bit closer */
        font-size: 0.75rem;
    }
}
/* Existing Button Styles */
.optimizer-upgrade-btn {
    width: 100%;
    padding: 12px;
    background-color: #3E6ED4;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    margin-bottom: 12px;
    transition: background 0.3s ease;
}

.optimizer-upgrade-btn:hover {
    background-color: #2b52a3;
}

/* NEW: Tutorial Link Style */
.optimizer-tutorial-btn {
    width: 100%;
    padding: 10px;
    background-color: transparent;
    color: #64748b; /* Slate Gray */
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;

    /* Flexbox for centering content and icon */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    text-decoration: none !important; /* Removes link underline */
    transition: all 0.3s ease;
    cursor: pointer;
}

.optimizer-tutorial-btn:hover {
    background-color: #f8fafc; /* Very light gray */
    color: #3E6ED4; /* Text turns blue */
    border-color: #3E6ED4; /* Border turns blue */
}

.optimizer-tutorial-btn i {
    font-size: 14px;
    color: inherit; /* Icon takes text color */
}


