/* =========================================================
   m4p_cartonfinder — homepage carton finder widgets
   Two side-by-side cards with dimension inputs + submit. Brand palette:
   primary #FF6B00, ink #1D1D1B, border #e5e5e3.
   ========================================================= */

.m4pcf-section {
    margin: 0;
}

/* Strona wyników m4p-cartonfinder-search ma duży gap między menu a tytułem
   "Dopasowane kartony" (breadcrumb + padding wrappera). Zacieśniamy. */
body#m4p-cartonfinder-search #wrapper .breadcrumb {
    display: none;
}

body#m4p-cartonfinder-search #inner-wrapper {
    padding-top: 16px;
    /* Standard search listing ends flush against the footer here — give the
       page the bottom breathing room other listings have. */
    margin-bottom: 48px;
}

body#m4p-cartonfinder-search .m4pcf-results {
    margin-top: 0;
}

/* ---- Tabs (segmented pill switcher) -------------------------------- */
/* Two-state toggle sits above the panels. Both options visible inside one
   rounded "track"; active option fills with primary brand colour, inactive
   stays muted. Equal-width buttons via `flex: 1`, full width up to a sane
   max so it doesn't stretch across the whole page. */
.m4pcf-tabs {
    display: inline-flex;
    width: 100%;
    max-width: 520px;
    margin: 0 auto 18px;
    padding: 4px;
    background: #f5f5f5;
    border: 1px solid #e5e5e3;
    border-radius: 999px;
}

.m4pcf-tab {
    flex: 1 1 50%;
    min-width: 0;
    max-width: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    background: transparent;
    color: #555;
    border: none;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
    /* Text doesn't break the row — truncate with "…" if it doesn't fit. */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.m4pcf-tab .fa {
    /* Don't let the icon shrink when label is squeezed. */
    flex: 0 0 auto;
}

/* Label sits inside its own span so `text-overflow: ellipsis` can clip it —
   flex containers can't do ellipsis on a bare text node, the inner element
   needs `min-width: 0` to allow shrinking below content width. */
.m4pcf-tab__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.m4pcf-tab:hover:not(.is-active),
.m4pcf-tab:focus-visible:not(.is-active) {
    color: #1D1D1B;
    background: rgba(255, 255, 255, 0.6);
    outline: none;
}

.m4pcf-tab.is-active {
    background: #FF6B00;
    color: #ffffff;
    cursor: default;
    box-shadow: 0 2px 8px rgba(255, 107, 0, 0.25);
}

.m4pcf-tab .fa {
    font-size: 0.95rem;
    color: inherit;
}

@media (max-width: 480px) {
    .m4pcf-tabs {
        max-width: 100%;
    }
    .m4pcf-tab {
        padding: 9px 10px;
        font-size: 0.78rem;
        letter-spacing: 0.01em;
    }
}

/* ---- Panels -------------------------------------------------------- */
.m4pcf-panels {
    display: block;
}

.m4pcf-panel {
    display: none;
}

.m4pcf-panel.is-active {
    display: flex;
}

.m4pcf-panel[hidden] {
    display: none !important;
}

.m4pcf-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px 24px;
    background: #ffffff;
    border: 1px solid #e5e5e3;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(29, 29, 27, 0.04);
}

.m4pcf-card__header {
    margin: 0;
}

.m4pcf-card__title {
    margin: 0 0 4px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #1D1D1B;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.m4pcf-card__lead {
    margin: 0;
    color: #555;
    font-size: 0.9rem;
    line-height: 1.4;
}

.m4pcf-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

/* Carton panel — long+wide+high+type all on one row on desktop. */
.m4pcf-fields--carton {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 767px) {
    .m4pcf-fields--carton {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 420px) {
    .m4pcf-fields--carton {
        grid-template-columns: 1fr;
    }
}

.m4pcf-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    font-size: 0.78rem;
    color: #1D1D1B;
}

.m4pcf-field__label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-size: 0.7rem;
    color: #555;
}

/* ---- Field tooltip (? icon + image popup) -------------------------- */
.m4pcf-help {
    display: inline-flex;
    align-items: center;
    position: relative;
    padding: 0;
    background: none;
    border: none;
    color: #bbb;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.m4pcf-help:hover,
.m4pcf-help:focus {
    color: #FF6B00;
    outline: none;
}

.m4pcf-help__popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: #fff;
    border: 1px solid #e5e5e3;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(29, 29, 27, 0.14);
    padding: 6px;
    width: 120px;
    pointer-events: none;
}

