/* Global color tokens and reusable panel styling values. */
:root {
    --bg-top: #f2f4f8;
    --bg-bottom: #d7dde7;
    --panel-bg: rgba(251, 253, 255, 0.94);
    --panel-border: rgba(82, 101, 131, 0.2);
    --panel-shadow: 0 18px 40px rgba(34, 51, 84, 0.16);
    --panel-shadow-soft: 0 10px 20px rgba(34, 51, 84, 0.08);
    --title: #19324d;
    --text: #31465f;
    --muted: #6b7d93;
    --accent: #2f6fa8;
    --accent-dark: #1f4f79;
    --accent-soft: rgba(47, 111, 168, 0.1);
    --grid-line: rgba(91, 114, 146, 0.12);
    --input-bg: #f8fbff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow: auto;
    background:
        radial-gradient(circle at top left, rgba(102, 157, 211, 0.18), transparent 34%),
        linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
    color: var(--text);
    font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.connection_banner {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: none;
    padding: 10px 16px;
    border: 1px solid rgba(42, 74, 112, 0.18);
    border-radius: 999px;
    background: rgba(245, 250, 255, 0.72);
    box-shadow: 0 12px 24px rgba(25, 50, 77, 0.12);
    backdrop-filter: blur(10px);
    color: var(--title);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    pointer-events: none;
}

/* Show the temporary instruction banner only while the user is connecting devices. */
.connection_banner.is-visible {
    display: block;
}

.graph_modal {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(21, 34, 52, 0.22);
    backdrop-filter: blur(6px);
}

.graph_modal.is-visible {
    display: flex;
}

.graph_window {
    width: min(820px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 18px 20px 20px;
    border: 1px solid rgba(54, 82, 117, 0.18);
    border-radius: 22px;
    background: rgba(250, 252, 255, 0.96);
    box-shadow: 0 26px 48px rgba(24, 42, 66, 0.24);
}

.graph_header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.graph_header h2 {
    margin: 0;
    color: var(--title);
    font-size: 1.08rem;
}

.graph_subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.76rem;
}

.graph_close_button {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
}

.graph_toggle_row {
    display: flex;
    gap: 8px;
    margin: 14px 0 12px;
}

.graph_toggle_button {
    padding: 8px 12px;
    border: 1px solid rgba(67, 96, 131, 0.16);
    border-radius: 999px;
    background: rgba(234, 241, 249, 0.9);
    color: var(--title);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.graph_toggle_button.is-active {
    background: linear-gradient(180deg, #3f80ba, #2d6597);
    color: #fff;
}

.graph_empty_state {
    display: none;
    margin: 32px 0;
    color: var(--muted);
    font-size: 0.86rem;
    text-align: center;
}

.graph_empty_state.is-visible {
    display: block;
}

.graph_svg {
    width: 100%;
    height: 420px;
    border-radius: 16px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(240, 246, 252, 0.94));
}

/* The page is a three-part workbench: amp panel, canvas, and device palette. */
.main_body {
    display: flex;
    align-items: flex-start;
    gap: 0;
    width: max-content;
    min-width: 3460px;
}

/* Shared styling for the top utility buttons. */
.header_buttons button {
    position: relative;
    top: 12px;
    left: 230px;
    padding: 10px 18px;
    border: 1px solid rgba(28, 62, 96, 0.14);
    border-radius: 999px;
    background: linear-gradient(180deg, #3f80ba, #2d6597);
    color: #f7fbff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 10px 18px rgba(25, 50, 77, 0.16);
    transition: left 1s ease, transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.header_buttons button:hover {
    background: linear-gradient(180deg, #4d92cf, #356f9f);
    transform: translateY(-1px);
    box-shadow: 0 14px 24px rgba(25, 50, 77, 0.2);
}

/* Section heading styles reused by the amp panel and device palette. */
.panel_heading {
    margin-bottom: 10px;
}

.panel_heading h2 {
    margin: 0;
    color: var(--title);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.panel_eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.panel_hint {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.35;
}

/* Compact card styling for the left-side amp source panel. */
#amp_input {
    width: 208px;
    max-height: calc(100vh - 32px);
    overflow: auto;
    position: relative;
    left: 5px;
    margin-top: 10px;
    padding: 14px 12px 12px;
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(239, 245, 252, 0.96));
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(10px);
    transition: left 1s ease;
}

/* Tight table styling keeps the full frequency list visible on smaller screens. */
#amp_input table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.71rem;
}

#amp_input thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 7px 6px;
    border-bottom: 1px solid rgba(58, 89, 128, 0.18);
    background: rgba(224, 234, 245, 0.96);
    color: var(--title);
    font-size: 0.63rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: left;
}

#amp_input tbody tr:nth-child(odd) {
    background: rgba(248, 251, 255, 0.7);
}

#amp_input tbody tr:nth-child(even) {
    background: rgba(236, 243, 250, 0.65);
}

#amp_input td {
    padding: 6px 6px;
    border-bottom: 1px solid rgba(91, 114, 146, 0.08);
}

#amp_input td:first-child {
    font-weight: 600;
    white-space: nowrap;
}

.amp_input_num {
    width: 52px;
    padding: 4px 6px;
    border: 1px solid rgba(78, 105, 142, 0.2);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--title);
    font-size: 0.73rem;
    font-weight: 700;
    text-align: right;
    box-shadow: inset 0 1px 2px rgba(37, 55, 77, 0.08);
}

