/*
 * This file is part of Cockpit.
 *
 * Copyright (C) 2013 Red Hat, Inc.
 *
 * Cockpit is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * Cockpit 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
 */

/* ---------------------------------------------------------------------------------------------------- */

@import (less) "../lib/page.css";
@import (less) "../lib/table.css";
@import "variables.less";
@import "switcher.less";
@import "active-pages.less";

/* Hacks on top for now */

html, body {
    height: 100%;
}

html.index-page body {
    overflow: hidden;
}

.hide-before:before {
    display: none;
}

.curtains-ct {
    top: auto;
    position: static;
}

#dashboard-add {
    height: 28px;
    width: 28px;
}

#dashboard-hosts .list-group-item {
    border-left-width: 7px;
    border-left-style: solid;
    border-top: none;
    position: relative;
    outline: 0;
}

#dashboard-hosts .list-group-item:before {
    content: "";
    position: absolute;
    border-top: 1px solid #BABABA;
    top: 0px;
    left: 0px;
    right: 0px;
    height: 1px;
}

#dashboard-hosts .list-group-item:first-child:before {
    border-top-color: transparent;
}

#dashboard-hosts button {
    height: 28px;
    width: 28px;
    padding: 8px;
    float: right;
    margin-left: 10px;
}

#dashboard-hosts button.btn.pficon {
    padding-top: 5px;
    font-size: 14px;
}

/* Per server buttons not visible by default */
#dashboard-hosts .list-group button {
    margin-top: 2px;
    display: none;
}

/* When panel is editable, then buttons are visible */
#dashboard-hosts.editable .list-group button {
    display: block;
}

#dashboard-hosts.editable .list-group-item:hover {
    background-color: #FFF;
    cursor: auto;
}

#dashboard-hosts .spinner {
    float: left;
    margin: 6px 13px 4px 3px;
}

#dashboard-hosts .list-group-item span.reconnecting {
    color: #888;
    display: inline;
    padding-left: 20px;
}

.host-avatar {
    border-radius: 3px;
    margin-right: 10px;
    width: 32px;
    height: 32px;
}

#dashboard-hosts .list-group-item .host-avatar {
    float: left;
    border-style: none;
}

#dashboard-hosts .list-group-item span {
    margin-right: 76px;
    display: block;
    padding-top: 6px;
    padding-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#dashboard-hosts .list-group-item div.os {
    padding-top: 6px;
    padding-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
    color: #888;
    float: right;
}

#dashboard-toolbar > div.dropdown {
    display: inline-block;
}

#dashboard-toolbar .dropdown-toggle span {
    display: inline-block;
    width: 6em;
    text-align: left;
    padding-left: 5px;
}

@media (max-width: 400px) {
    #dashboard-hosts .list-group-item div.os {
        display: none;
    }
    #dashboard-hosts .list-group-item span.reconnecting {
        display: none;
    }
}


.zoom-controls {
    display: none;
}

.show-zoom-controls .zoom-controls {
    display: block;
}

.show-zoom-cursor .zoomable-plot {
    cursor: ew-resize;
}

.dashboard-plot {
    margin-bottom: 10px;
    height: 250px;
}

#host-edit-color {
    width:100px;
    height:26px;
}

#host-edit-color-popover .popover-content {
    width: 220px;
}

#host-edit-color-popover .color-cell {
    display: inline-block;
    width: 25px;
    height: 25px;
    margin: 2px;
}

#host-edit-avatar {
    margin-top: 10px;
}

#host-edit-avatar canvas:hover,
#host-edit-color:hover,
#host-edit-color-popover .color-cell:hover {
    cursor: pointer;
    box-shadow: inset 0px 0px 0px 1px #7BB2DD;
}

#host-edit-apply {
    min-width: 55px;
}

#host-edit-file-input {
    display: none;
}

/* Make the time range buttons equal width */

#dashboard-range-buttons button {
    width: 70px;
}

#sync-users {
    max-height: 126px;
    overflow-y: auto;
    overflow-x: none;
    display: block;
    border: 1px solid #BABABA;
    margin-bottom: 15px;
}

