/*
 * 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 "@patternfly/patternfly/components/Button/button.scss";

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

/* Hacks on top for now */

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(--ct-color-link)
}

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

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

#connecting {
    height: 100%;
    background-color: var(--ct-global--palette--black-250);
    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-modal {
    /* Do not let the language menu expand to the end of the page */
    .pf-c-menu__content {
        max-height: 20rem;
        overflow: auto;
    }
}

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

/* Credentials dialog */
#ssh-file-container, #ssh-file-add {
  display: inline-block;
}

#credentials-dialog {
    .pf-c-modal-box__body {
        // Turn off modal scrolling
        overflow: visible;
    }

    .modal-body {
        display: grid;
        grid-template-rows: auto 1fr;
        // Full screen minus the button, heading, and padding
        max-height: calc(100vh - (var(--pf-global--spacer--md) * 11));
        grid-gap: var(--pf-global--spacer--md);
    }

    .table-scrollable {
        // Scroll the table content instead
        overflow: auto;
    }

    table {
        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(--pf-global--palette--black-850) !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;
}

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

.hostkey-fingerprint {
  font-size: large;
  font-weight: bold;
  margin-top: var(--pf-global--spacer--md);
  border: none;
  background-color: transparent;
}

.hostkey-type {
  font-size: small;
}

.hostkey-verify-help-cmds {
  border-radius: 0.25rem;
  padding: 0.5rem 1rem;
  background: #ddd;
  margin-top: var(--pf-global--spacer--md);
  margin-bottom: var(--pf-global--spacer--md);
}
