///
/// This file regroups the frontend general design rules and portal design
/// rules.
///

// ======  Variables =========
$-navbar-height: $nav-link-height !default;

// Portal toolbar (filters, search bar)
$o-portal-mobile-toolbar: true; // Enable/Disable custom design
$o-portal-mobile-toolbar-border: $border-color;
$o-portal-mobile-toolbar-bg: $gray-200;

// Portal Tables
$o-portal-table-th-pt: map-get($spacers, 2) !default; // bts4 pt-2
$o-portal-table-th-pb: map-get($spacers, 2) !default; // bts4 pb-2
$o-portal-table-td-pt: map-get($spacers, 1) !default; // bts4 pt-1
$o-portal-table-td-pb: map-get($spacers, 1) !default; // bts4 pb-1

// Portal custom bg color
$o-portal-bg-color: desaturate($gray-200, 100%);

// Check if portal uses default colors
$o-portal-use-default-colors: $body-bg == $white;

// Frontend general
body {
    // Set frontend direction that will be flipped with
    // rtlcss for right-to-left text direction.
    direction: ltr;
}

#wrapwrap {
    position: relative;
    display: flex;
    flex-flow: column nowrap;
    width: 100%;
    min-height: 100%;

    > * {
        flex: 0 0 auto;
    }
    > main {
        flex: 1 0 auto;
    }
}

header {
    .navbar-brand {
        flex: 0 0 auto;

        &.logo {
            padding-top: 0;
            padding-bottom: 0;

            img {
                width: auto;
                height: $-navbar-height;
                max-width: none;
            }
        }
    }
    .nav-link {
        white-space: nowrap;
    }
}
.navbar {
    margin-bottom: 0;

    ul.nav > li {
        &.divider {
            display: none;
            height: $-navbar-height;
            border-right: 1px solid $nav-divider-color;
        }

        &.active + .divider {
            visibility: hidden;
        }
    }
    .nav.navbar-nav.float-right {
        @include media-breakpoint-down(sm) {
            float: none!important;
        }
    }
}
@include media-breakpoint-up(md) {
    .navbar-expand-md ul.nav > li.divider {
        display: list-item;
    }
}
ul.flex-column > li > a {
    padding: 2px 15px;
}

// Odoo options classes
.jumbotron {
    margin-bottom: 0;
}

// Typography
ul {
    list-style-type: disc;
}
li > ul {
    list-style-type: circle;
}
li > * > li > ul {
    list-style-type: square;
}
li > * > li > * > li > ul {
    list-style-type: disc;
}
li > * > li > * > li > * > li > ul {
    list-style-type: circle;
}
li > * > li > * > li > * > li > * > li > ul {
    list-style-type: square;
}
li > * > li > * > li > * > li > * > li > * > li > ul {
    list-style-type: disc;
}
ol {
    list-style-type: decimal;
}
li > ol {
    list-style-type: lower-alpha;
}
li > * > li > ol {
    list-style-type: lower-greek;
}
li > * > li > * > li > ol {
    list-style-type: decimal;
}
li > * > li > * > li > * > li > ol {
    list-style-type: lower-alpha;
}
li > * > li > * > li > * > li > * > li > ol {
    list-style-type: lower-greek;
}
li > * > li > * > li > * > li > * > li > * > li > ol {
    list-style-type: decimal;
}
li > p {
    margin: 0;
}
hr {
    padding: 4px 0;
}

// Bootstrap hacks
%o-double-container-no-padding {
    padding-right: 0;
    padding-left: 0;
}
.container {
    .container, .container-fluid {
        @extend %o-double-container-no-padding;
    }
}
.container-fluid .container-fluid {
    @extend %o-double-container-no-padding;
}
#wrap {
    > .container, > .container-fluid {
        // BS3 used to do this on all containers so that margins and floats are
        // cleared inside containers. As lots of current odoo layouts may rely
        // on this for some alignments, this is restored (at least for a while)
        // here only for main containers of the frontend.
        &::before, &::after {
            content: "";
            display: table;
            clear: both;
        }
    }
}
[class^="col-lg-"] {
    min-height: 24px;
}
.input-group {
    flex-flow: row nowrap;
}
.list-group-item:not([class*="list-group-item-"]):not(.active) {
    color: color-yiq($list-group-bg);
}

%o-portal-breadcrumbs {
    background-color: inherit;
}

// Replaces old BS3 page-header class
%o-page-header {
    margin-bottom: $headings-margin-bottom * 2;
    padding-bottom: $headings-margin-bottom;
    border-bottom-width: $border-width;
    border-bottom-style: solid;
    border-bottom-color: $border-color;
    line-height: 2.1rem;
}
.o_page_header {
    @extend %o-page-header;
}

// Images spacing
img, .media_iframe_video, .o_image {
    &.float-right {
        margin-left: $grid-gutter-width / 2;
    }
    &.float-left {
        margin-right: $grid-gutter-width / 2;
    }
}
img.o_we_custom_image {
    // Images added with the editor are .img-fluid by default but should
    // still behave like inline content.
    display: inline-block;
}

// Others
::-moz-selection {
    background: rgba(150, 150, 220, 0.3);
}
::selection {
    background: rgba(150, 150, 220, 0.3);
}
.oe_demo {
    position: relative;
    img {
        width: 100%;
    }
    div {
        @include o-position-absolute($left: 0, $bottom: 0);
        background-color: rgba(0, 0, 0, 0.4);
        opacity: 0.85;
        width: 100%;
        padding: 7px;
        color: white;
        font-weight: bold;
        a {
            color: white;
        }
    }
}
.oe_search_box {
    padding-right: 23px;
}

