/*
 * qwx components for the Webhooks page (qwx-components.js): the page's frame and parent tabs, cards,
 * grid cards (QWW's ag-grid look, on a plain table), the search filters, forms in a card, and the
 * modal frame. The names, slots and markup are QWW's (QuoteWerksWeb.Web/app/components/qwx/qwx.css
 * and qwx-modal.js, 2026-11-17), so a screen reads the same in both apps; the values are kept in step
 * by hand. The tokens are qwx-theme.css's (html.qwx). Light mode only.
 */

/* Slot elements (<qw-grid-footer> etc.) are only markers: their children join the row or column they
   sit in, so the slot's flex layout (gaps, a qwx-grow spacer) applies to them directly. */
qw-panel-actions,
qw-panel-footer,
qw-grid-toolbar,
qw-grid-footer,
qw-modal-footer-left,
qw-modal-footer-right {
    display: contents;
}

html.qwx .qwx-grow {
    flex: 1;
    min-width: 0;
}

/* ===================================================================== the page */

/* The page is the window's height: the tabs across the top, the chosen view filling the rest. Opened
   in QWW (Setup > Webhooks) the window is QWW's frame, under its "Setup > Webhooks" header. */
html.qwx,
html.qwx body {
    height: 100%;
}

html.qwx .qwx-app {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

html.qwx .qwx-area {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 14px 16px 16px;
}

/* a view (Webhooks, Logs, Documentation) and its controller's element fill the area */
html.qwx .qwx-view,
html.qwx .qwx-view > [ng-controller] {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

/* ===================================================================== parent tabs */

/* QWW's top tier of tabs (.qwx-parent-tabs): the house dark-grey strip, grey labels, the chosen one
   white with a caret the page's colour pointing into its page. Opened on its own, the strip also
   carries the QuoteWerks logo at the left and the sign-in menu at the right. */
html.qwx .qwx-parent-tabs {
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    background-color: #333;
}

html.qwx .qwx-parent-tabs-list {
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
}

html.qwx .qwx-parent-tabs-list > li > a {
    position: relative;             /* the caret */
    display: flex;
    align-items: center;
    padding: 15px 22px;             /* 50px tall with the 20px line, as in QWW */
    line-height: 20px;
    border-right: 1px solid #4a4a4a;
    color: #c1c1c1;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
}

html.qwx .qwx-parent-tabs-list > li > a:hover,
html.qwx .qwx-parent-tabs-list > li > a:focus {
    background-color: rgba(255, 255, 255, .05);
    color: #fff;
    outline: none;
}

html.qwx .qwx-parent-tabs-list > li.active > a {
    background: none;
    color: #fff;
    font-weight: 600;
}

html.qwx .qwx-parent-tabs-list > li.active > a::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 9px solid var(--qwx-bg);
}

html.qwx .qwx-parent-tabs-list > li > a > i {
    margin-right: 7px;
}

/* the logo, when the page is opened on its own */
html.qwx .qwx-app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 0 18px;
    border-right: 1px solid #4a4a4a;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

html.qwx .qwx-app-logo:hover {
    color: #fff;
}

html.qwx .qwx-app-logo > img {
    position: relative;
    top: -1px;
    height: 20px;
}

/* the sign-in menu (oidc-user-popover), when the page is opened on its own */
html.qwx .qwx-app-user {
    display: flex;
    align-items: center;
    padding: 0 14px;
    color: #c1c1c1;
    font-size: 15px;
}

html.qwx .qwx-app-user .oidc-user-popover-container > div:first-child:hover {
    color: #fff;
}

html.qwx .qwx-app-user .card {
    color: var(--qwx-text);
    font-size: 12px;
    border: 1px solid var(--qwx-line);
    border-radius: var(--qwx-radius);
}

/* ===================================================================== cards (qw-panel, qw-grid-panel) */

qw-panel,
qw-grid-panel {
    display: block;
    flex: 0 0 auto;
    min-width: 0;
}

/* "fill" (and every grid card): the card takes the remaining height of a flex column */
qw-panel.qwx-fill,
qw-grid-panel.qwx-fill {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

html.qwx .qwx-panel {
    margin: 0;
    background-color: var(--qwx-card);
    border: 1px solid var(--qwx-line);
    border-radius: var(--qwx-radius);
    box-shadow: var(--qwx-shadow);
}

html.qwx .qwx-fill > .qwx-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

html.qwx .qwx-panel-heading {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--qwx-line);
    border-radius: var(--qwx-radius) var(--qwx-radius) 0 0;
}

html.qwx .qwx-panel-icon {
    color: #2879c6;
    font-size: 15px;
}

html.qwx .qwx-panel-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--qwx-ink);
}

html.qwx .qwx-panel-subtitle {
    margin-top: 1px;
    font-size: 12px;
    color: var(--qwx-muted);
}

html.qwx .qwx-panel-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

html.qwx .qwx-panel-body {
    padding: 12px 14px;
    font-size: 12px;
}

