/* ============================================
   kasuwa Components
   Shared UI components used across pages
   ============================================ */

:root {
    --kw-primary: #10A5BB;
    --kw-text: #333333;
    --kw-text-muted: #666666;
    --kw-radius: 8px;
    --kw-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid #10A5BB;
    outline-offset: 2px;
}

/* ============================================
   Product Card
   ============================================ */

.kw-product-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: var(--kw-radius);
    box-shadow: var(--kw-shadow);
    transition: box-shadow 0.2s, transform 0.2s;
    min-width: 0;
    overflow: hidden;
}

.kw-product-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.kw-product-card-image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    border-radius: var(--kw-radius) var(--kw-radius) 0 0;
}

.kw-product-card-image img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s ease;
}

/* Product card link (wraps images only) */
.kw-product-card-link {
    display: block;
    width: 100%;
    height: 100%;
}

/* Hover second image */
.kw-product-card-img2 {
    position: absolute;
    top: 0; left: 0;
    opacity: 0;
}
.kw-product-card:hover .kw-product-card-img2.lazyloaded {
    opacity: 1;
}

/* Wishlist star */
.kw-product-fav {
    position: absolute;
    top: 8px; right: 8px;
    width: 32px; height: 32px;
    border: none; border-radius: 50%;
    background: rgba(255,255,255,0.85);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    z-index: 2;
    padding: 0;
    outline: none;
}
.kw-product-fav:focus {
    outline: none;
}
.kw-product-fav svg {
    width: 16px; height: 16px;
    stroke: #666; fill: none;
    transition: fill 0.2s, stroke 0.2s;
}
.kw-product-card:hover .kw-product-fav,
.kw-product-fav.active {
    opacity: 1;
}
.kw-product-fav:hover {
    background: #fff;
}
.kw-product-fav.active svg {
    fill: #f59e0b; stroke: #f59e0b;
}

/* Quick Add-to-Cart button */
.kw-product-quickadd {
    position: absolute;
    bottom: 8px; right: 8px;
    width: 36px; height: 36px;
    border: none; border-radius: 50%;
    background: var(--kw-primary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s, transform 0.15s;
    z-index: 2;
    padding: 0;
    outline: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.kw-product-quickadd:focus {
    outline: none;
}
.kw-product-quickadd svg {
    width: 16px; height: 16px;
    stroke: #fff; fill: none;
}
.kw-product-card:hover .kw-product-quickadd {
    opacity: 1;
}
.kw-product-quickadd:hover {
    background: #0d8a9c;
    transform: scale(1.1);
}
.kw-product-quickadd:active {
    transform: scale(0.95);
}

/* Quick Add — loading state */
.kw-product-quickadd--loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Quick Add — done state (green feedback) */
.kw-product-quickadd--done {
    opacity: 1;
    background: #28a745 !important;
    pointer-events: none;
}

/* Quick Add — Make (digital) orange variant */
.kw-product-card-make .kw-product-quickadd {
    background: #ff6600;
}
.kw-product-card-make .kw-product-quickadd:hover {
    background: #e55c00;
}

.kw-product-card-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 8px;
    background: rgba(255,255,255,0.75);
    border-radius: 4px;
    font-size: 0.6875rem;
    color: var(--kw-text-muted);
}

.kw-product-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px;
}

.kw-product-card-category {
    font-size: 0.75rem;
    color: var(--kw-text-muted);
    margin-bottom: 4px;
}

.kw-product-card-category a {
    color: var(--kw-text-muted);
    text-decoration: none;
}

.kw-product-card-category a:hover {
    color: var(--kw-primary);
}

.kw-product-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kw-product-card-title a {
    color: var(--kw-text);
    text-decoration: none;
}

.kw-product-card-title a:hover {
    color: var(--kw-primary);
}

.kw-product-card-digital {
    color: #FF7700;
}
.kw-product-card-digital svg {
    width: 14px; height: 14px;
    vertical-align: -2px;
}

/* Make (digital) product card color overrides */
.kw-product-card-make .kw-product-card-category a:hover,
.kw-product-card-make .kw-product-card-title a:hover,
.kw-product-card-make .kw-product-card-shop a:hover {
    color: #FF7700;
}
.kw-product-card-make .kw-product-card-price {
    color: #FF7700;
}

.kw-product-card-shop {
    font-size: 0.75rem;
    color: var(--kw-text-muted);
    margin-bottom: 6px;
}

.kw-product-card-shop a {
    color: var(--kw-text-muted);
    text-decoration: none;
}

.kw-product-card-shop a:hover {
    color: var(--kw-primary);
}

.kw-product-card-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--kw-text-muted);
    margin-bottom: 4px;
}
.kw-product-card-rating strong {
    font-weight: 600;
    color: #333;
}
.kw-product-card-rating-count {
    color: #999;
}

.kw-product-card-shipping {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #059669;
    background: #ecfdf5;
    padding: 3px 8px;
    border-radius: 6px;
    margin-bottom: 4px;
}
.kw-product-card-shipping svg {
    width: 12px; height: 12px; flex-shrink: 0;
}

.kw-product-card-price {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 700;
    color: #333;
}

.kw-product-card-price * {
    float: none !important;
    text-align: left !important;
}

.kw-product-card-price .discountprice {
    order: 1;
    font-size: 0.75rem;
    font-weight: 400;
    color: #aaa;
    text-decoration: line-through;
}