// Kept for (up to) saas-12 compatibility
.para_large {
    font-size: 120%;
}
.jumbotron .para_large p {
    font-size: 150%;
}
.readable {
    font-size: 120%;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;

    .container {
        padding-left: 0;
        padding-right: 0;
        width: auto;
    }
}

//  Background (kept for 8.0 compatibility) (! some are still used by website_blog)
.oe_dark {
    background-color: rgba(200, 200, 200, 0.14);
}
.oe_black {
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
}
.oe_green {
    background-color: #169C78;
    color: white;
    .text-muted {
        color: #ddd !important;
    }
}
.oe_blue_light {
    background-color: #41b6ab;
    color: white;
    .text-muted {
        color: #ddd !important;
    }
}
.oe_blue {
    background-color: #34495e;
    color: white;
}
.oe_orange {
    background-color: #f05442;
    color: white;
    .text-muted {
        color: #ddd !important;
    }
}
.oe_purple {
    background-color: #b163a3;
    color: white;
    .text-muted {
        color: #ddd !important;
    }
}
.oe_red {
    background-color: #9C1b31;
    color: white;
    .text-muted {
        color: #ddd !important;
    }
}
.oe_none {
    background-color: #FFFFFF;
}
.oe_yellow {
    background-color: #A2A51B;
}
.oe_green {
    background-color: #149F2C;
}

// Portal specific
// ===  Page custom bg ===
// To be applied to all portal pages if bg-color is white (default).
@if ($o-portal-use-default-colors) {
    #wrapwrap.o_portal {
        @include o-bg-color($o-portal-bg-color);
    }
}

.o_portal {
    .breadcrumb {
        @extend %o-portal-breadcrumbs;
    }

    > tbody.o_portal_report_tbody {
        vertical-align: middle;
    }
}

.o_portal_wrap {
    .o_portal_my_home > .o_page_header > a:hover {
        text-decoration: none;
    }

    .o_portal_navbar {
        .breadcrumb {
            padding-left: 0;
            padding-right: 0;
            @extend %o-portal-breadcrumbs;
        }

        @if ($o-portal-use-default-colors) {
            background-color: white!important;
        }
    }

    .o_portal_my_doc_table {
        th {
            padding-top: $o-portal-table-th-pt;
            padding-bottom: $o-portal-table-th-pb;
        }

        td {
            padding-top: $o-portal-table-td-pt;
            padding-bottom: $o-portal-table-td-pb;

        }

        tr:last-child td {
            padding-bottom: $o-portal-table-td-pb * 1.5;
        }

        td, th {
            vertical-align: middle;
            white-space: nowrap;
        }
    }

    address {
        span[itemprop="name"] {
            font-weight: bold;
            margin-bottom: 0.3em;
        }

        div[itemprop="address"] > div {
            position: relative;

            span[itemprop="streetAddress"] {
                line-height: 1.2;
                margin-bottom: 0.3em;
            }

            .fa {
                @include o-position-absolute(0, $left: 0);
                line-height: $line-height-base;

                + span {
                    display: block;
                    // FontAwesome '.fa-fw' fixed-with + margin
                    padding-left: 1.28571429em + 0.5em;
                }
            }
        }
    }

    .o_my_sidebar div[itemprop="address"] > div {
        margin-top: 0.5em;
    }

    @if ($o-portal-mobile-toolbar) {
        #o_portal_navbar_content {
            @include media-breakpoint-down(md) {
                margin: $navbar-padding-y (-$navbar-padding-x) 0;
                padding: $navbar-padding-y $navbar-padding-x ;
                border-top: $border-width solid $o-portal-mobile-toolbar-border;
                background-color: $o-portal-mobile-toolbar-bg;
            }
        }
    }

    table.table tr {
        word-wrap: break-word;
    }
}

.oe_attachments .o_image_small {
    height: 40px;
    width: 50px;
}

.o_portal_chatter {
    padding: 10px;

    .o_portal_chatter_avatar{
        width: 45px;
        height: 45px;
        margin-right: 1rem;
    }

    .o_portal_chatter_header {
        margin-bottom: 15px;
    }

    .o_portal_chatter_composer {
        margin-bottom: 15px;
    }

    .o_portal_chatter_messages {
        margin-bottom: 15px;

        .o_portal_chatter_message_title {
            p {
                font-size:85%;
                color:$o-main-color-muted;
                margin: 0px;
            }
        }
    }

    .o_portal_chatter_pager {
        text-align: center;
    }
}

.o_portal_signature_form .o_portal_sign_error_msg {
    color: $danger;
}

form label {
    font-weight: $font-weight-bold;
    &.label-optional {
        font-weight: $font-weight-normal;
    }
}

.o_portal_contact_img {
    width: 2.3em;
    height: 2.3em;
}

.o_portal_sidebar {
    #sidebar_content.card {
        border-left: 0;
        border-bottom: 0;

        > div.card-body {
            border-left: $border-width solid $border-color;
        }

        > ul > li {
            border-left: $border-width solid $border-color;
            margin-bottom: -1px;
        }

        > div.card-footer {
            border-left: $border-width solid $border-color;
            border-bottom: $border-width solid $border-color;
        }
    }

    .o_portal_page_size {
        width: 100%;
        max-width: 210mm; // A4 page's width
    }

    .o_portal_html_view {
        overflow: hidden;
        background: white;
        position: relative;

        .o_portal_html_loader {
            @include o-position-absolute(45%, 0, auto, 0);
        }

        iframe {
            position: relative;
        }
    }
}
