/*
*
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.

* You should have received a copy of the GNU Affero General Public License
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
*
* Any use of the work other than as authorized under this license or copyright law is prohibited.
*
*/

@import 'bootstrap/less/mixins.less';
@import 'bootstrap/less/normalize.less';
@import 'bootstrap/less/scaffolding.less';
@import 'bootstrap/less/type.less';
@import 'bootstrap/less/grid.less';
@import 'bootstrap/less/forms.less';
@import 'bootstrap/less/buttons.less';
@import 'bootstrap/less/dropdowns.less';
@import 'bootstrap/less/utilities.less';
@import 'font-awesome/less/variables.less';

@import "../components/checkboxes.less";

@wallpaper-start-color: #fff;
@wallpaper-end-color: #fff;

@fa-font-path: '../../../3rd.party/font-awesome/fonts';

@font-face {
    font-family: 'FontAwesome';
    src: url('@{fa-font-path}/fontawesome-webfont.woff2?v=@{fa-version}') format('woff2'),
         url('@{fa-font-path}/fontawesome-webfont.woff?v=@{fa-version}') format('woff'),
         url('@{fa-font-path}/fontawesome-webfont.ttf?v=@{fa-version}') format('truetype'),
         url('@{fa-font-path}/fontawesome-webfont.svg?v=@{fa-version}#fontawesomeregular') format('svg');
    font-weight: normal;
    font-style: normal;
}

// set html font size to 1rem this way we are compliant with bootstrap 4 and 5.
// setting this to 1 rem means we are using the browsers default font size which is usually 16px
// careful though, bootstrap 3 sets this to 10px although never uses it
html {
    font-size: 1rem;
}

html, body {
    height: 100%;
    font-family: @normal-font-family;
}

html[lang], body {
    font-size: 1rem;
    line-height: 1.24rem;
}

// ensure proper alignment (during development)
// or use the bookmarklet from http://keyes.ie/things/baseliner/
html.baseline {
    #background-loader {
        display: block !important;
        background-color: transparent;
        background-image: url('../../default/baseline_8_cyan.png');
        opacity: 0.50;
    }
    &.red #background-loader {
        background-image: url('../../default/baseline_8_red.png');
        opacity: 0.30;
    }
    &.gray #background-loader {
        background-image: url('../../default/baseline_8_gray.png');
        opacity: 0.80;
    }
}

.unselectable {
    .user-select(none);
}

.selectable-text {
    .user-select(text);
    cursor: default;
}

.noscript {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 65000;
    width: 400px;
    margin: -50px 0 0 -200px;
    z-index: 65301;
}

#background-loader {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 65300;
    background-color: #fff;
    -webkit-transform: translateZ(0); /* activate GPU acceleration */
}

// duplicate code to prevent loading themes (see /themes/components/dropdown.less)
.smart-dropdown-container {
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 100000;

    ul {
        overflow-y: auto;
        overflow-x: hidden;
        li:first-child.divider {
            display: none;
        }
    }
}

#io-ox-login-screen ~ .smart-dropdown-container {
    top: 0;
}

// overwrite some bootstrap styles. Once any theme is loaded, it also loads all of bootstrap. This messes up the layout
.touch body #io-ox-login-screen { font-size: 14px; }

#io-ox-login-screen {
    .row label {
        padding-top: inherit;
        font-size: inherit;
        line-height: inherit;
    }
    .form-control { padding: 4px 12px; }
    font: 14px/20px @normal-font-family;
}
// bootstrap overwrite end

#io-ox-login-screen {
    height: 100%;
    z-index: 65102;
    color: #fff;

    .no-margin {
        margin: 0;
    }

    &.relogin {
        right: auto;
        left: 50%;
        width: 800px;
        margin-left: -400px;
        -webkit-box-shadow: 0 0 70px 5px #000;
        -moz-box-shadow: 0 0 70px 5px #000;
        box-shadow: 0 0 70px 5px #000;
    }

    .io-ox-busy {
        position: relative;
        &:before {
            position: absolute;
            top: 50%;
            left: 50%;
            margin: -10px 0 0 -10px;
            /* icon-refresh */
            font-size: 20px;
            font-family: 'FontAwesome';
            content: '\f021';
            color: rgba(0, 0, 0, 0.30);
            /* icon-spin */
            -moz-animation: fa-spin 1.5s infinite linear;
            -o-animation: fa-spin 1.5s infinite linear;
            -webkit-animation: fa-spin 1.5s infinite linear;
            animation: fa-spin 1.5s infinite linear;
        }
    }

    .help-block {
        margin-bottom: 16px;
    }
}

