/* ==========================================================================
   MINIMALIST ENTERPRISE PRODUCT GRID & VIEW SWITCHER
   ========================================================================== */

/* --- TOOLBAR & VIEW SWITCHER --- */
.items-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border, #e4e4e7);

    & .sub-nav {
        border-bottom: none;
        margin-bottom: 0;
    }
}

.view-switcher {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #f4f4f5;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.03);
    margin-bottom: 12px;
    position: relative;
        top: 7px;

    & .view-btn {
        background: transparent;
        border: none;
        padding: 5px 8px;
        border-radius: 6px;
        cursor: pointer;
        color: #71717a;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.15s ease;

        & svg {
            width: 15px;
            height: 15px;
            stroke-width: 2;
            stroke: currentColor;
            fill: none;
        }

        &:hover {
            color: #09090b;
        }

        &.active {
            background: #ffffff;
            color: #09090b;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
        }
    }
}

/* --- GRID CONTAINER BASE --- */
.product-grid {
    display: grid;
    gap: 16px;
    width: 100%;
}

/* --- CATALOG CARD BASE --- */
.catalog-card {
    background: #ffffff;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    display: flex;

    &:hover {
        border-color: #a1a1aa;
    }
}

.card-img-box {
    position: relative;
    background: #fafafa;
    overflow: hidden;

    & img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: opacity 0.2s ease;
        border-radius: 6px;
    }
}

.card-body {
    display: flex;
    flex-direction: column;

    & .card-date {
        font-size: 11px;
        color: #a1a1aa;
        font-weight: 500;
        letter-spacing: 0.02em;
        margin-bottom: 4px;
    }

    & h4 {
        font-size: 13.5px;
        font-weight: 600;
        line-height: 1.4;
        margin: 2px 0 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;

        & a {
            color: #09090b;
            text-decoration: none;

            &::after {
                content: '';
                position: absolute;
                inset: 0; /* Cover top, right, bottom, left */
                z-index: 1;
            }

            &:hover {
                text-decoration: underline;
            }


        }
    }

    & .card-price {
        font-size: 14px;
        font-weight: 700;
        color: #09090b;
        margin-top: 6px;
        letter-spacing: -0.01em;
    }

    & .card-stats {
        font-size: 11px;
        color: #71717a;
        display: flex;
        align-items: center;
        gap: 4px;
        margin-top: auto;
        
    }
}


/* ==========================================================================
   MODE 1: ROW VIEW (GRID - 5 ITEMS PER ROW)
   ========================================================================== */
.product-grid.view-row {
    grid-template-columns: repeat(5, 1fr);

    & .catalog-card {
        flex-direction: column;
    }

    & .card-img-box {
        width: 100%;
        aspect-ratio: 1 / 1;
        border-bottom: 1px solid #f4f4f5;
    }

    & .card-body {
        padding: 12px 1px;
        flex: 1;

        & .card-stats {
            padding-top: 10px;
            margin-top: 0px;
        }
    }

    /* Göm footer-knapparna i Grid view */
    & .card-footer {
        display: none;
    }

    /* Minimalistiska Hover Actions i bildområdet */
    & .card-image-actions {
        position: absolute;
        top: 8px;
        right: 8px;
        display: flex;
        align-items: center;
        gap: 4px;
        opacity: 0;
        transform: translateY(-4px);
        transition: all 0.15s ease-in-out;
        pointer-events: none;
        z-index: 10;
        & a, & button {
            width: 30px;
            height: 30px;
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.92);
            backdrop-filter: blur(8px);
            border: 1px solid rgba(0, 0, 0, 0.08);
            display: flex;
            align-items: center;
            justify-content: center;
            color: #09090b;
            cursor: pointer;
            transition: all 0.15s ease;

            & svg {
                width: 14px;
                height: 14px;
                stroke-width: 2;
                stroke: currentColor;
                fill: none;
            }

            &:hover {
                background: #09090b;
                color: #ffffff;
                border-color: #09090b;
            }

            &.external-market-btn {
                &:hover {
                    background: #2563eb;
                    color: #ffffff;
                    border-color: #2563eb;
                }
                & {
                    color: #2563eb;
                }
            }

            &.danger {
                color: #dc2626;
            }

            &.danger:hover {
                background: #ef4444;
                color: #ffffff;
                border-color: #ef4444;
            }
        }
    }

    & .catalog-card:hover .card-image-actions {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }
}

/* Responsiv nedbrytning för Row View */
@media (max-width: 1550px) { .product-grid.view-row { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 1200px) { .product-grid.view-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 850px)  { .product-grid.view-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px)  { .product-grid.view-row { grid-template-columns: 1fr; } }


/* ==========================================================================
   MODE 2: COLUMN VIEW (LIST)
   ========================================================================== */
.product-grid.view-column {
    grid-template-columns: 1fr;
    gap: 8px;
    

    & .catalog-card {
        flex-direction: row;
        align-items: center;
        padding: 10px 16px;
        gap: 16px;
        border-radius: 8px;
        border: 1px solid #00000014;
        border-radius: 10px;

        &:hover {
            background-color: #fafafa;
        }
    }

    & .card-img-box {
        width: 112px;
        aspect-ratio: 1/1;
        border-radius: 6px;
        border: 1px solid #e4e4e7;
        flex-shrink: 0;
    }

    & .card-body {
        padding: 0;
        flex: 1;
        min-width: 0;

        & .card-price {
            margin-top: 2px;
        }

        & .card-stats {
            margin-top: 8px;
        }
    }

    /* Göm bildens hover-knappar i List-view */
    & .card-image-actions {
        display: none;
    }

    /* Minimalistiska handlingar i lista (Footer) */
    & .card-footer {
        display: flex;
        align-items: center;
        gap: 6px;
        margin-left: auto;
        flex-shrink: 0;
        z-index: 10;

        & a, & button {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 500;
            background: #ffffff;
            border: 1px solid #e4e4e7;
            color: #09090b;
            cursor: pointer;
            transition: all 0.15s ease;
            text-decoration: none;

            & svg {
                width: 14px;
                height: 14px;
                stroke-width: 1.75;
                stroke: currentColor;
                fill: none;
            }

            &:hover {
                background: #f4f4f5;
                border-color: #d4d4d8;
            }

            &.external-market-btn {
                color: #2563eb;
                border-color: #e4e4e7;

                &:hover {
                    background: #eff6ff;
                    border-color: #bfdbfe;
                    color: #1d4ed8;
                }
            }

            &.primary {
                background: #09090b;
                color: #ffffff;
                border-color: #09090b;

                &:hover {
                    background: #27272a;
                }
            }

            &.danger {
                color: #dc2626;

                &:hover {
                    background: #fef2f2;
                    border-color: #fecdd3;
                }
            }
        }
    }
}

/* Mobil-fallback för lista */
@media (max-width: 640px) {
    .product-grid.view-column .catalog-card {
        flex-wrap: wrap;
        padding: 12px;
    }
    .product-grid.view-column .card-footer {
        width: 100%;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid #f4f4f5;
        justify-content: flex-end;
    }
}