/*
 * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

.network-type-filter-scope-bar.default-item-selected:not(:hover) {
    --scope-bar-text-color-override: var(--text-color);
    --scope-bar-background-color-override: transparent;
    --scope-bar-border-color-override: transparent;
}

.network-type-filter-scope-bar.default-item-selected:hover {
    --scope-bar-background-opacity-override: 0.5;
}

.network-other-filters-button > .glyph {
    width: 16px;
    height: 16px;
    color: var(--glyph-color);
    opacity: var(--glyph-opacity);
}

.network-other-filters-button:active > .glyph {
    color: var(--glyph-color-pressed);
}

.network-other-filters-button.active > .glyph {
    color: var(--glyph-color-active);
}

.network-other-filters-button.active:active > .glyph {
    color: var(--glyph-color-active-pressed);
}

.content-view.tab.network > .content-browser > .navigation-bar .hierarchical-path .icon {
    margin-inline: 8px 4px;
}

.network-overview-icon > .icon {
    content: url(../Images/NetworkOverview.svg);
}

.network-har-icon > .icon {
    content: url(../Images/NetworkHAR.svg);
}

.content-view.network .network-table {
    display: flex;
    flex-direction: column;
}

.content-view.network .network-table > .table .icon {
    position: relative;
    width: 16px;
    height: 16px;
    bottom: 1px;
    vertical-align: middle;
    margin-inline-end: 4px;
}

.network-table > .table li:not(.filler, .selected) .cell:not(.name, .current-session),
.network-table > .table li:not(.filler, .selected) .cell.name:not(.current-session) > * {
    opacity: 0.5;
}

.network-table > .table li:not(.filler) .cell.name {
    cursor: pointer;
}

body.shift-key-pressed .network-table > .table:hover li:not(:hover, .selected, .initiated) .cell {
    color: var(--text-color-transparent);
}

body.shift-key-pressed .network-table > .table:hover li:not(:hover, .selected, .initiated) .cell > * {
    color: var(--text-color);
    opacity: 0.4;
}

body.shift-key-pressed .network-table > .table:hover li.initiated .cell.name::after {
    display: inline-block;
    float: right;
    width: 4px;
    height: 4px;
    margin-top: 8px;
    content: "";
    background-color: var(--glyph-color-active);
    border-radius: 50%;
}

.network-table > .table .cell.dom-node.name .icon {
    content: url(../Images/TypeIcons.svg#DOMElement-light);
}

.network-table > .table .cell.dom-node.name .disclosure {
    width: 13px;
    height: 13px;
    vertical-align: -2px;
    content: url(../Images/DisclosureTriangles.svg#closed-normal);
    background-size: 13px 13px;
    background-repeat: no-repeat;
}

body[dir=rtl] .network-table > .table .cell.dom-node.name .disclosure {
    transform: scaleX(-1);
}

.network-table:focus > .table li.selected .cell.dom-node.name .disclosure {
    content: url(../Images/DisclosureTriangles.svg#closed-selected);
}

.network-table > .table .cell.dom-node.name .disclosure.expanded {
    content: url(../Images/DisclosureTriangles.svg#open-normal);
}

.network-table:focus > .table li.selected .cell.dom-node.name .disclosure.expanded {
    content: url(../Images/DisclosureTriangles.svg#open-selected);
}

.network-table > .table.grouped .data-container .cell.name {
    --item-padding-start: 19px;
    --item-disclosure-width: 11px;
}

.network-table > .table.grouped .data-container .cell:not(.parent).name {
    padding-inline-start: var(--item-padding-start);
}

.network-table > .table.grouped .data-container .cell.child.name {
    padding-inline-start: calc(var(--item-padding-start) + var(--item-disclosure-width));
}

.network-table > .table .data-container .cell.name .range {
    color: hsla(0, 0%, 0%, 0.7);
}

.network-table > .table .data-container .cell.name .range::before {
    content: "\00A0\2014\00A0"; /* &nbsp;&mdash;&nbsp; */;
}

.network-table:focus > .table .data-container li.selected .cell.name .range {
    color: hsla(0, 0%, 100%, 0.9);
}

.network-table > .table li:not(.selected) .cell:matches(.cache-type, .multiple) {
    color: var(--text-color-gray-medium);
}

.network-table > .table .cell.domain > .lock {
    width: 8px;
    height: 10px;
    content: url(../Images/Locked.svg);
    margin-inline-end: 5px;
}

.network-table > .table li.selected .cell.domain > .lock {
    /* FIXME: <https://webkit.org/b/189773> Web Inspector: create special Network waterfall for media events */
    filter: invert();
}

.network-table > .table .cell.name > .status {
    margin-inline-start: 4px;
}

body[dir=ltr] .network-table > .table .cell.name > .status {
    float: right;
}

body[dir=rtl] .network-table > .table .cell.name > .status {
    float: left;
}

.network-table > .table .cell.name > .status .indeterminate-progress-spinner {
    margin-top: 3px;
    width: 14px;
    height: 14px;
}

.network-table.showing-detail > .table .cell:not(.name) {
    display: none;
}

.network-table.showing-detail > .table .resizer:not(:first-of-type) {
    display: none;
}

.network-table.showing-detail > .table .timeline-ruler {
    display: none;
}

.network-table > .table .header .cell.waterfall {
    /* Hide the label for this column. */
    color: transparent;
}

.network-table > .table .header .cell.waterfall:matches(.sort-ascending, .sort-descending) {
    background-color: var(--background-color-selected);
}