#io-ox-login-blocker {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background-color: black;
    opacity: 0.01;
    filter: alpha(opacity=1);
    z-index: 65000;
}

.login-spacer {
    flex-grow: 1;
}

#io-ox-login-container, #io-ox-login-background-image {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    min-height: 100%;
    padding: 0;
    background-size: cover !important;
    overflow-y: auto;

    &#io-ox-login-container {
        background: radial-gradient(at 33% 50%, lighten(@brand-primary, 20%), @brand-primary);
    }

    .login-logo {
        max-height: 32px;
        background-size: contain;
        background-repeat: no-repeat;
        background-position: center;

        display: block;
        width: auto;
        height: auto;
    }

    .composition-element {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        margin: 4px 8px;
        min-width: fit-content;

        *:not(:last-child) {
            margin-right: 4px;
        }
    }
}

#io-ox-login-header {
    width: 100%;
    margin: 0;
    background: linear-gradient(rgba(0,0,0,0.1),rgba(0,0,0,0));
}

#io-ox-login-toolbar {
    position: relative;
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 16px;

    label {
        margin-bottom: 0;
    }

    div {
        margin-left: 16px;
        margin-right: 16px;
    }

    #io-ox-language-list {
        overflow-y: scroll;
    }

    * {
        color: #fffff;
    }

    > * {
        margin: 0 16px;
    }

    > *:first-child {
        margin-left: 0;
    }

    > *:last-child {
        margin-right: 0;
    }
}

#io-ox-login-content {
    display: flex;
    flex-shrink: 0;
    width: 100%;

    .align-center {
        align-self: center;
    }
}

#io-ox-information-message {
    display: flex;
    margin: 0 auto;
    margin-top: 8px;
    width: 420px;
}

#io-ox-login-footer {
    width: 100%;
    margin: 64px 0 0 0;
    padding: 6px 2px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;

    background-color: rgba(0, 0, 0, 0.15);

    color: #ffffff;

    a {
        color: #94c1ec;
    }

    > * {
        margin: 0 8px;
        &:first-child { margin-left: 0; }
        &:last-child { margin-right: 0; }
    }

}

#io-ox-languages {
    display: flex;

    #language-select option {
        color: #000000;
    }

    *:not([role="menuitem"]) {
        color: #ffffff;
    }

    * > a:not([role="menuitem"]),#language-select,.toggle-text,.caret {
        color: #94c1ec;
    }

    .dropup, .dropdown {
        display: inline-block;
    }

    a.lang-label {
        text-decoration: none;
        margin-right: 5px;
        // color: #fff;
        &:focus { outline: 0; }
        &:hover { text-decoration: none; }
        font-weight: normal;
    }
}

#language-select {
    background: transparent;
    border:0;
}

#io-ox-login-box {
    display: flex;
    justify-content: center;

    .flex-column {
        display: flex;
        flex-direction: column;
    }
}

#box-form {
    width: 420px;
    text-align: center;
    border-radius: 6px;
    box-shadow: 0 15px 70px 0 rgba(0,0,0,.5);

    * {
        color: #333333;
    }

    a {
        color: @btn-primary-bg;
    }

    * button {
        border-color: @btn-primary-border;
        background-color: @btn-primary-bg;
        color: @btn-primary-color;
    }
}

#box-form-header {
    height: 4rem;
    line-height: 60px;
    font-size: 24px;
    font-weight: bold;
    border-radius: 6px 6px 0 0;
    background-size: cover !important;
    background-position: 50% 50% !important;
    background-color: #f5f5f5;
    color: #333333;
}

