/*
 * 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 "../lib/page.scss";
@import "../lib/table.css";
@import "variables";
@import "nav.scss";
@import "active-pages.scss";
@import "../../node_modules/@patternfly/patternfly/components/Button/button.scss";

:root {
    --ct-color-host-accent: var(--pf-global--active-color--100);
}

/* Hacks on top for now */

html, body {
    height: 100%;
    width: 100%;
}

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

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

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

#machine-change-auth > p {
    margin-bottom: 5px;
}

// Fix fingerprint layout
.add-host-fingerprint {
    margin-top: var(--pf-global--spacer--md);

    td {
        padding: 0;
        line-height: inherit;
        height: auto;
        vertical-align: middle !important;

        &:first-child {
            padding-right: var(--pf-global--spacer--md);
        }
    }
}

.machine-key {
    margin: 0;
    white-space: pre-line;
    padding: var(--pf-global--spacer--xs) var(--pf-global--spacer--sm);
}

.login-setup-checkbox-wrapper {
    // Use a flex layout to better vertically align the contents to the grid
    display: flex;
}

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

#navbar-docs-items a:not([data-toggle]) {
    color: var(--color-link)
}

#navbar-docs .dropdown-menu a i.fa{
    padding-left: 5px;
    vertical-align: baseline;
}

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

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

// TODO why is this slider here??
.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: var(--color-link);
}

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

.slider-thumb {
    position: absolute;
    border-radius: 9px;
    background-color: var(--color-link);
    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;
}

#connecting {
    height: 100%;
    background-color: var(--color-gray-2);
    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,
#systime-time-hours,
#systime-time-minutes {
    display: inline;
}

/* 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 */
#ssh-file-container, #ssh-file-add {
  display: inline-block;
}

#credentials-dialog {
    div.table-scrollable {
        max-height: 500px;
        overflow-y: auto;
        margin-right: 7px;
        padding-right: 8px;
        margin-top: 15px;
        padding-top: 0px;
    }

    table {
        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: var(--color-gray-12) !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 {
    overflow-wrap: break-word;
    word-break: break-all;
}

.banned {
    color: var(--color-red-hat-red);
    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;
}

.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);
}

// Page layout

$phone: 767px;
$desktop: $phone + 1px;

.page {
    --nav-width: 15rem;
    display: grid;
    width: 100%;
    height: 100%;

    @media (max-width: $phone) {
        grid-template-areas: "main main main" "sidebar switcher header";
        grid-template-rows: 1fr 4rem;
        grid-template-columns: 1fr auto auto;
        overflow: hidden;

        .area-ct-subnav {
            grid-area: main;
        }

        .sidebar-toggle {
            grid-area: sidebar;
            display: flex;
            background: var(--pf-global--BackgroundColor--dark-100);
        }

        > .header,
        > .navbar,
        > .sidebar-toggle {
            background:
                // Line on bottom
                linear-gradient(to top,
                    var(--ct-color-host-accent),
                    var(--ct-color-host-accent) 0.1875rem,
                    transparent 0.1875rem
                ),
                // Base color (with subtle glow)
                linear-gradient(to top,
                    var(--ct-color-host-accent) -1.5rem,
                    var(--pf-global--BackgroundColor--dark-100) 0.75rem
                );
        }
    }

    @media (min-width: $desktop) {
        grid-template-areas: "switcher header" "sidebar main";
        grid-template-rows: max-content 1fr;
        grid-template-columns: minmax(min-content, var(--nav-width)) 1fr;

        > .navbar {
            max-width: var(--nav-width);
        }

        .sidebar {
            grid-area: sidebar;
        }

        .sidebar-toggle {
            grid-area: none;
            display: none;
        }

        > .header {
            background:
                // Shadow to the left
                linear-gradient(to right,
                    var(--pf-global--BackgroundColor--dark-100) -1rem,
                    transparent 1rem
                ),
                // Line on top
                linear-gradient(to bottom,
                    var(--ct-color-host-accent),
                    var(--ct-color-host-accent) 0.1875rem,
                    transparent 0.1875rem
                ),
                // Base color (with subtle glow)
                linear-gradient(to bottom,
                    var(--ct-color-host-accent) -1.5rem,
                    var(--pf-global--BackgroundColor--dark-100) 0.75rem
                );
        }
    }

    // Shrink nav for VMs @ 1024×768 (and below)
    @media (max-width: 1024px) and (max-height: 768px) and (orientation: landscape) {
        --nav-width: 14rem;
    }

    .area-ct-content {
        grid-area: main;
    }

    .header {
        grid-area: header;
    }
}