.kw-product-card-price .discountprice.text-sale {
    color: #aaa;
}

.kw-product-card-price .discounttext {
    display: none;
}

.kw-product-card-price .float-right {
    float: none !important;
}

.kw-product-card-baseprice {
    display: none;
}

/* Sponsored Badge */
.cat-sponsored-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 8px;
    background: rgba(255,255,255,0.9);
    border-radius: 4px;
    font-size: 0.6875rem;
    color: #999;
    z-index: 1;
}

/* ============================================
   Product Scroll Container
   Horizontal scroll on mobile, grid on desktop
   ============================================ */

.kw-product-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.kw-product-scroll::-webkit-scrollbar {
    display: none;
}

.kw-product-scroll .kw-product-card {
    flex: 0 0 40vw;
    scroll-snap-align: start;
    height: auto;
}

.kw-product-scroll .kw-product-card-image {
    aspect-ratio: 1 / 1;
}

.kw-product-scroll .kw-product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.kw-product-scroll::after {
    content: '';
    position: sticky;
    right: 0;
    flex: 0 0 40px;
    margin-left: -40px;
    align-self: stretch;
    background: linear-gradient(to right, rgba(255,255,255,0), #fff);
    pointer-events: none;
    z-index: 2;
}

/* ============================================
   Responsive Grid: Orphan Prevention

   Maximal 5 Produkte, immer genau 1 volle Reihe.

   | Breakpoint     | Spalten | Sichtbar |
   |----------------|---------|----------|
   | 768px-1023px   | 3       | 3        |
   | 1024px-1279px  | 4       | 4        |
   | 1280px+        | 5+      | 5        |
   ============================================ */

/* Responsive: Tablet (768px+) - 3 Spalten, 3 Produkte */
@media (min-width: 768px) {
    .kw-product-scroll > *:nth-child(n+4) {
        display: none;
    }

    .kw-product-scroll {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        overflow: visible;
    }

    .kw-product-scroll .kw-product-card {
        flex: none;
    }

    .kw-product-scroll .kw-product-card-image {
        aspect-ratio: 1 / 1;
    }

    .kw-product-scroll .kw-product-card-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .kw-product-scroll::after {
        display: none;
    }
}

/* Responsive: Desktop (1024px+) - 4 Spalten, 4 Produkte */
@media (min-width: 1024px) {
    .kw-product-scroll > *:nth-child(4) {
        display: block;
    }

    .kw-product-scroll > *:nth-child(n+5) {
        display: none;
    }

    .kw-product-scroll {
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
    }

    .kw-product-card-title {
        font-size: 0.9375rem;
    }
}

/* Responsive: Large (1280px+) - 5 Spalten, 5 Produkte (max, gilt auch für XL) */
@media (min-width: 1280px) {
    .kw-product-scroll > *:nth-child(5) {
        display: block;
    }

    .kw-product-scroll > *:nth-child(n+6) {
        display: none;
    }

    .kw-product-scroll {
        grid-template-columns: repeat(5, 1fr);
    }
}


/* ============================================
   Last Seen Title
   ============================================ */

.kw-lastseen-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #333;
    margin: 0 0 12px;
}

/* ============================================
   Product Badges (shared)
   ============================================ */

.kw-product-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.kw-product-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.kw-product-badge svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.kw-product-badge-bestseller {
    padding: 4px 10px;
    background: #fff7ed;
    color: #ea580c;
    border-radius: 6px;
}

.kw-product-badge-bestseller svg {
    fill: currentColor;
}

.kw-product-badge-new {
    color: var(--kw-primary);
}

.kw-product-badge-today {
    color: #059669;
}

.kw-product-badge-cart {
    color: var(--kw-primary);
}

.kw-product-badge-custom {
    padding: 4px 10px;
    background: #E6F7F9;
    color: var(--kw-primary);
    border-radius: 6px;
}

.kw-product-badge-unique {
    padding: 4px 10px;
    background: #E6F7F9;
    color: var(--kw-primary);
    border-radius: 6px;
}

.kw-product-badge-soldout {
    color: #dc2626;
}

/* ============================================
   Star Rating (shared)
   ============================================ */

.kw-stars { display: inline-flex; align-items: center; gap: 1px; }
.kw-stars svg.filled { fill: #f59e0b; stroke: none; }
.kw-stars svg.empty  { fill: none; stroke: #d1d5db; stroke-width: 2; }
.kw-stars svg.half   { stroke: none; }

/* ============================================
   Fade-In Animation
   ============================================ */

@keyframes kwFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.kw-card-enter { animation: kwFadeIn 0.35s ease-out both; }

/* ============================================
   Skeleton Loading
   ============================================ */

@keyframes kwPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}
.kw-product-card.skeleton          { pointer-events: none; animation: kwPulse 1.5s ease-in-out infinite; }
.kw-product-card.skeleton .kw-skeleton-image { aspect-ratio: 1; background: #e5e5e5; }
.kw-product-card.skeleton .kw-skeleton-body  { padding: 10px; }
.kw-product-card.skeleton .kw-skeleton-line  { height: 12px; background: #e5e5e5; border-radius: 6px; margin-bottom: 8px; }
.kw-product-card.skeleton .kw-skeleton-line.short { width: 60%; }
.kw-product-card.skeleton .kw-skeleton-line.price { width: 40%; height: 16px; margin-top: 12px; margin-bottom: 0; }
