/*
*
* @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.
*
*/


// 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;
}

body {
    // add a bit of perfection
    -webkit-font-feature-settings: "liga", "kern";
    font-feature-settings: "liga", "kern";
}

.elevation-1() { box-shadow: 0  6px 12px rgba(0, 0, 0, 0.175); }
.elevation-2() { box-shadow: 0 10px 20px 5px rgba(0, 0, 0, 0.2); }
.elevation-3() { box-shadow: 0 15px 70px 10px rgba(0, 0, 0, 0.5);  }

textarea,
.user-select-text { .user-select(text); }

textarea { resize: none; }

// disable native styles because of ios safari browser bugs, see https://stackoverflow.com/questions/26573346/ios-safari-messes-up-input-type-date/31362574
html.ios input[type="datetime-local"], html.ios input[type="date"] {
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    padding-top: 0;
}

span.hint {
    font-size: 8pt;
    text-align: left;
}

/* model.trigger('invalid:... */
.help-block.error {
    //font-weight: bold;
    color: @error-text-color;
}

/* fail handling */
.io-ox-fail {
    padding: 4px;
    font-weight: normal;
    color: #767676;
}

.io-ox-center {
    display: table;
    width: 100%;
    height: 100%;
}

.io-ox-center > div {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
}

/* Bootstrap overrides BEGIN */
legend, label {
    color: @label-default-bg;
    margin-bottom: 5px;
    font-size: 13px;
    line-height: 20px;
    * {
        font-weight: normal;
    }
}

.radio-inline, .checkbox-inline, .checkbox label, .radio label { font-size: @font-size-base; }

legend {
    padding-top: 8px;
    font-weight: bold;

    &.simple {
        margin:0;
        border-bottom: 0 none;
    }

    &.io-ox-label h2 {
        display: inline;
        font-size: 13px;
    }
}

.btn-file {
    position: relative;
    overflow: hidden;

    input[type=file] {
        position: absolute;
        top: 0;
        right: 0;
        min-width: 100%;
        min-height: 100%;
        font-size: 100px;
        text-align: right;
        filter: alpha(opacity=0);
        opacity: 0;
        background: red;
        cursor: inherit;
        display: block;
        outline: 0;
    }

    i.fa-paperclip:after { content: '\00a0'; }
}

.btn-unstyled {
    width: 100%;
    text-align: left;
    padding: 0;
    background-color: transparent;
    border: none;
}

/* medium large button, used on mobile since the bootstrap large button is to large */
.btn-medium {
    padding: 8px 19px;
    font-size: 15.5px;
}

.action-button-rounded {
    margin: 24px 0 0 0;
    button {
        font-size: 13px;
        line-height: 24px;
        padding: 0;
        margin: 0 24px 0 0;
    }
    & > .dropdown {
        display: inline-block;
    }
    // work with icons and svg
    .icon-container, .fa:first-child:not(svg) {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        border: 1px solid fade(@link-color, 40%);
        background-color: fade(@link-color, 4%);
        color: @link-color;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 16px;
        margin: 0 auto;
    }
    .icon-container svg {
        height: 16px;
    }
    [data-action="join"] svg, .icon-container svg.call-icon {
        height: 24px;
    }
    .btn-link:hover:not(:disabled), .btn-link:focus {
        outline: 0;
        text-decoration: none;
        i.fa:first-child {
            color: white;
            background-color: @link-color;
            border: 0;
        }
    }
    &.horizontal {
        button {
            display: flex;
            align-items: center;
            i.fa, .icon-container { margin-right: 8px; }
        }
    }
}

.cursor-pointer, .label.pointer { cursor: pointer; }

.badge {

    &.badge-deferred {
        background-color: @badge-deferred-bg;
        color: @badge-deferred-color;
    }

    &.badge-inprogress {
        background-color: @badge-inprogress-bg;
        color: @badge-inprogress-color;
    }

    &.badge-notstarted {
        background-color: @badge-notstarted-bg;
        color: @badge-notstarted-color;
    }

    &.badge-done {
        background-color: @badge-done-bg;
        color: @badge-done-color;
    }

    &.badge-waiting {
        background-color: @badge-waiting-bg;
        color: @badge-waiting-color;
    }

    &.badge-overdue {
        background-color: @badge-overdue-bg;
        color: @badge-overdue-color;
    }
}