/* Arrow pointing down */
.m4pcf-help__popup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #fff;
    filter: drop-shadow(0 1px 0 #e5e5e3);
}

.m4pcf-help__popup img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.m4pcf-help:hover .m4pcf-help__popup,
.m4pcf-help:focus .m4pcf-help__popup,
.m4pcf-help.is-open .m4pcf-help__popup {
    display: block;
}

.m4pcf-field input[type="number"],
.m4pcf-field select {
    width: 100%;
    height: 42px;
    padding: 8px 12px;
    border: 1px solid #dddddd;
    border-radius: 8px;
    background: #ffffff;
    color: #1D1D1B;
    font-size: 0.95rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.m4pcf-field input[type="number"]::-webkit-outer-spin-button,
.m4pcf-field input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.m4pcf-field input[type="number"]:focus,
.m4pcf-field select:focus {
    outline: none;
    border-color: #FF6B00;
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

.m4pcf-field select {
    padding-right: 32px;
    background-image: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23555' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.m4pcf-field--type {
    width: 100%;
}

/* Fragile/heavy checkbox */
.m4pcf-checkbox {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 10px;
    align-items: start;
    margin: 0;
    cursor: pointer;
    user-select: none;
}

.m4pcf-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: #FF6B00;
    cursor: pointer;
}

.m4pcf-checkbox span {
    font-size: 0.88rem;
    font-weight: 600;
    color: #1D1D1B;
    line-height: 1.3;
}

.m4pcf-helper {
    grid-column: 2;
    display: block;
    margin-top: 2px;
    font-size: 0.75rem;
    color: #555;
    font-weight: 400;
}

.m4pcf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
    padding: 12px 22px;
    background: #FF6B00;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.05s ease;
    align-self: flex-start;
}

.m4pcf-btn:hover,
.m4pcf-btn:focus {
    background: #cc5500;
    color: #ffffff;
    outline: none;
}

.m4pcf-btn:active {
    transform: scale(0.98);
}

.m4pcf-btn .fa {
    font-size: 0.9rem;
}

/* Results page */
.m4pcf-results {
    margin-bottom: 48px;
}

.m4pcf-results__summary {
    margin: 0 0 18px;
    color: #555;
    font-size: 0.95rem;
}

.m4pcf-results__summary p {
    margin: 0 0 4px;
}

.m4pcf-results__count {
    margin: 0 0 14px;
    color: #555;
    font-size: 0.9rem;
}

/* ---- Sidebar (filters) -------------------------------------------- */
.m4pcf-layout {
    margin-top: 12px;
}

.m4pcf-sidebar {
    margin-bottom: 24px;
}

.m4pcf-filters {
    padding: 18px;
    background: #ffffff;
    border: 1px solid #e5e5e3;
    border-radius: 10px;
    position: sticky;
    top: 12px;
}

.m4pcf-filters__title {
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e5e3;
    font-size: 0.95rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #1D1D1B;
}

.m4pcf-filter-group {
    border: none;
    padding: 0;
    margin: 0 0 16px;
}

.m4pcf-filter-group legend {
    width: auto;
    margin: 0 0 8px;
    padding: 0;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #1D1D1B;
}

.m4pcf-price-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.m4pcf-price-range label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
}

.m4pcf-price-range span {
    font-size: 0.72rem;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.m4pcf-price-range input,
.m4pcf-sort {
    width: 100%;
    height: 38px;
    padding: 6px 10px;
    border: 1px solid #dddddd;
    border-radius: 8px;
    background: #ffffff;
    color: #1D1D1B;
    font-size: 0.9rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.m4pcf-price-range input:focus,
.m4pcf-sort:focus {
    outline: none;
    border-color: #FF6B00;
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.12);
}

.m4pcf-sort {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23555' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.m4pcf-checkbox-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}

.m4pcf-checkbox-list li {
    padding: 4px 0;
}

.m4pcf-checkbox-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 0.85rem;
    color: #1D1D1B;
    cursor: pointer;
}

.m4pcf-checkbox-list input[type="checkbox"] {
    accent-color: #FF6B00;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.m4pcf-checkbox-list small {
    color: #888;
    font-weight: 400;
}

.m4pcf-filters__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding-top: 14px;
    border-top: 1px solid #e5e5e3;
}

.m4pcf-filters__reset {
    color: #555;
    font-size: 0.85rem;
    text-decoration: none;
}

.m4pcf-filters__reset:hover {
    color: #FF6B00;
}

@media (max-width: 991px) {
    .m4pcf-filters {
        position: static;
    }
}
