@using System.Globalization
@using System.Drawing

<style>

/**********
    MAIN
***********/
.fr-@WebReport.ID-container {

    width: @Width;
    height: @Height;
    background-color: white;
    display: @Inline;
    flex-direction: @WebReport.Toolbar.Vertical;
    position: relative;
}

.fr-@WebReport.ID-container * {
    box-sizing: content-box;
    -moz-box-sizing: content-box;
}

/*************
    TOOLBAR
**************/
.fr-@WebReport.ID-toolbar {
    background-color: @ColorTranslator.ToHtml(WebReport.Toolbar.Color);
    display: flex;
    -moz-animation: flex;
    font: @WebReport.Toolbar.UserFontSettings;
    flex-direction: @WebReport.Toolbar.RowOrColumn;
    width: auto;
    height: @(WebReport.Toolbar.VerticalToolbarHeight)px;
    order: @WebReport.Toolbar.TopOrBottom;
    position: relative;
    align-items: center;
    justify-content: @WebReport.Toolbar.Content;
    z-index: 2;
    border-radius: @(WebReport.Toolbar.ToolbarRoundness)px;
    @(WebReport.Tabs.Count > 1 ? "" : "box-shadow: 0px 3px 4px -2px rgba(0, 0, 0, 0.2)")
}

.fr-@WebReport.ID-toolbar-item {
    height: @ToolbarHeight;
    border-radius:@(WebReport.Toolbar.ToolbarRoundness)px;
    position: relative;
}

.fr-@WebReport.ID-toolbar-item:hover {
    background-color: @ColorTranslator.ToHtml(WebReport.Toolbar.Color);
}

.fr-@WebReport.ID-toolbar-item > img {
    height: @CalculateToolBarHeight(0.7f);
    padding-top: @CalculateToolBarHeight(0.15f);
    padding-bottom: @CalculateToolBarHeight(0.15f);
    padding-left: @CalculateToolBarHeight(0.25f);
    padding-right: @CalculateToolBarHeight(0.25f);
    opacity: @WebReport.Toolbar.TransparencyIcon;
    filter:invert(@WebReport.Toolbar.ColorIcon);
    display: block;
}

.fr-@WebReport.ID-toolbar-item:hover > img {
    opacity: 1;
}

/**********************
    TOOLBAR DROPDOWN
***********************/
.fr-@WebReport.ID-toolbar-dropdown-content {
    display: none;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    background-color: @ColorTranslator.ToHtml(WebReport.Toolbar.DropDownMenuColor);
    color:@ColorTranslator.ToHtml(WebReport.Toolbar.DropDownMenuTextColor);
    min-width: 120px;
    z-index: 2;
    position: absolute;
    @WebReport.Toolbar.DropDownMenuPosition;
    white-space: nowrap;
}

.fr-@WebReport.ID-toolbar-item:hover > .fr-@WebReport.ID-toolbar-dropdown-content {
    display: block;
}

.fr-@WebReport.ID-toolbar-dropdown-content > a {
    float: none;
    color: @ColorTranslator.ToHtml(WebReport.Toolbar.DropDownMenuTextColor);
    padding: 6px 12px 6px 8px;
    text-decoration: none;
    display: block;
    z-index:3;
    text-align: left;
    height: auto;
    font-size: 14px;
    user-select: none;
}
.fr-@WebReport.ID-toolbar-dropdown-content > a:hover {
    color: @ColorTranslator.ToHtml(WebReport.Toolbar.DropDownMenuTextColor);
    background-color: @ColorTranslator.ToHtml(WebReport.Toolbar.DropDownMenuColor);
    opacity: 0.4;
    z-index: 3;
    cursor: pointer;
}
.fr-webreport-toolbar-narrow > img {
    transform: rotate(@(WebReport.Toolbar.ToolbarNarrow)deg);
    padding-left: 0px;
    padding-right: 0px;
}

