/**
 * Gaash Storage Price List
 *
 * Direction agnostic: the block gets dir="rtl" / dir="ltr" from the renderer and all
 * horizontal rules below use logical properties, so Hebrew and English share one file.
 */

.gaash-pricelist {
    --gaash-pricelist-blue: #1f6fb5;
    --gaash-pricelist-border: #767676;
    --gaash-pricelist-note-bg: #eef3f8;
    --gaash-pricelist-stripe: #f7f9fb;

    color: #222;
    font-size: 15px;
    line-height: 1.5;
    /* Themes commonly hard code text-align: left, which is wrong in the Hebrew page. */
    text-align: start;
}

.gaash-pricelist * {
    box-sizing: border-box;
}

/* Two classes, to outweigh theme rules such as `.fl-page h2 { text-align: left }`. */
.gaash-pricelist .gaash-pricelist__title {
    margin: 0 0 0.9em;
    font-size: 1.5em;
    line-height: 1.2;
    text-align: start;
}

.gaash-pricelist__admin-notice {
    margin: 0 0 1.25em;
    padding: 8px 12px;
    border-inline-start: 4px solid #e0a800;
    background: #fff8e5;
    font-size: 0.9em;
}

.gaash-pricelist__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    grid-template-rows: auto auto;
    column-gap: 24px;
    /*
     * 0, because a grid row gap would also land between a bracket's heading and its own
     * table. The space between brackets comes from the table's bottom margin instead,
     * which works whether they sit side by side or stack.
     */
    row-gap: 0;
    align-items: start;
}

/*
 * One bracket = a heading plus a table, and it spans both rows of the grid above through
 * subgrid. So every heading on a row is as tall as the tallest one there and the tables
 * start on the same line, however many lines each sentence happens to wrap to.
 */
.gaash-pricelist__grid > .gaash-pricelist__bracket {
    display: grid;
    grid-row: span 2;
    grid-template-rows: subgrid;
    align-self: stretch;
    min-width: 0;
}

.gaash-pricelist__grid > .gaash-pricelist__bracket > .gaash-pricelist__table {
    align-self: start;
    margin-bottom: 24px;
}

/* Without subgrid: no row alignment, but keep the headings a uniform two lines tall. */
@supports not (grid-template-rows: subgrid) {
    .gaash-pricelist__grid .gaash-pricelist__bracket-title {
        min-height: 3.85em;
    }
}

/* The grid's last tables already carry a 24px bottom margin. */
.gaash-pricelist__bracket--flat {
    margin-top: 0;
}

.gaash-pricelist__table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    table-layout: fixed;
    background: #fff;
}

.gaash-pricelist__table th,
.gaash-pricelist__table td {
    padding: 8px 10px;
    border: 1px solid var(--gaash-pricelist-border);
    text-align: start;
    vertical-align: middle;
    font-size: 0.95em;
}

.gaash-pricelist__columns th {
    border-color: var(--gaash-pricelist-blue) !important;
    background: var(--gaash-pricelist-blue);
    color: #fff;
    font-weight: 700;
}

/* Two classes, so theme rules for h3 inside content do not reach it. */
.gaash-pricelist .gaash-pricelist__bracket-title {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid var(--gaash-pricelist-blue);
    border-bottom: 0;
    background: var(--gaash-pricelist-blue);
    color: #fff;
    font-size: 0.95em;
    font-weight: 700;
    line-height: 1.35;
    text-align: start;
}

.gaash-pricelist__col-rate {
    width: 34%;
}

.gaash-pricelist__table tbody th {
    font-weight: 400;
}

.gaash-pricelist__table tbody tr:nth-of-type(even):not(.gaash-pricelist__row--note) th,
.gaash-pricelist__table tbody tr:nth-of-type(even):not(.gaash-pricelist__row--note) td {
    background: var(--gaash-pricelist-stripe);
}

.gaash-pricelist__row--note td {
    background: var(--gaash-pricelist-note-bg);
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1.4;
}

.gaash-pricelist__amount {
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

.gaash-pricelist__actions {
    margin: 1.5em 0 0;
}

.gaash-pricelist__print {
    padding: 8px 18px;
    border: 1px solid var(--gaash-pricelist-blue);
    border-radius: 4px;
    background: transparent;
    color: var(--gaash-pricelist-blue);
    font: inherit;
    font-size: 0.95em;
    cursor: pointer;
}

.gaash-pricelist__print:hover,
.gaash-pricelist__print:focus {
    background: var(--gaash-pricelist-blue);
    color: #fff;
}

.gaash-pricelist--error {
    padding: 12px 16px;
    border-inline-start: 4px solid #c0392b;
    background: #fdecea;
}

/* Printed output, kept close to the published PDF: landscape, two tables side by side. */
@media print {
    #wpadminbar,
    .fl-page-header,
    .fl-page-header-fixed,
    .fl-page-nav-wrap,
    .fl-page-footer,
    .fl-page-footer-widgets,
    .fl-page-bar,
    .site-header,
    .site-footer,
    .ast-above-header,
    .ast-below-header,
    nav,
    aside,
    .gaash-pricelist__actions,
    .gaash-pricelist__admin-notice {
        display: none !important;
    }

    @page {
        size: landscape;
        margin: 10mm;
    }

    body {
        background: #fff !important;
    }

    .gaash-pricelist {
        font-size: 11px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .gaash-pricelist__grid {
        grid-template-columns: 1fr 1fr;
        column-gap: 10px;
        /* Not `gap`: a row gap would separate each heading from its own table. */
        row-gap: 0;
    }

    .gaash-pricelist__bracket {
        break-inside: avoid;
    }

    .gaash-pricelist__grid > .gaash-pricelist__bracket > .gaash-pricelist__table {
        margin-bottom: 10px;
    }

    .gaash-pricelist .gaash-pricelist__bracket-title,
    .gaash-pricelist__table th,
    .gaash-pricelist__table td {
        padding: 4px 6px;
    }
}
