@use "ct-card";
@use "page";

@import "global-variables";
@import "@patternfly/patternfly/components/Table/table.scss";
@import "@patternfly/patternfly/components/Table/table-grid.scss";
@import "@patternfly/patternfly/components/Toolbar/toolbar.scss";

#firewall,
#network-page {
    .pf-c-card {
        @extend .ct-card;
    }
}

#networking, #network-interface {
    .pf-l-gallery {
        --pf-l-gallery--GridTemplateColumns: 1fr;
    }
}

// General networking page overview
.network-page {
    .cockpit-log-panel {
        max-width: 100vw;
    }
}

#network-interface {
    @at-root {
        #network-interface-name {
            font-weight: var(--pf-c-card__title--FontWeight);
        }

        .network-interface-status > span {
            overflow-wrap: anywhere;
        }
    }
}

.network-number-field {
    max-width: 4em;
}

.network-graph {
    height: 180px;
}

.pf-c-page__main-breadcrumb + .networking-graphs {
    // Remove the top padding when following a breadcrumb
    padding-top: 0;
}

// Constrain widths of networking headers (on both the main page and in network-interface-members)
th {
    &.networking-speed {
        width: 20%;
    }

    &.networking-spacer {
        width: var(--pf-global--spacer--4xl);
    }

    &.networking-action {
        width: var(--pf-global--spacer--3xl);
    }
}

.network-interface-details {
    &-title {
        display: grid;
        grid-auto-flow: column;
        grid-gap: var(--pf-global--spacer--md);
    }

    &-delete {
        margin-right: var(--pf-global--spacer--lg);
    }

    // Seems to be used for the "general" checkbox
    .networking-controls {
        label {
            font-weight: inherit;
        }

        input {
            margin-left: 0px;
        }
    }
}

#networking-interfaces, #networking-unmanaged-interfaces {
    th[data-label=Name] button {
        font-weight: var(--pf-global--FontWeight--bold);

        // Preserve the same baseline as other elements, so items align
        display: inline;
        // Expand the link to the container, for easier clickability
        width: 100%;
    }
}

.network-interface-members {
    .pf-c-switch {
        margin-right: var(--pf-global--spacer--md);
    }
    .pf-c-table > tbody > tr > td:last-child {
        text-align: right;
        --pf-c-table--cell--Width: 10%;
    }
}

// If the button is not the first item in the DescriptionListDescription all left padding
.network-interface-settings dd .pf-c-description-list__text button:not(:first-child) {
    padding-left: var(--pf-global--spacer--md);
}

#network-mtu-settings-custom {
    position: relative;
    top: 6px;
}

#network-mtu-settings-input {
    margin-left: 0.5em;
    width: 5em;
    display: inline;
}

// Temporary curtain to hide the content as it loads
#testing-connection-curtain {
    z-index: 2000;
}

.pf-l-flex > .network-ip-settings-method {
    width: 12rem;
}

#network-ip-settings-body {
    .pf-c-form__label {
        // Don't allow labels to wrap
        white-space: nowrap
    }

    .remove-button-group {
        // Move 'Remove' button the the end of the row
        grid-column: -1;
        // Move 'Remove' button to the bottom of the line so as to align with the other form fields
        display: flex;
        align-items: flex-end;
    }
}

/********** Firewall section **********/

#add-services-dialog {
    .service-list {
        max-height: 13rem;
        overflow-y: auto;
    }

    .service-list-item-heading {
        font-size: 1.2em;
        margin: 0;
    }

    .service-list-item-text {
        display: flex;
        flex-wrap: wrap;
    }

    .service-ports {
        opacity: 0.75;

        &:first-of-type {
            margin-right: 1em;
        }
    }

    .add-services-dialog-type {
        display: flex;
    }

    .has-error {
        animation: 300ms error-slide-down ease-in-out;
        color: #c00;
        padding: 0;

        &:empty {
            display: none;
        }
    }
}

#firewall {
    height: 100%;

    .ct-table tbody tr:first-of-type td:nth-child(2) {
        font-weight: var(--pf-global--FontWeight--bold);
    }
}

@media screen and (max-width: $pf-global--breakpoint--md) {
    .zone-section-heading.pf-c-card__header {
         padding-left: var(--pf-global--spacer--md);
    }
}

#delete-confirmation-dialog {
    .delete-confirmation-body {
        display: flex;
    }
}

#add-zone-dialog legend {
    color: var(--ct-color-subtle-copy);
    font-size: var(--pf-global--FontSize--sm);
}

.add-zone-zones legend {
    line-height: 3;
}

#add-zone-dialog .add-zone-zones .pf-c-radio__label {
    text-transform: capitalize;
}

/* Move firewalld zones higher in z-index (so lines can go behind) */
.add-zone-zones-firewalld {
    input {
        position: relative;
        z-index: 2;
        width: 16px;
        height: 16px;
    }

    > label {
        /* FIXME: Add lines behind the radio buttons */
        &::after {
            border-bottom: 1px solid #d1d1d1;
            content: "";
        }

        /* Start line at the midpoint for the first radio */
        &:first-of-type::after {
            left: 50%;
        }

        /* End line at the midpoint for the last radio */
        &:last-of-type::after {
            right: 50%;
        }
    }
}

/* Display labels below buttons */
.add-zone-zones-firewalld, .add-zone-zones-custom {
   > label.radio {
        display: inline-flex;
    }
}

#add-zone-description-readonly {
    padding: 0.5rem 0 0;
    color: var(--ct-color-subtle-copy);
}

#add-zone-services-readonly legend {
    padding: 0;
    line-height: 1;
}

// Animation for Firewall's add service dialog,
// as a sudden transition would be (otherwise) too jarring
@keyframes error-slide-down {
    0% {
        line-height: 0;
        height: 0;
        opacity: 0;
        overflow: hidden;
    }

    100% {
        line-height: inherit;
        height: auto;
        opacity: 1;
    }
}

.pf-c-dropdown__menu-item.pf-m-danger {
    color: var(--pf-global--danger-color--200);
}

/* End Firewall specific CSS */