/* a card whose body is a list edge to edge: <qw-panel class="qwx-flush-panel"> */
qw-panel.qwx-flush-panel > .qwx-panel > .qwx-panel-body {
    padding: 0;
}

html.qwx .qwx-panel-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 14px;
    background-color: #fafbfd;
    border-top: 1px solid var(--qwx-line);
    border-radius: 0 0 var(--qwx-radius) var(--qwx-radius);
    color: var(--qwx-muted);
    font-size: 12px;
}

/* ---- the grid card */

html.qwx .qwx-grid-toolbar {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-bottom: 1px solid var(--qwx-line);
}

/* A toolbar's row: the buttons, then a qwx-grow, then the list's filters at the right. */
html.qwx .qwx-toolbar-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
    min-height: 30px;
}

html.qwx .qwx-grid-body {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 160px;
}

html.qwx .qwx-grid-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 36px;
    padding: 0 13px;
    border-top: 1px solid var(--qwx-line);
    border-radius: 0 0 var(--qwx-radius) var(--qwx-radius);
    color: #63778d;
    font-size: 12px;
}

/* An empty grid's message, over the grid below its header row; clicks pass through.
   Rule: say where the rows come from. */
html.qwx .qwx-grid-empty {
    position: absolute;
    inset: 32px 0 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: var(--qwx-muted);
    font-size: 13px;
    text-align: center;
    pointer-events: none;
}

html.qwx .qwx-grid-empty > i {
    font-size: 28px;
    color: #c3d0de;
}

/* ===================================================================== the grid look on a table */

/* QWW's qwx grid: a pale blue-grey header with clear column dividers, 30px rows with soft lines, the
   hover blue. The header stays put while the rows scroll in the card. */
html.qwx .qwx-table-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

html.qwx .qwx-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
    color: var(--qwx-text);
}

html.qwx .qwx-table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 1;
    height: 32px;
    padding: 0 12px;
    background-color: #f0f5fa;
    border-bottom: 1px solid #d4dfec;
    border-right: 1px solid var(--qwx-grid-divider);
    color: #354d66;
    font-size: 11px;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}

html.qwx .qwx-table > thead > tr > th:last-child {
    border-right: 0;
}

html.qwx .qwx-table > tbody > tr > td {
    height: 30px;
    padding: 3px 12px;
    border-bottom: 1px solid var(--qwx-line-soft);
    vertical-align: middle;
    white-space: nowrap;
}

/* The column that gives way (the URL): it takes the width the others leave, and its text ends in an
   ellipsis rather than widening the table. */
