/*
 * eu-cbam-checker.css - styles for eu-cbam-checker.php only.
 *
 * Look: a compact "tool" interface (tight spacing, small clear labels, bold result headline).
 * Colours: the site palette from style.css and design-system.css (--blue, --yellow, --grey, --light, --text, --white)
 * plus two very light tints (blue and yellow) for information and warning bands.
 * Flat colours, Arial, no gradients, no animations - same feel as the rest of the site.
 *
 * v37 (chat 12g): the two boxes are Cards (white, 3px yellow top line, 24px padding), inputs 46px high with a
 * 1px #767676 border, labels 1rem bold, help text 14px #595959, info band = Info box.
 *
 * Layout: two columns (inputs left, assessment right). Below 800px they stack.
 * Everything has min-width: 0 so nothing forces a sideways scroll, down to 320px wide.
 *
 * Contents: setup / breadcrumb and title / two columns / form fields / code search /
 *           tick boxes and radios / buttons / assessment panel / key-value tables /
 *           question that needs attention / bottom band and notes / small screens
 */

.cbc {
    /* Deeper shades of the EC blue (#4073AF), same hue, more saturation and contrast */
    --cbc-blue-rich: #255D9D;       /* icons, accents, links: 6.6:1 on white */
    --cbc-blue-deep: #1D497C;       /* deep emphasis */
    --cbc-blue-dark: #1D497C;     /* deep emphasis (was the button hover) */
    --cbc-blue-tint: #E8EEF6;      /* very light EC blue (form panels) */
    --cbc-blue-tint-strong: #E8EEF6; /* light EC blue band behind neutral results */
    --cbc-amber: #C29500;          /* deep amber edge for the warning band (yellow family) */
    --cbc-yellow-tint: #FFF6C2;    /* very light EC yellow (warning band) */
    --cbc-muted: #595959;          /* secondary text */
    --cbc-line: #767676;           /* form borders (v37: 1px #767676, strong enough to see) */
    --cbc-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 6l5 5 5-5' fill='none' stroke='%23262626' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --cbc-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='8.5' cy='8.5' r='5.5' fill='none' stroke='%23262626' stroke-width='1.8'/%3E%3Cpath d='M12.7 12.7 17 17' stroke='%23262626' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}

.cbc [hidden] {
    display: none !important;
}

.cbc * {
    min-width: 0;
}

/* ---------- Breadcrumb and title ---------- */

.cbc-crumbs {
    margin: 0 0 8px 0;
    font-size: 0.875rem;
    color: var(--cbc-muted);
}

.cbc-crumbs li[aria-current] {
    font-weight: bold;
}

.cbc-crumbs ol {
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    list-style: none;
}

.cbc-crumbs li {
    margin: 0;
}

.cbc-crumbs li + li::before {
    content: "/";
    margin: 0 8px;
}

.cbc-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 6px 24px;
    margin-bottom: 16px;
}

.cbc-sub {
    margin: 0;
    color: var(--cbc-muted);
    font-size: 1.05rem;
    line-height: 1.4;
}

.cbc-tag {
    margin: 0;
    color: var(--cbc-muted);
    font-size: 0.9rem;
}

.cbc-tag-top {
    text-align: right;
}

.cbc-tag-top span {
    display: block;
}

.cbc-tag-top span:first-child {
    font-weight: bold;
    color: var(--cbc-muted);
}

.cbc-tag-top {
    font-size: 0.875rem;
}

.cbc-tag-version {
    font-size: 0.875rem;
    color: var(--cbc-muted);
}

/* Loading message: visible while loading or if it fails; read aloud (not shown) once loaded. */
.cbc-load {
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    color: var(--cbc-muted);
}

.cbc-load-done {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.cbc-banner {
    padding: 10px 14px;
    border-left: 6px solid var(--yellow);
    background: var(--cbc-yellow-tint);
    color: var(--text);
}

.cbc-banner-error {
    border-left-color: var(--text);
}

/* ---------- Two columns ---------- */

.cbc-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
    gap: 20px;
    align-items: stretch;
}

/* Card: white, 1px grey border, 3px yellow top line, 24px padding (v37; was grey with a plain border) */
.cbc-card {
    background: var(--white);
    border: 1px solid var(--grey);
    border-top: 3px solid var(--yellow);
    padding: 24px;
}

.cbc-card h2 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    font-weight: bold;
    line-height: 1.35;
    color: var(--blue);
}

.cbc-card h2:focus {
    outline: none;
}

.cbc-card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 4px 16px;
    flex-wrap: wrap;
}

.cbc-card-head .cbc-tag {
    font-size: 0.85rem;
}

/* ---------- Form fields ---------- */

.cbc-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 12px;
}

.cbc-field {
    margin-bottom: 12px;
}