.network-table > .table :not(.header) .cell:first-of-type {
    background: rgba(0, 0, 0, 0.07);
}

.network-table > .table :not(.header) .cell.waterfall {
    position: absolute;
    height: 20px;
    border-inline-start: 1px solid var(--graph-line-color);
}

.network-table > .table :not(.header) .cell.waterfall .waterfall-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.network-table > .table :not(.header) .cell.waterfall .waterfall-container > .dom-event {
    position: absolute;
    top: calc(50% - (var(--node-waterfall-dom-event-size) / 2));
    min-width: var(--node-waterfall-dom-event-size);
    height: var(--node-waterfall-dom-event-size);
    background-color: var(--selected-background-color-active);
    border-radius: calc(var(--node-waterfall-dom-event-size) / 2);
}

.network-table > .table :not(.header) .cell.waterfall .waterfall-container > .dom-activity {
    position: absolute;
    top: calc(50% - 0.5px);
    border-top: 1px dashed var(--selected-background-color-active);
}

.network-table > .table :not(.header) .cell.waterfall .waterfall-container > .dom-activity.playing {
    border-top-style: solid;
}

.network-table > .table :not(.header) .cell.waterfall .waterfall-container > .area {
    position: absolute;
    top: var(--area-padding);
    height: calc(100% - (var(--area-padding) * 2));

    /* Half of the vertical space above any .dom-event node */
    --area-padding: calc((50% - (var(--node-waterfall-dom-event-size) / 2)) / 2);
}

.network-table > .table :not(.header) .cell.waterfall .waterfall-container > .area.dom-fullscreen {
    background-color: hsl(0, 0%, 40%);
}

.network-table > .table :not(.header) .cell.waterfall .waterfall-container > .area.power-efficient-playback {
    background-color: var(--network-request-color);
}

.network-table > .table .timeline-ruler {
    position: absolute;
    top: 0;
    bottom: 0;
    overflow: hidden;
}

.network-table > .table .timeline-ruler > .header {
    top: calc(var(--navigation-bar-height) - var(--timeline-ruler-height));
}

.content-view.network-table > .message-text-view {
    top: var(--navigation-bar-height);
    bottom: var(--network-statistics-height);
}

.content-view.network-table > .message-text-view > .message {
    font-size: var(--message-text-view-font-size);
    font-weight: normal;
}

/* Styles also used by `WI.ResourceTimingBreakdownView` (also inside a `WI.Popover`). */

.network-table .error {
    color: var(--error-text-color);
}

.waterfall.network .block {
    position: absolute;
    top: 8px;
    min-width: 2px;
    height: 4px;

    --start-radius: 2px;
    --end-radius: 2px;
}

body[dir=ltr] .waterfall.network .block {
    border-top-left-radius: var(--start-radius);
    border-top-right-radius: var(--end-radius);
    border-bottom-left-radius: var(--start-radius);
    border-bottom-right-radius: var(--end-radius);
}

body[dir=rtl] .waterfall.network .block {
    border-top-left-radius: var(--end-radius);
    border-top-right-radius: var(--start-radius);
    border-bottom-left-radius: var(--end-radius);
    border-bottom-right-radius: var(--start-radius);
}

.waterfall.network .block + .block {
    --start-radius: 0;
    --end-radius: 0;
}

.waterfall.network .block:matches(.mouse-tracking, .filler) + .block:not(.mouse-tracking, .filler),
.waterfall.network .block:not(.request, .response) + :matches(.request, .response) {
    --start-radius: 2px;
}

.waterfall.network .block:last-child {
    --end-radius: 2px;
}

.waterfall.network .block.request,
.waterfall.network .block.response {
    top: 3px;
    height: 14px;
}

.waterfall.network .block.mouse-tracking {
    top: 1px;
    z-index: 2;
    height: 18px;
}

.waterfall.network .block.filler {
    top: 9px;
    height: 2px;
    background-color: lightgrey;
}

.waterfall.network .block.redirect {
    background-color: var(--network-redirect-color);
}

.waterfall.network .block.queue {
    background-color: var(--network-queue-color);
}

.waterfall.network .block.dns {
    background-color: var(--network-dns-color);
}

.waterfall.network .block.connect {
    background-color: var(--network-connect-color);
}

.waterfall.network .block.secure {
    background-color: var(--network-secure-color);
}

.waterfall.network .block.request {
    background-color: var(--network-request-color);
}

.waterfall.network .block.response {
    background-color: var(--network-response-color);
}

.network-table > .statistics {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: var(--network-statistics-height);
    padding: 4px 0;
    border-top: 1px solid var(--border-color);
}

.network-table > .statistics > .statistic {
    display: flex;
    padding: 0 8px;
}

.network-table > .statistics > .statistic[hidden] {
    display: none;
}

.network-table > .statistics > .statistic > .icon {
    width: 16px;
    height: 16px;
}

.network-table > .statistics > .statistic > .text {
    padding-top: 1px;
    padding-inline-start: 4px;
    -webkit-user-select: all;
    font-variant-numeric: tabular-nums;
}

@media (prefers-color-scheme: dark) {
    .content-view.tab.network > .content-browser > .navigation-bar .hierarchical-path .icon {
        filter: invert(88%);
    }

    .network-table > .table .cell.domain > .lock {
        filter: var(--filter-invert);
    }

    .network-table > .table .data-container .cell.name .range {
        color: var(--text-color-secondary);
    }

    .network-table > .table .cell.dom-node.name .icon {
        content: url(../Images/TypeIcons.svg#DOMElement-dark);
    }
}