#sync-users table.table {
    margin-bottom: 0;
}

#sync-users .table > tbody > tr:first-child > td {
    border-top: none;
}

#sync-users .center-spinner {
    padding: 15px;
}

#add-unknown-host pre {
    margin: 0;
}

#edit-machine-port {
    width: 100px;
}

/* navbar styles */

.navbar-pf .navbar-toggle {
    color: white;
    font-size: 17px;
    padding: 3px 10px;
    line-height: 1;
}

.navbar-primary .btn-group {
    margin: 5px 0;
}

.navbar-primary .btn-group .btn {
    background-image:  linear-gradient(to bottom, #1D1D1D 0%, #030303 100%);
    padding: 5px 20px;
    color: #fff;
    border-color: #494949;
}

.navbar-primary .btn-group .btn:hover {
    background-image: linear-gradient(to bottom, #2f2f2f 0%, #232323 100%);
}

.navbar-primary .btn-group .btn.active {
    background-image: linear-gradient(to bottom, #2f2fFF 0%, #2323FF 100%);
}


.navbar-primary .btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) {
    border-radius: 5px 0 0 5px;
}

.navbar-primary .btn-group > .btn:last-child:not(:first-child):not(.dropdown-toggle) {
    border-radius: 0 5px 5px 0;
}

.navbar-primary .btn-group > .btn:only-child:not(.dropdown-toggle) {
    border-radius: 5px 5px 5px 5px;
}

/* Style a search box in navigation bar */

.navbar-primary .navbar-form {
    margin: 7px;
    box-shadow: none;
}

.navbar-header .navbar-toggle {
    display: none;
}

.navbar-header .navbar-brand {
    padding: 15px 0 15px 10px;
}

@media (max-width: 767px) {
    .navbar-pf-vertical .navbar-toggle {
        display: block;
    }

    .navbar-header .navbar-brand {
        padding: 13px 0 0;
    }
}

.navbar-default .navbar-form {
    border-color: transparent;
}

#machine-dropdown {
    padding: 0;
    margin: 0;

    .dropdown-menu {
        width: unit(@sidebar-width-full, px);
        top: 6rem;
        /* Align to arrow: 50% width + button padding + arrow width */
        right: ~"calc(-50% + 15px + 10px)";
        left: auto;
        overflow: visible;
        padding: 0;

        > .form-group {
            padding: 10px;
            margin: 0;
            position: relative;

            > .form-control-feedback {
                color: #aaa;
                margin: 11px;
                padding: 0.5em 0 0;
                left: 0;
            }
        }

        > ul[role="menu"] {
            max-height: 75vh;
            overflow: auto;
            overflow-x: hidden;
            padding: 0;
            position: relative;

            > li {
                position: relative;
                padding: 0;

                a {
                    padding: 1ex 2ex;
                    display: block;

                    > span {
                        display: block;
                        text-indent: ~"calc(1ex - 18px)";
                        padding-left: ~"calc(1ex + 18px)";
                    }
                }

                &.active a {
                    background-color: lightblue;
                    border: 1px solid #bee1f4;
                    border-width: 1px 0;
                    background-color: #def3ff;
                }
            }

            .fa-li {
                position: static;
                width: auto;
                padding: 0 1ex 0 0;
                font-size: 16px;
                vertical-align: baseline;
            }
        }
    }

    #machine-link {
        padding: 0 15px;
        margin: 0;
        line-height: 64px;
        color: inherit;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: flex;
        align-items: center;
        text-decoration: none;

        img, b {
            flex: none;
        }

        img {
            width: 24px;
            height: auto;
        }

        span {
            flex: auto;
            padding: 0 0 0 1ex;
        }

        &:hover {
            background: rgba(77, 82, 88, 0.5);
        }
    }

    .dropdown-menu:after {
        border: 10px solid transparent;
        border-top-width: 0;
        border-bottom-color: #fff;
        top: -10px;
        content: '';
        height: 0;
        left: 50%;
        margin: 0 0 0 -5px;
        position: absolute;
        width: 0;
    }

    input {
        padding-left: 25px;
        padding-right: 5px;
    }

    i.fa-search {
        top: 6px;
        left: 0;
    }
}



