/* ============================================================
   Category Product Widget — CPW
   ============================================================ */

.cpw-section {
    font-family: inherit;
}

/* ── Category navigation ─────────────────────────────────── */
.cpw-cat-nav-wrap {
    background: #ffffff;
    border-top:    1px solid #e8e8e8;
    border-bottom: 1px solid #e8e8e8;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cpw-cat-nav {
    display: flex;
    align-items: stretch;
    max-width: 1400px;
    margin: 0 auto;
}

.cpw-cat-item {
    flex: 1;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: border-color 0.2s ease;
    min-width: 110px;
    outline: none;
}

.cpw-cat-item:hover {
    border-bottom-color: rgba(232, 25, 44, 0.35);
}

.cpw-cat-item.is-active {
    border-bottom-color: #e8192c;
}

.cpw-cat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 22px 16px 18px;
    gap: 12px;
    border-right: 1px solid #e8e8e8;
    height: 100%;
    box-sizing: border-box;
}

.cpw-cat-item:last-child .cpw-cat-card {
    border-right: none;
}

.cpw-cat-thumb {
    width: 80px;
    height: 68px;
    object-fit: contain;
    display: block;
}

.cpw-no-thumb {
    width: 80px;
    height: 68px;
    background: #f0f0f0;
    border-radius: 2px;
}

.cpw-cat-name {
    font-size: 13px;
    color: #666666;
    text-align: center;
    line-height: 1.35;
    transition: color 0.15s;
}

.cpw-cat-item:hover .cpw-cat-name {
    color: #333333;
}

.cpw-cat-item.is-active .cpw-cat-name {
    color: #e8192c;
    font-weight: 600;
}

/* ── Spinner overlay on category card ─────────────────────── */
.cpw-cat-card {
    position: relative; /* needed for overlay positioning */
}

.cpw-cat-spinner-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 2px;
    z-index: 5;
}

.cpw-cat-item.is-loading .cpw-cat-spinner-overlay {
    display: flex;
}

.cpw-cat-spinner {
    display: inline-block;
    position: relative;
    width: 36px;
    height: 36px;
}

.cpw-cat-spinner div {
    box-sizing: border-box;
    display: block;
    position: absolute;
    width: 28px;
    height: 28px;
    margin: 4px;
    border: 3px solid transparent;
    border-top-color: #e8192c;
    border-radius: 50%;
    animation: cpw-spin 0.7s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.cpw-cat-spinner div:nth-child(1) { animation-delay: -0.3s; }
.cpw-cat-spinner div:nth-child(2) { animation-delay: -0.2s; }
.cpw-cat-spinner div:nth-child(3) { animation-delay: -0.1s; }

@keyframes cpw-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ── Panels (one per category, rendered server-side) ──────── */
.cpw-panel {
    display: none;
}

.cpw-panel.is-active {
    display: block;
}

/* ── Grid ─────────────────────────────────────────────────── */
.cpw-grid-wrap {
    background-color: #f4f4f4;
    padding: 36px 60px 40px;
}

.cpw-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    max-width: 1400px;
    margin: 0 auto;
}


/* ── Product card ─────────────────────────────────────────── */
.cpw-product-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    padding: 20px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-sizing: border-box;
}

/* Header: thumbnail + name side-by-side */
.cpw-card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.cpw-thumb {
    width: 82px;
    height: 82px;
    object-fit: contain;
    flex-shrink: 0;
    background: #f8f8f8;
}

.cpw-product-name {
    font-size: 15px;
    font-weight: 600;
    color: #2c2c2c;
    margin: 0;
    line-height: 1.35;
    padding-top: 2px;
}

/* Support links */
.cpw-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.cpw-link-item {
    font-size: 13px;
    line-height: 1.5;
}

.cpw-link-item.has-link a {
    color: #4a8db5;
    text-decoration: none;
}

.cpw-link-item.has-link a:hover {
    text-decoration: underline;
}

.cpw-link-item.no-link span {
    color: #aaaaaa;
}

/* Product Page button */
.cpw-card-footer {
    margin-top: auto;
}

.cpw-product-btn {
    display: block;
    width: 100%;
    padding: 10px 12px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: #e8192c;
    border: 1px solid #e8192c;
    background: transparent;
    text-decoration: none;
    box-sizing: border-box;
    transition: background-color 0.18s ease, color 0.18s ease;
    letter-spacing: 0.02em;
}

.cpw-product-btn:hover {
    background-color: #e8192c;
    color: #ffffff;
}

/* No products state */
.cpw-no-products {
    text-align: center;
    color: #999999;
    font-size: 14px;
    padding: 50px 0;
    grid-column: 1 / -1;
    margin: 0;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1100px) {
    .cpw-grid-wrap {
        padding: 28px 40px 32px;
    }
    .cpw-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .cpw-grid-wrap {
        padding: 20px 20px 24px;
    }
    .cpw-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .cpw-cat-nav {
        min-width: max-content;
    }
    .cpw-cat-item {
        min-width: 100px;
        flex: 0 0 auto;
    }
}