html.qwx .qwx-table .qwx-col-grow {
    width: 40%;
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* a cell with no value reads "N/A", muted -- never blank, which reads as missing data */
html.qwx .qwx-na {
    color: #9aa7b8;
}

html.qwx .qwx-table > tbody > tr:hover > td {
    background-color: #f2f8ff;
}

/* the columns that hold a switch or buttons are only as wide as those */
html.qwx .qwx-table .qwx-col-fit {
    width: 1%;
    max-width: none;
    overflow: visible;
}

html.qwx .qwx-table .qwx-col-fit .btn + .btn {
    margin-left: 4px;
}

/* a long value (a URL) ends in an ellipsis; the whole value is its tooltip */
html.qwx .qwx-table .qwx-cell-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* a switched-off webhook's row is dimmed, except its switch and buttons */
html.qwx .qwx-table > tbody > tr.qwx-row-off > td:not(.qwx-col-fit) {
    color: #9aa7b8;
}

/* a table in a card with rows that wrap (the delivery attempts' errors) */
html.qwx .qwx-table.qwx-table-wrap > tbody > tr > td {
    max-width: none;
    white-space: normal;
    vertical-align: top;
    padding-top: 7px;
    padding-bottom: 7px;
}

/* ---- a delivery's status: a small pill in its colour */
html.qwx .qwx-status {
    display: inline-block;
    padding: 0 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    background-color: #eef2f7;
    color: #4b5d73;
}

html.qwx .qwx-status-ok { background-color: #e3f4e8; color: #1d7a36; }
html.qwx .qwx-status-failed { background-color: #fbe9e7; color: #b42323; }
html.qwx .qwx-status-pending { background-color: #fdf3dc; color: #8a5d00; }

/* ===================================================================== filters in a grid's toolbar */

/* The list's search fields at the toolbar's right, each a caption beside its field. While any is
   filled the funnel is the kit's blue (the old box's red border). */
html.qwx .qwx-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

html.qwx .qwx-filters-icon {
    color: #a9b7c7;
    font-size: 13px;
}

html.qwx .qwx-filters-on .qwx-filters-icon {
    color: var(--qwx-blue);
}

html.qwx .qwx-filter {
    display: flex;
    align-items: center;
    gap: 6px;
}

html.qwx .qwx-filter > .form-control {
    width: 170px;
}

html.qwx .qwx-filter > .form-select {
    width: 120px;
}

/* ===================================================================== forms in a card */

/* A form's rows: the caption in a column of its own, the field beside it. A wide field spans both
   columns with .qwx-field-wide. */
html.qwx .qwx-field-grid {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: center;
    gap: 10px 18px;
}

html.qwx .qwx-field-grid > label {
    line-height: 18px;
}

/* a caption beside a field that is taller than one line sits at the field's top */
html.qwx .qwx-field-grid > label.qwx-label-top {
    align-self: start;
    padding-top: 5px;
}

html.qwx .qwx-field-grid > .qwx-field-wide {
    grid-column: 1 / -1;
}

/* a read-only value beside its caption */
html.qwx .qwx-field-value {
    color: var(--qwx-ink);
    font-size: 12px;
    overflow-wrap: anywhere;
}

/* things stacked in one field's place: a macro search, the field, a hint */
html.qwx .qwx-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

/* a field and what goes with it on one line */
html.qwx .qwx-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

html.qwx .qwx-inline > .form-control,
html.qwx .qwx-inline > .form-select {
    flex: 1 1 auto;
    min-width: 0;
}

html.qwx .qwx-inline > .qwx-auto {
    flex: 0 0 auto;
    width: auto;
}

/* the edit form's request headers: name, value, remove */
html.qwx .qwx-header-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 30px;
    gap: 6px;
    align-items: center;
}

html.qwx .qwx-header-row .btn.qwx-tool {
    width: 30px;
    height: var(--qwx-field-h);
}

/* A card's body editor (CodeMirror, style.css) under its caption row */
html.qwx .qwx-editor-caption {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===================================================================== the modal */

/* The page's dialogs show and hide with ng-show (app.js keeps its CodeMirror editors in them), so the
   overlay is the page's own: the dark wash, and the window centred in it, never taller than the
   window. The window holds qw-modal-frame, QWW's qwx modal frame. */
html.qwx .qwx-overlay {
    position: fixed;
    inset: 0;
    z-index: 200000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background-color: rgba(15, 30, 55, .45);
}

/* a question asked over another dialog (unsaved changes, sent) */
html.qwx .qwx-overlay.qwx-overlay-top {
    z-index: 200001;
}

html.qwx .qwx-modal-window {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 900px;
    max-height: 100%;
    border-radius: 10px;
    box-shadow: 0 18px 50px rgba(15, 30, 55, .35);
    animation: qwx-modal-in 160ms ease-out;
}

html.qwx .qwx-modal-window.qwx-modal-md { max-width: 800px; }
html.qwx .qwx-modal-window.qwx-modal-sm { max-width: 520px; }

@keyframes qwx-modal-in {
    from { transform: translateY(6px) scale(.995); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}

qw-modal-frame {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

html.qwx .qwx-modal-frame {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

html.qwx .qwx-modal-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px 12px 20px;
    background-color: #1d3150;
    color: #fff;
    border-radius: 10px 10px 0 0;
}

/* The bottom corners belong to whichever part is last: the footer, or the body without one. */
html.qwx .qwx-modal-frame > :last-child {
    border-radius: 0 0 10px 10px;
}

html.qwx .qwx-modal-icon {
    font-size: 20px;
    color: #8fc0f5;
}

html.qwx .qwx-modal-titles {
    min-width: 0;
}

html.qwx .qwx-modal-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
}

html.qwx .qwx-modal-subtitle {
    margin-top: 2px;
    overflow: hidden;
    color: #b8c8dc;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html.qwx .qwx-modal-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #d6e2f0;
    font-size: 16px;
}

html.qwx .qwx-modal-close:hover,
html.qwx .qwx-modal-close:focus {
    background-color: rgba(255, 255, 255, .12);
    color: #fff;
    outline: none;
}

/* The body: its cards in a column on the page colour, scrolling under the header. */
html.qwx .qwx-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 18px;
    overflow-y: auto;
    background-color: var(--qwx-bg);
}

html.qwx .qwx-modal-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background-color: #fff;
    border-top: 1px solid var(--qwx-line);
}

html.qwx .qwx-modal-footer-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Every footer button one size: the modal's 32px, at least 80px wide. */
html.qwx .qwx-modal-footer .btn {
    height: 32px;
    min-width: 80px;
    padding: 6px 14px;
}

/* ---- a message or a question (sent, delete, unsaved changes): its icon beside the text */
html.qwx .qwx-message {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 4px 2px;
    color: var(--qwx-text);
    font-size: 13px;
    line-height: 1.5;
}

html.qwx .qwx-message > i {
    font-size: 26px;
    color: #2879c6;
}

html.qwx .qwx-message > i.qwx-message-ok { color: #1d7a36; }
html.qwx .qwx-message > i.qwx-message-warn { color: #c08a18; }
html.qwx .qwx-message > i.qwx-message-danger { color: #b42323; }

html.qwx .qwx-message p {
    margin: 0;
}

/* ===================================================================== the documentation view */

/* The documentation page draws its own cards on the page colour, so its frame takes the whole area,
   edge to edge under the tabs. */
html.qwx .qwx-view.qwx-view-docs {
    margin: -14px -16px -16px;
}

html.qwx .qwx-docs-frame {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    border: 0;
    background-color: var(--qwx-bg);
}
