/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2017 Vector Creations Ltd
Copyright 2017 New Vector Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

html {
    /* hack to stop overscroll bounce on OSX and iOS.
       N.B. Breaks things when we have legitimate horizontal overscroll */
    height: 100%;
    overflow: hidden;
}

body {
    font-family: $font-family;
    font-size: 15px;
    background-color: $primary-bg-color;
    color: $primary-fg-color;
    border: 0px;
    margin: 0px;
}

.error, .warning {
    color: $warning-color;
}

h2 {
    color: $primary-fg-color;
    font-weight: 400;
    font-size: 18px;
    margin-top: 16px;
    margin-bottom: 16px;
}

a:hover,
a:link,
a:visited {
    color: $accent-color-alt;
}

input[type=text],
input[type=search],
input[type=password] {
    padding: 9px;
    font-family: $font-family;
    font-size: 14px;
    font-weight: 600;
    min-width: 0;
}

input[type=text].mx_textinput_icon,
input[type=search].mx_textinput_icon {
    padding-left: 36px;
    background-repeat: no-repeat;
    background-position: 10px center;
}

// FIXME THEME - Tint by CSS rather than referencing a duplicate asset
input[type=text].mx_textinput_icon.mx_textinput_search,
input[type=search].mx_textinput_icon.mx_textinput_search {
    background-image: url('$(res)/img/feather-customised/search-input.svg');
}

// dont search UI as not all browsers support it,
// we implement it ourselves where needed instead
input[type=search]::-webkit-search-decoration,
input[type=search]::-webkit-search-cancel-button,
input[type=search]::-webkit-search-results-button,
input[type=search]::-webkit-search-results-decoration {
    display: none;
}

// Override Firefox's UA style so we get a consistent look across browsers
input::placeholder,
textarea::placeholder {
    opacity: initial;
}

input[type=text], input[type=password], textarea {
    background-color: transparent;
    color: $primary-fg-color;
}

input[type=text]:focus, input[type=password]:focus, textarea:focus {
    outline: none;
    box-shadow: none;
}

/* Required by Firefox */
textarea {
    font-family: $font-family;
    color: $primary-fg-color;
}

// .mx_textinput is a container for a text input
// + some other controls like buttons, ...
// it has the appearance of a text box so the controls
// appear to be part of the input

.mx_Dialog, .mx_MatrixChat {
    :not(.mx_textinput):not(.mx_Field):not(.mx_no_textinput) > input[type=text],
    :not(.mx_textinput):not(.mx_Field):not(.mx_no_textinput) > input[type=search],
    .mx_textinput {
        display: block;
        box-sizing: border-box;
        background-color: transparent;
        color: $input-darker-fg-color;
        border-radius: 4px;
        border: 1px solid #c1c1c1;
        // these things should probably not be defined
        // globally
        margin: 9px;
        flex: 0 0 auto;
    }

    .mx_textinput {
        display: flex;
        align-items: center;

        > input[type=text],
        > input[type=search] {
            border: none;
            flex: 1;
            color: $primary-fg-color;
        }
    }

    :not(.mx_textinput):not(.mx_Field):not(.mx_no_textinput) > input[type=text]::placeholder,
    :not(.mx_textinput):not(.mx_Field):not(.mx_no_textinput) > input[type=search]::placeholder,
    .mx_textinput input::placeholder {
        color: $roomsublist-label-fg-color;
    }
}

/*** panels ***/
.dark-panel {
    background-color: $dark-panel-bg-color;
}

.dark-panel {
    :not(.mx_textinput):not(.mx_Field):not(.mx_no_textinput) > input[type=text],
    :not(.mx_textinput):not(.mx_Field):not(.mx_no_textinput) > input[type=search],
    .mx_textinput {
        color: $input-darker-fg-color;
        background-color: $input-darker-bg-color;
        border: none;
    }
}

.light-panel {
    :not(.mx_textinput):not(.mx_Field):not(.mx_no_textinput) > input[type=text],
    :not(.mx_textinput):not(.mx_Field):not(.mx_no_textinput) > input[type=search],
    .mx_textinput {
        color: $input-lighter-fg-color;
        background-color: $input-lighter-bg-color;
        border: none;
    }
}

/* Prevent ugly dotted highlight around selected elements in Firefox */
::-moz-focus-inner {
    border: 0;
}

/* applied to side-panels and messagepanel when in RoomSettings */
.mx_fadable {
    opacity: 1;
    transition: opacity 0.2s ease-in-out;
}

/* XXX: critical hack to GeminiScrollbar to allow them to work in FF 42 and Chrome 48.
   Stop the scrollbar view from pushing out the container's overall sizing, which causes
   flexbox to adapt to the new size and cause the view to keep growing.
 */
.gm-scrollbar-container .gm-scroll-view {
    position: absolute;
}

/* Expand thumbs on hoverover */
.gm-scrollbar {
    border-radius: 5px ! important;
}
.gm-scrollbar.-vertical {
    width: 6px;
    transition: width 120ms ease-out ! important;
}
.gm-scrollbar.-vertical:hover,
.gm-scrollbar.-vertical:active {
    width: 8px;
    transition: width 120ms ease-out ! important;
}
.gm-scrollbar.-horizontal {
    height: 6px;
    transition: height 120ms ease-out ! important;
}
.gm-scrollbar.-horizontal:hover,
.gm-scrollbar.-horizontal:active {
    height: 8px;
    transition: height 120ms ease-out ! important;
}