.cbc-field > label,
.cbc-fieldset legend {
    display: block;
    margin-bottom: 4px;
    font-size: 1rem;
    font-weight: bold;
    line-height: 1.3;
}

.cbc input[type="text"],
.cbc select {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 46px;
    padding: 6px 12px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1rem;
    color: var(--text);
    background-color: var(--white);
    border: 1px solid var(--cbc-line);
    border-radius: 0;
}

/* Drop-down arrow drawn by the page, so every browser looks the same */
.cbc select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 34px;
    background-image: var(--cbc-chevron);
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px 14px;
    text-overflow: ellipsis;
}

.cbc input[type="text"]::placeholder {
    color: var(--cbc-muted);
    opacity: 1;
}

.cbc input[type="text"]:focus,
.cbc select:focus {
    outline: 3px solid var(--yellow);
    outline-offset: 0;
    box-shadow: 0 0 0 5px var(--text);
    border-color: var(--text);
}

.cbc input:disabled,
.cbc select:disabled {
    background-color: #EBEBEB;
    cursor: not-allowed;
}

.cbc-help {
    margin: 4px 0 0 0;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--cbc-muted);
}

.cbc-after-btn {
    margin-top: 8px;
}

/* Visually hidden text for screen readers */
.cbc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Code search box and list ---------- */

.cbc-combo {
    position: relative;
}

/* Magnifying glass inside the search box (on the right) */
.cbc #cbc-code {
    padding-right: 40px;
    background-image: var(--cbc-search);
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px 18px;
}

.cbc-list {
    position: absolute;
    z-index: 20;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    max-height: 320px;
    overflow-y: auto;
    background: var(--white);
    border: 1px solid var(--text);
    border-top: 0;
}

.cbc-list li {
    margin: 0;
}

.cbc-option {
    display: block;
    padding: 8px 12px;
    border-bottom: 1px solid var(--grey);
    cursor: pointer;
    line-height: 1.35;
}

.cbc-option:hover,
.cbc-option[aria-selected="true"] {
    background: var(--cbc-blue-tint);
}

.cbc-option[aria-selected="true"] {
    outline: 2px solid var(--blue);
    outline-offset: -2px;
}

.cbc-option-label,
.cbc-option-parents {
    display: block;
    overflow-wrap: anywhere;
}

.cbc-option-label {
    font-size: 0.95rem;
}

.cbc-option-parents {
    margin-top: 2px;
    font-size: 0.78rem;
    color: var(--cbc-muted);
}

.cbc-list-empty {
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--cbc-muted);
}

/* Selected code panel */
.cbc-selected {
    margin: 0 0 12px 0;
    padding: 8px 12px;
    background: var(--cbc-blue-tint);
    border: 1px solid #CFCFCF;
    border-left: 4px solid var(--cbc-blue-rich);
}

.cbc-selected p {
    margin: 0;
    overflow-wrap: anywhere;
}

.cbc-selected-kicker {
    font-size: 0.75rem;
    color: var(--cbc-muted);
}

.cbc-selected-code {
    font-weight: bold;
}

.cbc-selected-label {
    font-size: 0.9rem;
}

.cbc-selected-parents {
    margin-top: 2px !important;
    font-size: 0.78rem;
    color: var(--cbc-muted);
}

/* ---------- Tick boxes and radio buttons ---------- */

.cbc-fieldset {
    margin: 0 0 12px 0;
    padding: 0;
    border: 0;
}

.cbc-fieldset legend {
    padding: 0;
}

.cbc-check,
.cbc-radio {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 0 6px 0;
}

.cbc-check input,
.cbc-radio input {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 1px 0 0 0;
    accent-color: var(--cbc-blue-rich);
}

.cbc-check input:focus-visible,
.cbc-radio input:focus-visible {
    outline: 3px solid var(--yellow);
    outline-offset: 2px;
}

.cbc-check label,
.cbc-radio label {
    font-size: 1rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.cbc-radio input:disabled + label {
    color: var(--cbc-muted);
    cursor: not-allowed;
}

.cbc-radios {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 20px;
}

.cbc-radios .cbc-radio {
    margin-bottom: 4px;
}

/* Special customs circumstances: a ruled section like the design (always open, never skipped) */
#cbc-special {
    margin: 4px 0 12px 0;
    padding: 10px 0 6px 0;
    border-top: 1px solid var(--grey);
    border-bottom: 1px solid var(--grey);
}

#cbc-special .cbc-help {
    margin: 0 0 8px 0;
}

.cbc-check-none {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--grey);
}

.cbc-check-none label {
    font-weight: bold;
}

/* Quantity box with the unit attached on the right, like the design */
.cbc-qty-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 104px;
    gap: 0;
}

