@import '~@equitysim/react-uikit/dist/styles/styleguide';

$row-max-width-mobile: v-space(68);
$row-max-width-mobile-cash: 74rem;
$row-max-width-mobile-option: 104rem;
$id-width: v-space(26);

%portfolio-holdings-row {
    padding: 0 0 0 $container-padding-h;
    width: $container-max-width;
    height: v-space(8);
    font-size: 1.4rem;

    @media screen and (max-width: 560px) {
        padding-left: $container-padding-mobile;
    }
    @media screen and (max-width: 420px) {
        width: $row-max-width-mobile;
    }
}

@mixin portfolio-holdings-row-mobile($parent) {
    // Placeholders don't work without some base property so `color:inherit` style definition is a nothing
    // rule to force it to use the media query
    color: inherit;

    @media screen and (max-width: 560px) {
        #{$parent}__id {
            width: $id-width / 2;
        }

        #{$parent}__icon,
        #{$parent}__market-value,
        #{$parent}__position {
            display: none;
        }
    }
}

// Stock Holdings Grid
// 1. Identifier, Position, Current Price, Daily Change, Quantity, Market Value, Profit/Loss, Icon
%portfolio-holdings-stock-grid {
    $gap-size: v-space(2);
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: v-space(26) // Identifier
        0.5fr // Position
        0.5fr // Weight
        0.6fr // Daily Change
        1fr // Market Value
        1fr // Profit/Loss
        v-space(9) // Trade Button
        ($container-padding-h - $gap-size); // Icon
    grid-gap: $gap-size;
    align-items: center;

    @extend %portfolio-holdings-grid-mobile;
}

%portfolio-holdings-stock-grid--public {
    @extend %portfolio-holdings-stock-grid;
    grid-template-columns: v-space(26) // Identifier
        0.5fr // Position
        0.5fr // Weight
        0.6fr // Daily Change
        1fr // Market Value
        1fr; // Profit/Loss
    padding-right: $container-padding-h;

    @media screen and (max-width: $screen-small) {
        grid-template-columns: v-space(26) // Identifier
            0.5fr // Weight
            0.6fr // Daily Change
            0.6fr; // Profit/Loss
    }
}

// Bond Holdings Grid
// 1. Identifier, Position, Current Price, Daily Change, Quantity, Market Value, Profit/Loss, Trade Icon, Icon
%portfolio-holdings-bond-grid {
    $gap-size: v-space(2);
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: v-space(26) // Identifier
        0.5fr // Position
        0.5fr // Weight
        0.6fr // Daily Change
        1fr // Market Value
        1fr // Profit/Loss
        v-space(9) // Trade Button
        ($container-padding-h - $gap-size); // Icon
    grid-gap: $gap-size;
    align-items: center;

    @extend %portfolio-holdings-grid-mobile;
}

%portfolio-holdings-bond-grid--public {
    @extend %portfolio-holdings-bond-grid;
    $gap-size: v-space(2);
    grid-template-columns: v-space(26) // Identifier
        0.5fr // Position
        0.5fr // Weight
        0.6fr // Daily Change
        1fr // Market Value
        1fr; // Profit/Loss
    padding-right: $container-padding-h;
}

// Option Holdings Grid
// 1. Contract, Position, Current Price, Daily Change, Quantity, Underlying Price/Strike Price, Exercise Icon, Trade Icon, Icon
%portfolio-holdings-option-grid {
    $gap-size: v-space(2);
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: v-space(13) // Contract
        v-space(8) // Position
        0.5fr // Weight
        0.6fr // Daily Change
        1.1fr // Market Value
        0.7fr // Underlying/Strike
        0.8fr // Profit/Loss
        v-space(10) // Exercise Button
        v-space(8) // Trade Button
        ($container-padding-h - $gap-size); // Icon
    grid-gap: $gap-size;
    align-items: center;

    @media screen and (max-width: $screen-small) {
        grid-template-columns: v-space(13) // Identifier
            0.5fr // Weight
            0.5fr // Daily Change
            0.6fr // Underlying/Strike
            1fr // Profit/Loss
            v-space(10) // Exercise Button
            v-space(10); // Trade Button
    }
}

%portfolio-holdings-option-grid--public {
    @extend %portfolio-holdings-option-grid;
    $gap-size: v-space(2);
    grid-template-columns: v-space(13) // Contract
        v-space(8) // Position
        0.6fr // Weight
        v-space(15) // Daily Change
        1.1fr // Market Value
        0.7fr // Underlying/Strike
        0.8fr; // Profit/Loss
    padding-right: $container-padding-h;
}

// Cash Holdings Grid
// 1. Currency, Amount, Exchange Button, Icon
%portfolio-holdings-cash-grid {
    $gap-size: v-space(2);
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: v-space(20) // Currency
        v-space(16) // Weight
        1fr // Amount
        v-space(16); // Exchange Button
    grid-gap: $gap-size;
    align-items: center;
    padding-right: $container-padding-h;

    @media screen and (max-width: $screen-small) {
        grid-template-columns: v-space(14) // Currency
            0.6fr // Weight
            1.4fr // Amount
            v-space(14); // Exchange Button
    }
}

%portfolio-holdings-cash-grid--public {
    @extend %portfolio-holdings-cash-grid;
    $gap-size: v-space(2);
    grid-template-columns: v-space(20) // Currency
        v-space(16) // Weight
        1fr; // Amount
}

%portfolio-holdings-row__icon {
    justify-self: end;
    margin-right: v-space(3);
    height: 1rem;
    width: 1rem;
    color: $seafoam;
    transition: transform $animation-duration;
}

%portfolio-holdings-grid-mobile {
    color: inherit;

    @media screen and (max-width: $screen-small) {
        grid-template-columns: v-space(13) // Identifier
            0.6fr // Weight
            0.5fr // Daily Change
            1fr // Profit/Loss
            v-space(10); // Trade Button
    }
}