// These are magic constants which are excluded from tinting, to let themes
// (which only have CSS, unlike skins) tell the app what their non-tinted
// colourscheme is by inspecting the stylesheet DOM.
//
// They are not used for layout!!
#mx_theme_accentColor {
    color: $accent-color;
}

#mx_theme_secondaryAccentColor {
    color: $secondary-accent-color;
}

#mx_theme_tertiaryAccentColor {
    color: $roomsublist-label-bg-color;
}

.mx_Dialog_wrapper {
    position: fixed;
    z-index: 4000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    display: flex;
    align-items: center;
    justify-content: center;
}

/* Spinner Dialog overide */
.mx_Dialog_wrapper.mx_Dialog_spinner .mx_Dialog {
    width: auto;
    border-radius: 8px;
    padding: 0px;
    box-shadow: none;
}

.mx_Dialog {
    background-color: $primary-bg-color;
    color: $light-fg-color;
    z-index: 4010;
    font-weight: 300;
    font-size: 15px;
    position: relative;
    padding: 40px 58px 36px 58px;
    width: 60%;
    max-width: 704px;
    box-shadow: 2px 15px 30px 0 $dialog-shadow-color;
    max-height: 80%;
    overflow-y: auto;
}

.mx_Dialog_background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: $dialog-backdrop-color;
    opacity: 0.8;
}

.mx_Dialog_lightbox .mx_Dialog_background {
    opacity: 0.85;
    background-color: $lightbox-background-bg-color;
}

.mx_Dialog_lightbox .mx_Dialog {
    border-radius: 0px;
    background-color: transparent;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    pointer-events: none;
}

.mx_Dialog_header {
    position: relative;
}

.mx_Dialog_title {
    font-weight: bold;
    font-size: 22px;
    line-height: 36px;
    color: $primary-fg-color;
}

.mx_Dialog_header.mx_Dialog_headerWithButton > .mx_Dialog_title {
    text-align: center;
}

.mx_Dialog_title.danger {
    color: $warning-color;
}

.mx_Dialog_cancelButton {
    mask: url('$(res)/img/feather-customised/cancel.svg');
    mask-repeat: no-repeat;
    mask-position: center;
    width: 36px;
    height: 36px;
    background-color: $primary-fg-color;
    cursor: pointer;
    position: absolute;
    top: 20px;
    right: 20px;
}

.mx_Dialog_content {
    margin: 24px 0 68px;
    font-size: 14px;
    color: $primary-fg-color;
    word-wrap: break-word;
}

.mx_Dialog_buttons {
    text-align: right;
}

.mx_Dialog button, .mx_Dialog input[type="submit"] {
    @mixin mx_DialogButton;
    margin-left: 0px;
    margin-right: 8px;

    // flip colours for the secondary ones
    font-weight: 600;
    border: 1px solid $accent-color ! important;
    color: $accent-color;
    background-color: $button-secondary-bg-color;
}

.mx_Dialog button:hover, .mx_Dialog input[type="submit"]:hover {
    @mixin mx_DialogButton_hover;
}

.mx_Dialog button:focus, .mx_Dialog input[type="submit"]:focus {
    filter: brightness($focus-brightness);
}

.mx_Dialog button.mx_Dialog_primary, .mx_Dialog  input[type="submit"].mx_Dialog_primary {
    color: $accent-fg-color;
    background-color: $accent-color;
}

.mx_Dialog button.danger, .mx_Dialog input[type="submit"].danger {
    background-color: $warning-color;
    border: solid 1px $warning-color;
    color: $accent-fg-color;
}

.mx_Dialog button:disabled, .mx_Dialog input[type="submit"]:disabled {
    background-color: $light-fg-color;
    border: solid 1px $light-fg-color;
    opacity: 0.7;
}

// TODO: Review mx_GeneralButton usage to see if it can use a different class
// These classes were brought in from the old UserSettings and are included here to avoid
// breaking the app.
// Ref: https://github.com/vector-im/riot-web/issues/8420
.mx_GeneralButton {
    @mixin mx_DialogButton;
    display: inline;
    margin: auto;
}

.mx_GeneralButton:hover {
    @mixin mx_DialogButton_hover;
}

.mx_linkButton {
    cursor: pointer;
    color: $accent-color;
}

.mx_TextInputDialog_label {
    text-align: left;
    padding-bottom: 12px;
}

.mx_TextInputDialog_input {
    font-size: 15px;
    border-radius: 3px;
    border: 1px solid $input-border-color;
    padding: 9px;
    color: $primary-fg-color;
    background-color: $primary-bg-color;
}

.mx_emojione {
    height: 1em;
    vertical-align: middle;
}

.mx_emojione_selected {
    background-color: $accent-color;
}

::-moz-selection {
    background-color: $accent-color;
    color: $selection-fg-color;
}

::selection {
    background-color: $accent-color;
    color: $selection-fg-color;
}

.mx_textButton {
    @mixin mx_DialogButton_small;
}

.mx_textButton:hover {
    @mixin mx_DialogButton_hover;
}

.mx_button_row {
    margin-top: 69px;
}

.mx_Beta {
    color: red;
    margin-right: 10px;
    position: relative;
    top: -3px;
    background-color: white;
    padding: 0 4px;
    border-radius: 3px;
    border: 1px solid darkred;
    cursor: help;
    transition-duration: 200ms;
    font-size: smaller;
    filter: opacity(0.5);
}

.mx_Beta:hover {
    color: white;
    border: 1px solid gray;
    background-color: darkred;
}

.mx_TintableSvgButton {
    position: relative;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-content: center;
}

.mx_TintableSvgButton object {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

.mx_TintableSvgButton span {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}