.nav > li[hidden] {
    display: none;
}

.navbar-advanced {
    display: none;
}

.credential-lock > * {
    display: none !important;
}

.credential-lock.credential-locked > *:first-child {
    display: block !important;
}

.credential-lock.credential-unlocked > *:last-child {
    display: block !important;
}

thead.credential-lock.credential-locked > *:first-child {
    display: table-row !important;
}

thead.credential-lock.credential-unlocked > *:last-child {
    display: table-row !important;
}


/* The server avatar */
#server-avatar {
    width:       128px;
    height:      128px;
    margin-left:  21px;     /* This centers it in #server-nav-column. */
    border-radius: 5px;
}

.server-graph .flot-y-axis .flot-tick-label {
    margin-right: 5px;
}

/*
 * The oops status in the navbar, used when an unhandled exception
 * occurs.
 */

.oops-status {
    color: red;
    font-weight: bold;
}

.slider {
    display: block;
    margin: 10px 10px;
    height: 5px;
    white-space: nowrap;
    font-size: 0px;
    background-color: #e7e7e7;
    cursor: pointer;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
}

.slider-warning {
    background-color: #d4a096;
}

.slider-bar {
    position: relative;
    height: 5px;
}

.slider > .slider-bar > .slider-bar {
    border-right: 3px solid white;
    height: 5px;
    position: relative;
}

.slider > .slider-bar > .slider-bar {
    display: inline-block;
}

.slider > div:first-child {
    float: left;
    background-color: #0099d3;
}

.slider-disabled > div:first-child {
    cursor: auto;
    background-color: #e7e7e7;
}

.slider-thumb {
    position: absolute;
    border-radius: 9px;
    background-color: #0099d3;
    width: 18px;
    height: 18px;
    top: -6px;
    right: -9px;
    content: '.';
    cursor: pointer;
    border: 1px solid #267da1;
    z-index: 1;
}

.slider-disabled .slider-thumb {
    background-color: #e7e7e7;
    border: 1px solid #d7d7d7;
    cursor: auto;
}

/* server overview dashboard */
#server .info-table-ct button {
    max-width: 300px;
}

#server .info-table-ct td:first-child {
    max-width: 50%
}

#server .info-table-ct {
    width: 100%;
}

@media (min-width: 992px) {
    #server .info-table-ct {
        table-layout: fixed;
        width: 100%;
        min-width: 220px;
    }

    /* server overview dashboard */
    #server .info-table-ct-container td button {
        max-width: 100%;
    }
}

@media (max-width: 991px) {
    #server .info-table-ct-container {
        padding: 0 0 20px;
        overflow: hidden;

        th,
        td:first-child {
            padding-left: 0;
        }

        td:last-child {
            max-width: 50vw;
        }
    }
}

@media (max-width: 480px) {
    #server .info-table-ct-container {

        td {
            overflow: auto;
            word-wrap: break-word;

            /* server overview dashboard */
            button {
                max-width: 200px;
            }
        }
    }
}

#connecting {
    height: 100%;
    background-color: #eeeeec;
    text-align: center;
    padding-top: 120px;
}

/* workaround: make text red for select if contained in has-error, not in patternfly */
.has-error > .bootstrap-select > button > span {
    color: #A94442;
}

/* System information */

#systime-date-input {
    display: inline;
    width: 150px;
}

#systime-time-hours,
#systime-time-minutes {
    display: inline;
    width: 50px;
}

/* index page */

.oops-status {
    color: red;
    font-weight: bold;
}

#display-language-list {
    width: 100%;
}

#display-language-list option {
    padding: 10px;
}

iframe.container-frame {
    display: none;
    border: none;
    width: 100%;
}

/* Credentials dialog */