#box-form-body {
    min-height: 380px;
    background-color: #fff;
    border-radius: 0 0 6px 6px;

    .form-control {
        height: 2.5rem;
    }

    form, form > div {
        min-height: inherit;
    }

    form > div > div.row {
        margin: 4px 0;
    }

    form > div {
        display: flex;
        flex-direction: column;
        padding-top: 27px;
        padding-bottom: 32px;

        .row.username, .row.password {
            margin: 0;
        }

        .row.options {
            .checkbox.custom {
                margin-top: 0;
            }

            div {
                margin-top: 4px;
            }
        }

        .row.feedback {
            margin-bottom: 14px;
            min-height: 32px;
        }

        .row.button {
            display: flex;
            align-items: flex-end;
            margin-top: auto;

            div {
                margin-bottom: 0;
            }
        }

        #io-ox-backtosignin {
            margin-top: auto;
            margin-bottom: auto;
        }

        #io-ox-forgot-password {
            margin-top: 4px;
        }
    }

    * > label {
        margin-bottom: 3px;
        font-size: 13px;
        float: left;
    }

    * > a {
        font-size: 13px;
    }

    .checkbox.custom, .radio.custom {
        padding-left: 1.25rem;
    }

    .checkbox.custom input:checked+i.toggle, .radio.custom input:checked+i.toggle {
        background-color: transparent;
        border: 1px solid #ccc;
        padding: 2px;
        font: normal normal normal 10px/1 FontAwesome;
    }
}

#login-title {
    text-align: left;
    font-size: 18px;
    font-weight: bold;
    margin: 0;
}

#io-ox-login-help,
#io-ox-login-feedback,
#io-ox-login-feedback div {
    text-align: left;
    font-size: 13px;
}

#io-ox-login-feedback.alert-highlight > .alert-info {
    background: #eee;
    border-radius: 4px;
    padding: 8px 8px;
    font-weight: bold;
}

.row.password-retype {
    display: none;
}

.login-type-message {
    #box-form-body {
        min-height: unset !important;

        form > div > div.row {
            margin: 0 !important;
        }

        #io-ox-login-help {
            margin: 0;
        }
    }
}


/* small screen size */

@media (max-width: 767px) {
    #io-ox-login-teaser { display: none; }
    #io-ox-login-content > .align-center { flex-grow: 1; }
}

@media (max-height: 300px) { #io-ox-language-list { max-height: 100px; } }
@media (max-height: 600px) { #io-ox-language-list { max-height: 200px; } }
@media (min-height: 600px) { #io-ox-language-list { max-height: 500px; } }


/* mobile stuff */

.smartphone #io-ox-login-screen #io-ox-login-container {

    .login-spacer,
    #box-form-header,
    .username label, .password label, .password-retype label, .email label,
    #io-ox-information-message { display: none; }

    .login-logo {
        margin: 16px;
        max-height: 24px;
    }

    #login-title-mobile {
        margin-right: 16px;
        align-self: center;
        font-size: 18px;
        font-weight: bold;
        text-align: right;
        flex-grow: 1;
        color: white;
    }

    #io-ox-login-content #box-form {
        width: 320px;

        #box-form-body {
            border-radius: 6px;
            min-height: unset;

            #io-ox-login-feedback {
                transition:transform 0.3s ease-out;
                transform:scaleY(1);
                &:empty{ transform:scaleY(0); }
            }
        }
    }

    #io-ox-login-footer {
        margin-top: 0;
        justify-content: center;
        #io-ox-languages {
            margin: 0;
            .lang-label { margin-bottom: 0; }
        }
    }
}

/* support for busy spinner */
@-moz-keyframes fa-spin {
  0%    { -moz-transform: rotate(0deg);     }
  100%  { -moz-transform: rotate(359deg);   }
}
@-webkit-keyframes fa-spin {
  0%    { -webkit-transform: rotate(0deg);  }
  100%  { -webkit-transform: rotate(359deg);}
}
@-o-keyframes fa-spin {
  0%    { -o-transform: rotate(0deg);       }
  100%  { -o-transform: rotate(359deg);     }
}
@-ms-keyframes fa-spin {
  0%    { -ms-transform: rotate(0deg);      }
  100%  { -ms-transform: rotate(359deg);    }
}
@keyframes fa-spin {
  0%    { transform: rotate(0deg);          }
  100%  { transform: rotate(359deg);        }
}

// a11y placeholder (AA compliant)
.form-control::-webkit-input-placeholder { /* WebKit, Blink, Edge */
    color: #666666;
}
.form-control::-moz-placeholder { /* Mozilla Firefox */
   color: #666666;
   opacity: 1;
}
.form-control::-ms-input-placeholder { /* Internet Explorer 10-11 */
   color: #666666;
}