.fr-webreport-toolbar-notbutton:hover {
    background-color: transparent;
}

.fr-webreport-toolbar-notbutton:hover > img {
    opacity: 0.5;
}

.fr-webreport-zoom-selected {
    width: 14px;
    color:@ColorTranslator.ToHtml(WebReport.Toolbar.DropDownMenuTextColor);
    opacity: 0.6;
    display: inline-block;
    font-size: 14px;
}
.fr-webreport-settings-btn {
    background-color: transparent;
    color: transparent;
    padding-left: 1rem;
    margin-left: 230px;
    display: flex;
    float: right;
    margin-top: -1.6rem;
    outline: none;
    padding-right: 1rem;
    border: none;
    position: relative;
    z-index: 4;
    flex-direction: row;
    align-content: space-around;
    justify-content: space-between;
    opacity:0.5;
}
.fr-webreport-settings-btn:hover {
    background-color: transparent;
    color: transparent;
    padding-left: 1rem;
    margin-left: 230px;
    display: flex;
    float: right;
    margin-top: -1.6rem;
    outline: none;
    padding-right: 1rem;
    border: none;
    position: relative;
    z-index: 4;
    flex-direction: row;
    align-content: space-around;
    justify-content: space-between;
    transform: scale(1.1);
    opacity:0.8;
}
.fr-webreport-settings-btn::-moz-focus-inner {
    background-color: transparent;
    color: transparent;
    padding-left: 1rem;
    margin-left: 230px;
    display: flex;
    float: right;
    margin-top: -1.6rem;
    outline: none;
    padding-right: 1rem;
    border: none;
    position: relative;
    z-index: 4;
    flex-direction: row;
    align-content: space-around;
    justify-content: space-between;
}
 /************************
         POPUP
*************************/
.fr-webreport-popup {
    min-width: 100%;
    position: absolute;
    min-height: 100%;
    z-index: 3;
    padding-bottom: 1rem;
    background-color: #0000005c;
    display: flex;
    align-content: flex-start;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: flex-start;
}

.fr-webreport-popup-content {
    display: flex;
    width: fit-content;
    height: fit-content;
    margin-top: 2.5rem;
    margin-left: 2.6rem;
    padding: 0px 10px 50px 10px;
    z-index: 4;
    border-radius: 10px;
    background-color: white;
    flex-wrap: nowrap;
    align-content: center;
    justify-content: center;
    align-items: center;
    flex-direction: column;

}

.fr-webreport-popup-content-title {
    display: flex;
    width: 100%;
    background-color: @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color);
    color: @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.FontColor);
    height: 2rem;
    margin: 0;
    border: 1px solid @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color);
    border-radius: 1px 1px 0px 0px;
    margin-bottom: 10px;
    box-shadow: -0.1rem -0.6rem 0rem 0.6rem @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color);
    align-items: center;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-content: center;
    font: @WebReport.Toolbar.Exports.UserFontSettingsStyle 16px @WebReport.Toolbar.Exports.UserFontSettingsFamily;
}
.fr-webreport-popup-content-title input {
    background-color: white;
    border: 3px solid @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color);
    color: black;
    max-height: 9.8px;
    border-radius: 3px;
}
.fr-webreport-popup-content-export-parameters {
    display: flex;
    width: 100%;
    -ms-flex-wrap: wrap;
    flex-direction: column;
    border-bottom: 2px solid #00000024;
    border-radius: 3px;
    padding-bottom: 1rem;
    /*padding-top: 1rem;*/
    align-content: flex-start;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    font: @WebReport.Toolbar.Exports.UserFontSettingsStyle 12px @WebReport.Toolbar.Exports.UserFontSettingsFamily;
}