#credentials-dialog {
    .modal-body {
        max-height: 500px;
    }

    .btn-onoff-ct .btn {
        padding-top: 1px;
        padding-bottom: 1px;
        height: 24px;
        line-height: 24px;
        display: inline;
    }

    table.credential-listing {
        margin-top: 0px;
        width: 100%;

        thead tr.load-custom-key {
            td.has-error div.dialog-error {
                display: block;
            }

            td {
                padding-left: 15px;
                padding-bottom: 15px;
                padding-top: 0;

                .dropdown-menu {
                    max-height: 100px;
                }

                input {
                    width: 500px;
                }

                button {
                    padding-right: 10px;
                    padding-left: 10px;
                }

                span.input-group-btn {
                    border-left: 2px solid transparent;
                }

                div.dialog-error {
                    display: none;
                }
            }
        }

        tbody.ssh-add-key-body {
            display: none;
        }

        tbody.ssh-add-key-body.unlock {
            display: table-row-group;
        }

        dd, dt {
            padding-top: 3px;
            min-height: 26px;
        }

        dt {
            min-width: 80px;
            max-width: 100px;
        }

        input[type='password'] {
            width: 300px;
        }


        textarea {
            color: #222 !important;
        }

        dt label {
            margin-bottom: 0px;
        }
    }

    thead td {
        padding-left: 15px;
        padding-bottom: 15px;
    }

    tbody .credential-unlock {
        display: none;
    }

    tbody.unlock .credential-panel {
        display: none !important;
    }

    tbody.unlock .credential-unlock {
        display: block;
    }
}

.credential-data {
    word-wrap: break-word;
    word-break: break-all;
}

.banned {
    color: #ff0000;
    font-size: 75px;
    line-height: 75px;
    float: left;
    padding-right: 15px;
}

.listing-ct-body .alert {
    border: none;
    margin: 0px 0px 10px 0px;
    padding: 0px;
    background-color: transparent;
}

.listing-ct-body .alert .fa {
    position: relative;
    left: 0px;
    top: 3px;
    padding-right: 5px;
}

#machine-spinner {
    margin: 10px;
}

.spinner-white {
    border-bottom: 4px solid rgba(255, 255, 255, 0.25);
    border-left: 4px solid rgba(255, 255, 255, 0.25);
    border-right: 4px solid rgba(255, 255, 255, 0.25);
    border-top: 4px solid rgba(255, 255, 255, 0.75);
}


/* Scrollable modal body, needs max-height set elsewhere */
.modal-scrollable {
    overflow-y: auto;
    margin-right: 7px;
    padding-right: 8px;
    margin-top: 15px;
    padding-top: 0px;
}

/* allow text only branding */
.navbar-pf .navbar-brand {
    text-transform: uppercase;
    margin: 0 8px;
}

.navbar-pf .navbar-brand:hover {
    color: #F1F1F1;
}

.navbar-pf .navbar-utility {
    font-size: 13px;
}

/***
Disclaimer: Fixing the navbar dropdown requires consideration of CSS
specificity. As PatternFly is super-specific, we either had to use
!important everywhere or include IDs.

What follows is not best-practice, but a necessary fix.
It is less bad than using !important, at least.
***/

#topnav {
    .fa,
    .pficon {
        /* Normalize the icons in the navbar */
        line-height: inherit;
        margin-right: 5px;
        padding-right: 0;
        position: static;
    }
}
@media (min-width: 768px) {
    /* Override navbar utility menu for desktop */
    #topnav {
        .navbar-utility > li > a,
        .navbar-utility > li > span {
            line-height: 50px;
            margin: 0;
            padding: 0 10px;
            font-size: 13px;
        }
    }

    #machine-spinner {
        /* Vertical alignment is a hack here. (50px - 24px) / 2 = 13px */
        margin-top: 13px;
    }
}
@media (max-width: 767px) {
    /* Override navbar utility menu for mobile */
    #topnav {
        .navbar-utility > li > a,
        .navbar-utility > li > span {
            margin: 0;
            padding: 0 20px;
            line-height: 54px;
        }
        .dropdown-menu > li > a,
        .dropdown-menu > li > span {
            /* Make menu items a consistent, touch-friendly size */
            padding: 0 40px;
            line-height: 54px;
        }
    }
}
