/* public/css/katalog.css */

/* =========================================================
   KATALOG GRID — dense, Tokopedia-style
   ========================================================= */

.katalog-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
}

/* =========================================================
   KATALOG CARD (grid view)
   ========================================================= */

.kcard {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}

.kcard:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--brand) 25%, var(--border-light));
}

.kcard--pro {
    border-color: #f59e0b;
}

.kcard--pro:hover {
    border-color: #d97706;
    box-shadow: 0 4px 20px rgba(245,158,11,0.18);
}

.kcard--featured {
    box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--brand) 30%, transparent);
}

.kcard__link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
    outline-offset: 2px;
}

/* Thumbnail */
.kcard__thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    background: color-mix(in srgb, var(--brand) 5%, var(--bg-card));
    flex-shrink: 0;
}

.kcard__thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s;
    display: block;
}

.kcard:hover .kcard__thumb-img {
    transform: scale(1.05);
}

.kcard__avail {
    position: absolute;
    bottom: 0.375rem;
    left: 0.375rem;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    line-height: 1;
    backdrop-filter: blur(4px);
}

.kcard__avail--busy   { background: rgba(245,158,11,0.88); color: #fff; }
.kcard__avail--closed { background: rgba(107,114,128,0.88); color: #fff; }

.kcard__pro-badge {
    position: absolute;
    top: 0.375rem;
    right: 0.375rem;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    background: rgba(217,119,6,0.9);
    color: #fff;
    backdrop-filter: blur(4px);
    line-height: 1;
}

/* Body */
.kcard__body {
    padding: 0.5rem 0.625rem 0.625rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.kcard__title {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-main);
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kcard__price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--brand);
    margin: 0.125rem 0 0;
}

.kcard__rating {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    margin-top: 0.125rem;
}

.kcard__rating .star-icon { color: #f59e0b; flex-shrink: 0; }

.kcard__rating-num {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-main);
}

.kcard__rating-count {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Seller row */
.kcard__seller {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: auto;
    padding-top: 0.375rem;
}

.kcard__seller-avatar {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.kcard__seller-avatar--fallback {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background: var(--brand);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kcard__seller-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.kcard__verified-icon {
    color: #2563eb;
    flex-shrink: 0;
}

.kcard__location {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.kcard__location svg { flex-shrink: 0; color: var(--text-muted); }

/* =========================================================
   KATALOG LIST VIEW
   ========================================================= */

.katalog-list {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.kcard-list {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 1rem;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}

.kcard-list:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.07);
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--brand) 20%, var(--border-light));
}

.kcard-list--pro { border-color: #f59e0b; }

.kcard-list__thumb-link { flex-shrink: 0; }

.kcard-list__thumb {
    width: 140px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    display: block;
}

.kcard-list__info { flex: 1; min-width: 0; }

.kcard-list__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
    flex-wrap: wrap;
}

.kcard-list__title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kcard-list__title:hover { color: var(--brand); }

.kcard-list__badges { display: flex; gap: 0.3rem; flex-wrap: wrap; flex-shrink: 0; }

.kcard-list__avail-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    line-height: 1;
}

.kcard-list__avail-badge--open   { background: #dcfce7; color: #15803d; }
.kcard-list__avail-badge--busy   { background: #fef9c3; color: #92400e; }
.kcard-list__avail-badge--closed { background: #f3f4f6; color: #6b7280; }

.kcard-list__desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0 0 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kcard-list__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.625rem;
    margin-bottom: 0.5rem;
}

.kcard-list__category {
    font-size: 0.7rem;
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 8%, transparent);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
}

.kcard-list__seller {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.kcard-list__seller-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
}

.kcard-list__seller-name:hover { color: var(--brand); }

.kcard-list__action {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.625rem;
    flex-shrink: 0;
    padding-top: 0.125rem;
}

.kcard-list__price {
    font-size: 1rem;
    font-weight: 700;
    color: var(--brand);
    margin: 0;
    white-space: nowrap;
}

/* =========================================================
   SKELETON override untuk katalog grid
   ========================================================= */

.kcard--skeleton .kcard__thumb {
    aspect-ratio: 3 / 2;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

/* Large desktop: 6 kolom */
@media (min-width: 1280px) {
    .katalog-grid { grid-template-columns: repeat(6, 1fr); }
}

/* Desktop: 5 kolom (default) */
@media (min-width: 1024px) and (max-width: 1279px) {
    .katalog-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Tablet landscape: 4 kolom */
@media (min-width: 768px) and (max-width: 1023px) {
    .katalog-grid { grid-template-columns: repeat(3, 1fr); }

    .kcard-list__thumb {
        width: 110px;
        height: 80px;
    }
}

/* Tablet portrait / large mobile: 3 kolom */
@media (min-width: 480px) and (max-width: 767px) {
    .katalog-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }

    .kcard-list {
        flex-wrap: wrap;
    }

    .kcard-list__thumb {
        width: 100%;
        height: 140px;
    }

    .kcard-list__action {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
}

/* Mobile: 2 kolom */
@media (max-width: 479px) {
    .katalog-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }

    .kcard__body { padding: 0.4rem 0.5rem 0.5rem; }

    .kcard__title { font-size: 0.75rem; }

    .kcard__price { font-size: 0.8125rem; }

    .kcard__seller { display: none; }

    .kcard-list {
        flex-direction: column;
    }

    .kcard-list__thumb {
        width: 100%;
        height: 120px;
    }

    .kcard-list__action {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.kcard, .kcard-list {
    animation: fadeInUp 0.25s ease both;
}

.kcard:nth-child(1)  { animation-delay: 0.02s; }
.kcard:nth-child(2)  { animation-delay: 0.04s; }
.kcard:nth-child(3)  { animation-delay: 0.06s; }
.kcard:nth-child(4)  { animation-delay: 0.08s; }
.kcard:nth-child(5)  { animation-delay: 0.10s; }
.kcard:nth-child(6)  { animation-delay: 0.12s; }
.kcard:nth-child(7)  { animation-delay: 0.14s; }
.kcard:nth-child(8)  { animation-delay: 0.16s; }
.kcard:nth-child(9)  { animation-delay: 0.18s; }
.kcard:nth-child(10) { animation-delay: 0.20s; }
.kcard:nth-child(11) { animation-delay: 0.22s; }
.kcard:nth-child(12) { animation-delay: 0.24s; }

@media (prefers-reduced-motion: reduce) {
    .kcard, .kcard-list { animation: none; }
    .kcard__thumb-img { transition: none; }
}