.fr-webreport-popup-content-export-parameters-col {
    display: flex;
    align-content: center;
    flex-wrap: nowrap;
    flex-direction: column;
    font: @WebReport.Toolbar.Exports.UserFontSettingsStyle 11px @WebReport.Toolbar.Exports.UserFontSettingsFamily;
}
.custom-select{
    width:auto;
    outline: none;
    min-width: 40px;
    padding-left:3px;
    padding-right: 3px;
    appearance: none;
    margin: 0px 5px 0px 5px;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 2px solid @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color);
    border-radius: 3px;
    height: 1.5rem;
    font: @WebReport.Toolbar.Exports.UserFontSettingsStyle 11px @WebReport.Toolbar.Exports.UserFontSettingsFamily;
}
.fr-webreport-popup-content-export-parameters-input {
    margin-left: 0.3rem;
    margin-bottom: 0.3rem;
    padding: 6px;
    outline: none;
    border: none;
    margin-left: 5px;
    margin-right: 5px;
    min-width: inherit;
    border-radius: 3px;
    border: 2px solid @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color);
    font: @WebReport.Toolbar.Exports.UserFontSettingsStyle 10px @WebReport.Toolbar.Exports.UserFontSettingsFamily;

}
.fr-webreport-popup-content-export-parameters-row {
    display: flex;
    padding-top: 5px;
    flex-direction: row;
    align-items: flex-start;

}
.fr-webreport-popup-content-export-parameters-slider {
    display: flex;
    margin-bottom: 10px;
    margin-top: 10px;
    margin-left: 5px;
    background-color: transparent;
    border-radius: 10px;
    border-radius: 3px;
    justify-content: center;
    align-items: center;
    align-content: center;
    flex-direction: row;

}
.fr-webreport-popup-content-export-parameters-slider span {
    color: black;
    background-color: transparent;
    min-width: 128px;
    padding: 5px;
    white-space: nowrap;
    font:@(WebReport.Toolbar.Exports.UserFontSettingsStyle)  11px  @(WebReport.Toolbar.Exports.UserFontSettingsFamily);
}
input[type=range] {
    height: 1.7rem;
    overflow: hidden;
    -webkit-appearance: none;
    margin-left: 0;
    outline: none;
    background-color: #424242;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 100%;
    cursor: pointer;
    animate: 0.2s;
    background: #424242;
    border-radius: 0px;
}
    input[type=range]::-webkit-slider-thumb {
        height: 100%;
        width: 5%;
        border-radius: 0px;
        background: linear-gradient(gray,5%, @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color) );
        cursor: pointer;
        -webkit-appearance: none;
        box-shadow: -100vw 0vw 0vw 100vw @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color);
        margin-top: 0px;
    }
label{
    margin-bottom: 5px;
    margin-top: 5px;

}
.fr-webreport-popup-content-export-parameters-col input[type="text"] {
    background-color: white;
    color: #000000;
    border: 2px solid @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color);
    max-height: 11px;
}
.fr-webreport-popup-content-export-parameters-button {
    margin-left: 0.3rem;
    margin-bottom: 0.3rem;
    padding: 6px;
    outline: none;
    background-color: #ffffff00;
    border: none;
    margin-left: 5px;
    height: 0.8rem;
    margin-right: 5px;
    min-width: inherit;
    color: @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color);
    border-radius: 3px;
    border: 2px solid @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color);
    font: @(WebReport.Toolbar.Exports.UserFontSettingsStyle)  11px  @(WebReport.Toolbar.Exports.UserFontSettingsFamily);
}

.fr-webreport-popup-content-buttons {
    display: flex;
    padding-top: 1rem;
    margin-bottom: -1.9rem;
    width: 100%;
    flex-wrap: nowrap;
    align-content: center;
    justify-content: space-around;
    align-items: center;
    flex-direction: row;
}