.cbc-qty-input input[type="text"] {
    border-right: 0;
}

.cbc-qty-input select {
    background-color: #EBEBEB;
}

/* ---------- Buttons ---------- */

.cbc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 24px;
    min-height: 46px;
    border: 2px solid var(--blue);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1rem;
    font-weight: bold;
    line-height: 1.3;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cbc-btn-primary {
    background: var(--blue);
    color: var(--white);
}

.cbc-btn-primary:hover,
.cbc-btn-primary:focus {
    background: var(--cbc-blue-rich);
    border-color: var(--cbc-blue-rich);
    color: var(--white);
    text-decoration: none;
}

.cbc-btn:focus-visible,
.cbc-linkbtn:focus-visible,
.cbc-why summary:focus-visible,
.cbc-sources summary:focus-visible {
    outline: 3px solid var(--yellow);
    outline-offset: 0;
    box-shadow: 0 0 0 5px var(--text);
}

.cbc-btn:disabled {
    background: #EBEBEB;
    border-color: #CFCFCF;
    color: #595959;
    cursor: not-allowed;
}

.cbc-btn-block {
    width: 100%;
}

.cbc-linkbtn {
    padding: 8px 4px;
    background: none;
    border: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 1rem;
    color: var(--cbc-blue-rich);
    text-decoration: underline;
    cursor: pointer;
}

/* ---------- Assessment panel ---------- */

.cbc-placeholder {
    margin: 0;
    padding: 20px 16px;
    border: 1px dashed var(--grey);
    background: var(--white);
    color: var(--cbc-muted);
    font-size: 0.95rem;
}

.cbc-kicker {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.3;
    color: var(--cbc-muted);
}

.cbc-sub-line {
    margin: 2px 0 0 0;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--cbc-muted);
}

/* Product scope: icon + bold headline */
.cbc-headline {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 0 16px 12px;
    border-left: 4px solid var(--cbc-blue-rich);
    margin-bottom: 14px;
    border-bottom: 1px solid var(--grey);
}

.cbc-headline > div {
    flex: 1 1 auto;
}

.cbc-headline-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: bold;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.cbc-status-icon {
    flex: 0 0 auto;
    line-height: 0;
}

/* Section headings inside the panel */
.cbc-block {
    margin: 0 0 14px 0;
    padding-left: 12px;
    border-left: 4px solid var(--cbc-blue-rich);
}

.cbc-block h3 {
    margin: 0 0 6px 0;
    font-size: 1.1rem;
    font-weight: bold;
    line-height: 1.25;
}

.cbc-block-note {
    margin-top: 6px;
}

/* Overall outcome band (also used for the "please answer" message) */
.cbc-status {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 12px 0;
    padding: 10px 12px;
    background: var(--cbc-blue-tint-strong);
    border-left: 6px solid var(--cbc-blue-rich);
}

/* Warning band: full EC yellow with a deep amber edge and dark text */
.cbc-tone-alert {
    background: var(--yellow);
    border-left-color: var(--cbc-amber);
}

/* Review / incomplete: EC grey */
.cbc-tone-review {
    background: var(--grey);
    border-left-color: var(--cbc-muted);
}

.cbc-status .cbc-kicker {
    color: var(--text);
}

.cbc-status-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: bold;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.cbc-explain {
    margin: 0 0 14px 0;
}

.cbc-explain p {
    margin: 0 0 6px 0;
    overflow-wrap: anywhere;
}

.cbc-explain .cbc-kicker {
    margin-bottom: 2px;
}

/* ---------- Key-value tables ---------- */

.cbc-kv {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
}

.cbc-kv th,
.cbc-kv td {
    padding: 8px 4px;
    border-top: 1px solid var(--grey);
    text-align: left;
    vertical-align: top;
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

.cbc-kv tr:last-child th,
.cbc-kv tr:last-child td {
    border-bottom: 1px solid var(--grey);
}

.cbc-kv th {
    width: 52%;
    font-weight: normal;
}

.cbc-kv-muted {
    margin-bottom: 14px;
}

.cbc-kv-muted th,
.cbc-kv-muted td {
    font-size: 0.85rem;
    color: var(--cbc-muted);
}

/* ---------- Why this result? ---------- */

.cbc-why {
    margin: 0 0 16px 0;
    border: 1px solid var(--grey);
    background: var(--white);
}

.cbc-why summary,
.cbc-sources summary {
    cursor: pointer;
    font-weight: bold;
}

.cbc-why summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    list-style: none;
}

.cbc-why summary::-webkit-details-marker,
.cbc-sources summary::-webkit-details-marker {
    display: none;
}

.cbc-why summary::after,
.cbc-sources summary::after {
    content: "";
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    background: var(--cbc-chevron) no-repeat center / 14px 14px;
}