/* fixes WBR handling in long character sequences, esp. for IE */
wbr:after { content: "\00200B" }

.alert {
    padding: 8px 35px 8px 14px;
    margin-bottom: 20px;
    &.indicator {
        margin-bottom: 0px;
    }
}


.row label { padding-top: 8px; }

/* Bootstrap overrides END */

.clear-title {
    font-family: @light-font-family;
    font-weight: 300;
    font-size: 20pt;
    line-height: 1.15em;
}

/* Hopscotch overrides BEGIN */
div.hopscotch-bubble {
    * { box-sizing: content-box; }

    div.hopscotch-bubble-content { margin: 0; }
}
/* Hopscotch overrides END */

#background-loader.secure {
    background-color: rgba(255, 255, 255, 0);
    /* bug 27760 */
    /* .transition(background-color 0.5 linear); */
    &.block {
        background-color: rgba(255, 255, 255, 0.5);
        text-align: center;

        button {
            display: none;
            position: relative;
            top: 52%;
        }
    }
}

.auto-logout-dialog:not(.logout-failed) [data-action="retry"] {
    display: none;
}

@keyframes make-visible {
    99% {visibility: hidden;}
    100% {visibility: visible;}
}

.io-ox-busy {
    position: relative;

    &:before {
        visibility: hidden;
        position: absolute;
        top: 50%;
        left: 50%;
        margin: -10px 0 0 -10px;
        /* icon-refresh */
        font-size: 20px;
        font-family: 'FontAwesome';
        content: '\f021';
        color: #ccc;
        /* icon-spin */
        animation: fa-spin 1.5s infinite linear, 1ms make-visible forwards;
        animation-delay: 300ms;
        .relogin-required & {
            animation: 1ms make-visible forwards;
        }
    }

    &.immediate:before {
        animation-delay: 0ms;
    }
}

#io-ox-core {
    // use explicit z-index (e.g. so that side-popups appear above)
    z-index: 0;

    // Bug 27436
    -webkit-backface-visibility: hidden;

    &.wallpaper {
        .radial-gradient(@wallpaper-color-1, @wallpaper-color-2, @wallpaper-color-3);
    }

    transition: filter 1s linear, opacity 1s linear;

}

#io-ox-offline {
    position: absolute;
    bottom: 0;
    width: 15rem;
    left: 50%;
    margin-left: -7.5rem;
    height: 2.5rem;
    font-weight: bold;
    line-height: 2.5rem;
    text-align: center;
    color: #fff;
    border: 1px solid #FF7000;
    border-width: 1px 1px 0 1px;
    background-color: @red;
    cursor: default;
    z-index: 650000;
    box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.30);
    border-radius: 5px 5px 0 0;
}

// defined in core CSS to guarantee an instant response
.io-ox-viewer {
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 11; // just to one more than #io-ox-screens
}

/* scrollable for touch devices, esp. iOS */
.scrollable {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
}

html:not(.internet-explorer) {
    .scrollable[tabindex], .listbox[tabindex] {
        &:focus {
            box-shadow: inset 0 0 0 2px @link-color;
        }
    }
}

// Apparently IE does not manage to draw box shadows without leaving artifacts when scrolling
// So we have to use boder and change the padding so the content does not move on focus. IE strikes again!
.internet-explorer {
    .scrollable[tabindex], .listbox[tabindex] {
        &:focus {
            border: 2px solid @link-color;
            &.default-content-padding:not(.no-padding-adjustment) {
                padding: 18px 28px;
            }
        }
    }
}