.fr-webreport-popup-content-btn-submit {
    outline: none;
    border: none;
    background-color: @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color);
    border-radius: 3px;
    width: 100px;
    padding: 3px;
    font-weight: normal;
    color: @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.FontColor);
    font: @WebReport.Toolbar.Exports.UserFontSettingsStyle 14px @WebReport.Toolbar.Exports.UserFontSettingsFamily;
}
.fr-webreport-popup-content-btn-submit:hover {
    transform: scale(1.015);
}
.fr-@WebReport.ID-container .active:hover {
    transform: scale(1.015);
}
.fr-@WebReport.ID-container .active {
    background-color: @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.Color);
    color: @ColorTranslator.ToHtml(WebReport.Toolbar.Exports.FontColor);
}
.fr-webreport-popup-content-export-parameters-button:hover {
    transform:scale(1.015);
}

/************************
    TOOLBAR NAVIGATION
*************************/
.fr-@WebReport.ID-toolbar-slash{
    height: @CalculateToolBarHeight(0.68f);
}
.fr-@WebReport.ID-toolbar-slash > img {
    transform: rotate(@(WebReport.Toolbar.ToolbarSlash)deg);
    height: @CalculateToolBarHeight(0.44f);
    padding-left: 3px;
    padding-right: 3px;
}

.fr-@WebReport.ID-toolbar-item > input {
    font-family: Arial,sans-serif;
    font-size: @CalculateToolBarHeight(0.35f);
    text-align: center;
    border: 0;
    background: #fbfbfb;
    border-radius: 4px;
    height: @CalculateToolBarHeight(0.68f);
    width: 2.5em;
    margin-top: @CalculateToolBarHeight(0.17f);
    margin-bottom: @CalculateToolBarHeight(0.15f);
    margin-left: @CalculateToolBarHeight(0.1f);
    margin-right: @CalculateToolBarHeight(0.1f);
    padding: 0;
    display: block;
}

.fr-@WebReport.ID-toolbar-item > input:hover:not([readonly]) {
    background: #fff;
}

.fr-@WebReport.ID-toolbar-item > input[readonly] {
    cursor: default;
}
/***********
    TABS
***********/

.fr-webreport-tabs {
     flex-shrink: 0;
     font-family: Verdana,Arial,sans-serif;
     background-color: #f1f1f1;
     display: table;
     width: @WebReport.Toolbar.TabsPositionSettings;
     max-width: @(WebReport.ReportMaxWidth)px;
     box-shadow: 0px 3px 4px -2px rgba(0, 0, 0, 0.2);
     position: relative;
     z-index: 1;
     @WebReport.Toolbar.TabsPositionSettings
 }

 /***********
    MISC
***********/
input[type="date"]::-webkit-calendar-picker-indicator{
    opacity: 0;
}
.datetimepicker > input[type="date"]{
    background: url(_content/FastReport.Web/Resources/date-picker.svg) no-repeat;
    background-size: 10px;
    background-position: right 5px center;
    background-origin: content-box, content-box;
}
.datetimepicker > input[type="date"]:disabled {
    background: url("") no-repeat;
}
</style>


@code {

    [Parameter]
    public WebReport WebReport { get; set; }


    protected override void OnParametersSet()
    {
        ToolbarHeight = WebReport.Toolbar.Height.ToString() + "px";
    }

    //protected override bool ShouldRender() => false;

    private string Width
    {
        get
        {
            if (!WebReport.Width.IsNullOrWhiteSpace())
                return WebReport.Width + "px";
            return string.Empty;
        }
    }

    private string Height
    {
        get
        {
            if (!WebReport.Height.IsNullOrWhiteSpace())
                return WebReport.Height + "px";
            return string.Empty;
        }
    }

    private string Inline
    {
        get
        {
            if (WebReport.Inline)
                return "inline-flex";
            return "flex";
        }
    }

    private string ToolbarHeight
    {
        get;
        set;
    }

    private string CalculateToolBarHeight(float variable)
    {
        var calculatedHeight = WebReport.Toolbar.Height * variable;
        return $"{calculatedHeight.ToString("0.##", CultureInfo.InvariantCulture)}px";
    } 

}