.cbc-why[open] summary::after,
.cbc-sources[open] summary::after {
    transform: rotate(180deg);
}

.cbc-why-list {
    margin: 0;
    padding: 0 14px 8px 14px;
}

.cbc-why-list div {
    padding: 7px 0;
    border-top: 1px solid var(--grey);
}

.cbc-why-list dt {
    font-size: 0.78rem;
    font-weight: bold;
    color: var(--cbc-muted);
}

.cbc-why-list dd {
    margin: 2px 0 0 0;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

/* Main button and a plain link, side by side */
.cbc-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 22px;
}

.cbc-actions .cbc-btn {
    min-width: 260px;
}

/* ---------- A question that needs attention ---------- */

/* Dark bar + light yellow background + bold text: it does not rely on colour alone. */
.cbc .cbc-invalid {
    margin-left: -12px;
    margin-right: -12px;
    padding: 8px 12px;
    background: var(--cbc-yellow-tint);
    border-left: 6px solid var(--text);
}

.cbc .cbc-invalid input[type="text"],
.cbc .cbc-invalid select {
    border: 2px solid var(--text);
}

/* Browsers draw a fieldset title half outside its box; this keeps the title inside the highlight. */
.cbc fieldset.cbc-invalid legend {
    float: left;
    width: 100%;
}

.cbc fieldset.cbc-invalid legend + * {
    clear: both;
}

.cbc .cbc-check.cbc-invalid {
    flex-wrap: wrap;
}

.cbc-error {
    margin: 0 0 6px 0;
    font-size: 0.9rem;
    font-weight: bold;
    line-height: 1.35;
    color: var(--text);
}

.cbc-check .cbc-error {
    flex: 0 0 100%;
}

/* Note above the result when one confirmation or figure is still missing */
.cbc-todo {
    margin: 0 0 14px 0;
    padding: 8px 12px;
    background: var(--cbc-yellow-tint);
    border-left: 6px solid var(--text);
}

.cbc-todo p {
    margin: 0 0 2px 0;
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

.cbc-todo .cbc-linkbtn {
    padding-left: 0;
    font-size: 0.95rem;
}

/* ---------- Bottom band and notes ---------- */

.cbc-info {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin: 20px 0 10px 0;
    padding: 16px 20px;
    background: var(--cbc-blue-tint-strong);
    border-left: 4px solid var(--cbc-blue-rich);
    color: var(--text);
}

.cbc-info-icon {
    flex: 0 0 auto;
    margin-top: 1px;
}

.cbc-info p {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.4;
}

.cbc-info .cbc-info-title {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--cbc-blue-deep);
}

.cbc-foot-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 6px 24px;
}

.cbc-foot {
    margin: 0;
    padding-top: 2px;
    font-size: 0.875rem;
    color: var(--cbc-muted);
}

/* Closed: a link row (14px, dark blue, underlined) on the right. Open: a full-width box underneath. */
.cbc-sources summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 2px 0;
    list-style: none;
    font-size: 0.875rem;
    font-weight: normal;
    color: var(--cbc-blue-rich);
    text-decoration: underline;
}

.cbc-sources summary:hover {
    color: var(--cbc-blue-deep);
}

.cbc-sources[open] {
    flex: 0 0 100%;
    border: 1px solid var(--grey);
    background: var(--white);
}

.cbc-sources[open] summary {
    padding: 10px 14px;
}

#cbc-sources-body {
    padding: 0 14px 4px 14px;
    font-size: 0.88rem;
}

.cbc-sources-list {
    padding-left: 20px;
}

.cbc-sources-list li {
    overflow-wrap: anywhere;
}

/* ---------- Tablet: keep two columns, but year and sector stack when tight ---------- */

@media (min-width: 801px) and (max-width: 1000px) {
    .cbc-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .cbc-actions .cbc-btn {
        min-width: 0;
    }
}

/* ---------- Phones and small tablets: one column ---------- */

@media (max-width: 800px) {
    .cbc-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .cbc-tag-top {
        text-align: left;
    }

}

@media (max-width: 560px) {
    .cbc-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .cbc-sub {
        font-size: 1rem;
    }

    .cbc-headline-title {
        font-size: 1.5rem;
    }

    .cbc-actions .cbc-btn {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 400px) {
    .cbc-card {
        padding: 16px 14px 18px 14px;
    }

    .cbc-qty-input {
        grid-template-columns: minmax(0, 1fr) 96px;
    }

    .cbc-btn {
        padding: 12px 16px;
    }

    .cbc-headline {
        gap: 10px;
    }

    .cbc-headline-title {
        font-size: 1.35rem;
    }

    .cbc-kv th {
        width: 46%;
    }

    .cbc-info {
        padding: 12px;
        gap: 10px;
    }
}