// shared css
.list-view, .vgrid {
    .gray { color: #707070; }
    .selected:not(:focus) .gray {
        color: #333333;
    }
    .vgrid-cell, .list-item {
        &:hover .gray {
            color: #555;
        }
    }
}

.focusable:focus, .list-item.focusable:focus {
    outline: 2px solid @link-color;
}

.blockscroll { overflow: hidden !important; }

.scrollable-pane {
    position: relative;
    width: 100%;
    min-height: 100%;

    &:after {
        content: '\00a0'; /* make sure margins/paddings are applied properly */
    }

}

.ui-disabled {
    pointer-events: none;
    color: @ui-disabled-color;
}


.atb, .abs {
    position: absolute;
    top: 0;
    bottom: 0;
}

.abs {
    left: 0;
    right: 0;
}

.abs-r { right: 0; }
.abs-l { left: 0; }

.ellipsis { .ellipsis(); }

.person, .person-link {
    color: #333;
    word-break: normal;
    white-space: nowrap;
}
.from .person { color: inherit; }

.person-link { cursor: pointer; }

.default-content-padding { padding: 32px 32px; }

.border-top    { border-top: 1px solid @default-border-color; }
.border-right  { border-right: 1px solid @default-border-color; }
.border-bottom { border-bottom: 1px solid @default-border-color; }
.border-left   { border-left: 1px solid @default-border-color; }

.touch body { font-size: @font-size-touch; }

@media (max-width: 767px) {
    body {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

@media (max-width: 900px) {
    .default-content-padding { padding: 26px 13px; }
    .internet-explorer .scrollable[tabindex].default-content-padding:focus:not(.no-padding-adjustment) { padding: 24px 11px; }
}

.form-spacer { margin-top: 32px; }

// form control inside input groups needs auto height (breaks layout otherwise)
.input-group >.form-control {
    height: auto;
}

.form-control {
    // 30px with default 14px font size but scales with text zoom
    height: 2.14285714em;
}

// ensure visibility for tooltips
.tooltip { z-index: 100000; }

.center-childs {
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-container {
    // space for toggle action and caps-lock indicator
    input.form-control {
        .ellipsis();
        padding-right: 12px;
    }
    &.has-focus input.form-control { padding-right: 50px; }
    .toggle-asterisks.form-control-feedback {
        display: none;
        height: 22px;
        padding: 0px 16px;
        top: 4px;
        right: 4px;
        bottom: 4px;
        z-index: 3;
        pointer-events: all;
        background-color: #e6e6e6;
        font-size: 16px;
        &:focus {
            color: #ffffff;
            background-color: @brand-primary;
        }
    }
    &.has-focus .toggle-asterisks {
        display: flex;
    }
}

.blur {
    .ie11 & {
        opacity: 0;
    }
    filter: blur(@bluriness);
}

h1.unstyled,
h2.unstyled,
h3.unstyled,
h4.unstyled,
h5.unstyled {
    margin: inherit;
    font-weight: inherit;
    font-size: inherit;
}

label.unstyled {
    color: inherit;
    line-height: inherit;
    font-size: inherit;
    font-weight: inherit;
    margin-bottom: inherit;
}

// small screens (mobile)
// note that we have to target max-width and max-device-width
// to target all devices which don't support the max-device-width
// property
@media(max-width: @smartphone-breakpoint) and (orientation: portrait), (max-height: @smartphone-breakpoint) and (orientation: landscape) {

    .default-content-padding { padding: 5px 10px; }
    .internet-explorer .scrollable[tabindex].default-content-padding:focus:not(.no-padding-adjustment) { padding: 3px 8px; }
    .form-control {padding: 4px; }

    // flat input fields
    textarea.flat, input.flat {
        border-width: 0;
        border-bottom-width: 1px;
        box-shadow: none;
        border-radius: 0;

        &:focus {
            border-width: 0;
            box-shadow: none;
            border-bottom-width: 1px;
            border-color: initial;
        }

    }

    .clear-title { font-size: 15pt; }

    #background-loader.secure.block {
        background-color: rgba(0,0,0,.6);
        height: 150%;
        position: fixed; // always center this
    }
}

/* Override Edge's Clear input behaviour */
::-ms-clear { display: none; }

svg.fa, .fasvg {
    height: 14px;
    // needed for wider icons like the drive cloud
    overflow: visible;
    text {
        font-size: 100px;
        fill: currentColor;
    }
}