.amp_input_num:focus {
    outline: none;
    border-color: rgba(47, 111, 168, 0.5);
    box-shadow: 0 0 0 3px rgba(47, 111, 168, 0.14);
}

/* Right-side device palette sized to stay usable on smaller laptop screens. */
.device_selection {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 160px;
    max-height: calc(100vh - 20px);
    overflow: auto;
    padding: 14px 10px 10px;
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(247, 250, 253, 0.96), rgba(232, 239, 247, 0.95));
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(12px);
}

/* Device tiles make the icon palette easier to scan and click. */
.device_grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.device_tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px 6px 7px;
    border: 1px solid rgba(69, 95, 129, 0.14);
    border-radius: 12px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(238, 244, 250, 0.9));
    box-shadow: var(--panel-shadow-soft);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.device_tile:hover {
    transform: translateY(-2px);
    border-color: rgba(47, 111, 168, 0.28);
    box-shadow: 0 14px 24px rgba(34, 51, 84, 0.12);
}

.coax_tile {
    background:
        linear-gradient(180deg, rgba(230, 242, 255, 0.98), rgba(217, 232, 247, 0.98));
    border-color: rgba(47, 111, 168, 0.26);
}

.device_label {
    color: var(--title);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
}

.clickable-image,
.coax-image {
    display: block;
    height: auto;
    cursor: grab;
    filter: drop-shadow(0 5px 8px rgba(30, 46, 67, 0.14));
    transition: transform 0.16s ease, filter 0.16s ease;
}

.clickable-image:hover,
.coax-image:hover {
    transform: scale(1.03);
    filter: drop-shadow(0 8px 12px rgba(30, 46, 67, 0.18));
}

/* Keep each source icon visually balanced inside the compact palette. */
#tap,
#splitter {
    width: 108px;
}

#amp {
    width: 92px;
}

#node,
#inline_eq {
    width: 86px;
}

#coax {
    width: 82px;
}

/* Subtle grid lines help the empty canvas feel like a technical workspace. */
#canvas {
    position: relative;
    width: 3200px;
    min-width: 3200px;
    height: 10000px;
    top: 20px;
    left: 58px;
    bottom: 10px;
    right: 50px;
    background-image:
        linear-gradient(to right, transparent 0, transparent 23px, var(--grid-line) 24px),
        linear-gradient(to bottom, transparent 0, transparent 23px, var(--grid-line) 24px);
    background-size: 24px 24px;
    transition: left 1s ease;
}

/* These styles affect dynamically-created device cards placed on the canvas. */
.draggable-container {
    display: inline-block;
    text-align: center;
    cursor: move;
    position: absolute;
    padding: 38px 12px 12px;
    min-width: 118px;
    border: 1px solid rgba(72, 93, 121, 0.16);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.55);
    box-shadow: var(--panel-shadow-soft);
}

.device_graph_button,
.device_toggle_button,
.device_delete_button {
    position: absolute;
    top: 6px;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    z-index: 3;
}

.device_graph_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: auto;
    min-width: 24px;
    padding: 0 2px;
    color: var(--accent-dark);
    font-size: 14px;
    right: 54px;
}

.device_graph_button.tap-primary {
    right: 116px;
}

.device_graph_button.tap-secondary {
    right: 70px;
}

.graph_button_badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.device_toggle_button {
    right: 30px;
    color: var(--accent-dark);
}

.device_delete_button {
    right: 6px;
    color: #c53737;
}

.device_toggle_button:hover {
    color: var(--accent);
}

.device_delete_button:hover {
    color: #e04545;
}

.draggable-container.is-minimized {
    padding-bottom: 10px;
}

.draggable-container.is-minimized .output-levels,
.draggable-container.is-minimized .tap-output {
    display: none;
}

.draggable-container img {
    margin-top: 8px;
}

.draggable-container .output-levels,
.draggable-container .tap-output {
    display: inline-block;
    vertical-align: top;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.draggable-container .tap-output {
    margin-left: 10px;
    background-color: rgba(72, 148, 231, 0.1);
}

.draggable-container .output-levels {
    margin-left: 10px;
    background-color: rgba(96, 128, 175, 0.08);
}

.dropdown-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 8px;
}

.make-dropdown,
.model-dropdown {
    display: block;
    width: 132px;
    padding: 4px 6px;
    margin: 3px 0;
    border: 1px solid rgba(78, 105, 142, 0.2);
    border-radius: 8px;
    background-color: rgba(252, 254, 255, 0.85);
    color: var(--title);
    font-size: 10px;
    cursor: pointer;
    box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.06);
}

.make-dropdown:hover,
.model-dropdown:hover {
    border-color: #007bff;
}

.make-dropdown:focus,
.model-dropdown:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.16);
}

.cable-container {
    padding: 10px;
    border: 1px solid rgba(72, 93, 121, 0.18);
    border-radius: 15px;
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: var(--panel-shadow-soft);
    color: #333;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    font-size: 12px;
    margin: 5px;
    cursor: move;
}

/* Slightly tighten the layout again when the screen width shrinks. */
@media (max-width: 1200px) {
    .device_selection {
        width: 150px;
    }

    #canvas {
        left: 40px;
    }
}
