/**
 * API Category Template Styles
 * Styles for the product listing page from API
 */

/* Main container */
.products-fallback {
    max-width: 1100px;
    margin: 40px auto;
    padding: 20px;
}

.products-fallback h1 {
    margin-top: 0;
}

/* Product grid */
.products-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 20px;
    margin-top: 50px;
}

/* Product grid (flex layout for equal-height cards; default 4 columns) */
.products-grid .product-link {
    display: flex;
    align-items: stretch;
    box-sizing: border-box;
    flex: 1 0 22%; /* four columns */
    max-width: 22%;
    text-decoration: none;
    color: inherit;
}

/* Product card */
.product-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

/* Make the whole card clickable without changing its layout */
.product-link {
    display: flex;
    align-items: stretch;
    box-sizing: border-box;
    flex: 1 0 22%; /* four columns */
    max-width: 22%;
    text-decoration: none;
    color: inherit;
}

/* Product media */
.product-media {
    margin-bottom: 10px;
}

.product-media > div {
    position: relative;
}

.product-image-container {
    height: 180px;
    overflow: hidden;
    border-radius: 6px;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Navigation buttons */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 12;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
}

.nav-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.prev-btn {
    left: 8px;
}

.next-btn {
    right: 8px;
}

/* Color swatches */
.product-colors {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.product-colors.no-images {
    min-height: 34px;
    visibility: hidden;
}

.color-swatch {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid #ddd;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #fff;
}

.color-swatch:hover {
    border-color: #b48c72;
}

.color-swatch-inner {
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.color-swatch-text {
    font-size: 12px;
    color: #333;
}

/* Product title */
.product-card h3 {
    font-size: 16px;
    margin: 0 0 8px;
    flex: 1;
    display: flex;
    align-items: flex-end;
}

/* Product price */
.product-price {
    color: #b48c72;
    font-weight: 600;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.product-price .original-price {
    color: #999;
    font-size: 14px;
    text-decoration: line-through;
    font-weight: 400;
}

.product-price .discount-price {
    color: #b48c72;
    font-weight: 600;
}

/* Pagination */
.api-pagination {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.api-pagination ul {
    list-style: none;
    display: flex;
    gap: 8px;
    padding: 0;
    margin: 0;
    align-items: center;
}

.api-pagination li a,
.api-pagination li span {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #eee;
    background: #fff;
    color: #333;
    text-decoration: none;
}

.api-pagination li a:hover {
    border-color: #b48c72;
    background: #fafafa;
}

.api-pagination li span {
    border-color: #b48c72;
    background: #b48c72;
    color: #fff;
}

.api-pagination .pagination-ellipsis {
    padding: 8px 12px;
    border: none;
    background: transparent;
}

/* Debug panel */
#products-api-log {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 99999;
    max-width: 420px;
}

#products-api-log-toggle {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 10px 12px;
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    cursor: pointer;
}

#products-api-log-toggle:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

#products-api-log-box {
    display: none;
    margin-top: 12px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.api-log-header {
    padding: 12px;
    border-bottom: 1px solid #f2f2f2;
    font-weight: 600;
    background: #fafafa;
}

.api-log-content {
    max-height: 360px;
    overflow: auto;
    padding: 12px;
    font-family: monospace;
    font-size: 13px;
    white-space: pre-wrap;
}

/* Thumbnail styles (if needed for future use) */
.thumb-btn {
    border: 1px solid #eee;
    padding: 4px;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    margin-right: 6px;
    margin-bottom: 6px;
}

.thumb-btn:hover {
    border-color: #b48c72;
}

.thumb-btn img {
    height: 48px;
    width: 48px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .products-fallback {
        padding: 15px;
        margin: 20px auto;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
        margin-top: 30px;
    }

    .product-image-container {
        height: 140px;
    }

    .nav-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    #products-api-log {
        right: 12px;
        bottom: 12px;
        max-width: calc(100vw - 24px);
    }

    .api-log-content {
        max-height: 240px;
        font-size: 12px;
    }
}
