/* Categories Listing — Structural CSS */
/* Colors, borders, gaps come from per-instance generated_css */

.catlist {
    display: block;
    margin-top: 10px;
}

.catlist .cl_list_and_pagination {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 16px;
    position: relative;
}

.catlist a, .catlist button {
    text-decoration: none !important;
    cursor: pointer;
}

.catlist img {
    max-width: 100%;
}

.catlist .cl_list {
    display: grid;
    width: 100%;
    margin: auto;
    overflow-x: hidden;
    overflow-y: hidden;
}

/* Card — flex column so button can stick to bottom via margin-top:auto.
   Gap between elements is here (was on .cl-cat-content wrapper before
   restructuring to match plist1's flat-children pattern). Padding is
   admin-controlled via category_item_style. */
.catlist .cl_list .cl_item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
    transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}

/* Hover — subtle lift */
.catlist .cl_list .cl_item:hover {
    transform: translateY(-2px);
}

/* ─── Horizontal layout — image on the left, everything else stacked on
   the right inside a bare <div> child (matches plist1 horizontal). The
   bare wrapper inherits flex-direction:column from the original card
   default, but inside .cl_item.layout-horizontal it needs to override
   the parent's row direction so its children stack vertically. ─── */
.catlist .cl_list .cl_item.layout-horizontal {
    flex-direction: row;
}

.catlist .cl_list .cl_item.layout-horizontal > .cl-cat-image {
    max-width: 40%;
    flex-shrink: 0;
}

.catlist .cl_list .cl_item.layout-horizontal > div:not(.cl-cat-image) {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

/* ─── Image with aspect ratio ─── */
.cl-cat-image {
    overflow: hidden;
}

.cl-cat-image a {
    display: block;
    position: relative;
    overflow: hidden;
}

/* When padding-bottom is set inline (aspect ratio), image is absolute-positioned */
.cl-cat-image a[style*="padding-bottom"] {
    height: 0;
}

.cl-cat-image a[style*="padding-bottom"] img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.cl-cat-image img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    transition: transform 0.35s ease;
}

/* Zoom on hover */
.catlist .cl_item:hover .cl-cat-image img {
    transform: scale(1.05);
}

/* ─── Title ─── */
.cl-cat-title a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

/* Title-row flex layout — only when the title-row icon is active.
   Without `.has-icon`, the row keeps its natural block layout so the
   existing text-align / font controls in `category_title_style` apply
   the same as before. With `.has-icon`, title text + icon link sit on
   one line (title at start, icon at end). */
.cl-cat-title.has-icon {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
/* Title-text slot — `flex:1` lets long titles shrink + wrap inside the
   slot instead of pushing the icon off the card. `min-width:0` overrides
   flex's default min-width:auto so shrinking below intrinsic content
   width works.
   text-align is INTENTIONALLY not set here — it's admin-controlled via
   category_title_style. The slot inherits text-align from .cl-cat-title,
   which lets admins pick center / left / right and have it apply to
   text inside the expanded slot. */
.cl-cat-title.has-icon .cl-cat-title-text {
    flex: 1;
    min-width: 0;
}
.cl-cat-title-icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.cl-cat-title-icon-link .cl-cat-title-icon,
.cl-cat-title-icon-link svg {
    color: inherit;
    fill: currentColor;
}

/* ─── Description ─── */
.cl-cat-description {
    overflow: hidden;
}

/* ─── Category info ─── */
/* Plain block layout — `text-align` from category_info_style controls
   the placement (start / center / end). No flex here: a flex container
   ignores text-align for child positioning, and the category_info
   element is just a single text line — no icon or multi-element layout
   to justify the flex. (The legacy .cl-cat-product-count rule used flex
   to vertically center an inline icon, but the unified info element
   doesn't have one.) */

/* ─── Button — push to bottom of card ─── */
/* Wrapper is 100% width so its text-align (set by admin via the
   `category_bt_container_style` paintbrush — Alignment) positions the
   inline-flex <a> when admin caps it with max-width. The <a> is
   `width:100%` by default so without max-width it simply fills the
   wrapper and alignment is moot. */
.cl-cat-button-link {
    margin-top: auto;
    width: 100%;
}

.cl-cat-button-link a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    text-decoration: none !important;
    transition: opacity 0.2s ease;
}

.cl-cat-button-link a:hover {
    opacity: 0.8;
}

/* ─── Pagination ─── */
.catlist .list-load-more-btn {
    cursor: pointer;
    transition: opacity 0.3s ease;
}
.catlist .list-load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.catlist .list-loading {
    margin-top: 10px;
    color: #6b7280;
}
.catlist .list-pagination-numbers {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.catlist .cl-pagination-number {
    min-width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.catlist .cl-pagination-number:disabled {
    cursor: not-allowed;
}

/* ─── Filter ─── */
.catlist .list-filter-groups {
    width: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    padding-top: 10px;
}
.catlist .list-filter-group {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: min-content;
}

/* ─── Filter — visually hide radio inputs (list.css only hides checkboxes).
   Cannot use display:none — it breaks label click→radio check in some browsers.
   Use absolute positioning + opacity:0 so the radio stays in DOM + clickable. ─── */
.catlist .list-filter-display-buttons input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.catlist .list-filter-display-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.catlist .list-filter-display-buttons li label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    user-select: none;
    transition: all 0.15s ease;
}

/* ─── Mobile ─── */
@media (max-width: 767px) {
    .catlist .list-filter-container {
        width: 100%;
    }
}

/* ─── Entry animation ─── */
@keyframes cl-catFadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
