/* assets/css/frontend.css — Affiliate Inserter Frontend */

/* ── Card grid ────────────────────────────────────────────────────────────── */

.afsi-products-wrap {
    margin: 1.5rem 0;
}

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

/* ── Card ─────────────────────────────────────────────────────────────────── */

.afsi-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform .2s, box-shadow .2s;
}

.afsi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
    text-decoration: none;
}

/* ── Image ─────────────────────────────────────────────────────────────────── */

.afsi-img-wrap {
    aspect-ratio: 1;
    overflow: hidden;
    background: #f1f3f5;
}

.afsi-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.afsi-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: #adb5bd;
}

/* ── Body ──────────────────────────────────────────────────────────────────── */

.afsi-card-body {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 6px;
}

.afsi-card-title {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.afsi-card-footer {
    margin-top: auto;
}

/* ── Shopee button ─────────────────────────────────────────────────────────── */

.afsi-cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: #ee4d2d;
    padding: 5px 12px;
    border-radius: 99px;
    white-space: nowrap;
}

/* ── Inline text link ──────────────────────────────────────────────────────── */

/* ── Text link block (frontend) ──────────────────────────────────────────────── */

/* ปล่อยให้ theme/Gutenberg จัดการ width และ margin
   ห้ามใส่ width:100% หรือ margin:0 !important เพราะจะทำลาย layout centering ของ theme */

/* NEW save: root = <div> */
.wp-block-afs-product-text {
    display: block;
    word-break: break-word;
    box-sizing: border-box;
}

.wp-block-afs-product-text a.afsi-inline-link {
    color: #2271b1 !important;
    text-decoration: underline !important;
    font-weight: 500 !important;
    transition: color 0.15s;
}

.wp-block-afs-product-text a.afsi-inline-link:hover {
    color: #ee4d2d !important;
}

/* OLD save (deprecated): root = <a> */
a.wp-block-afs-product-text {
    display: block;
    word-break: break-word;
    box-sizing: border-box;
}

a.wp-block-afs-product-text.afsi-inline-link {
    color: #2271b1 !important;
    text-decoration: underline !important;
    font-weight: 500 !important;
    transition: color 0.15s;
}

a.wp-block-afs-product-text.afsi-inline-link:hover {
    color: #ee4d2d !important;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .afsi-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* ── afs/product-section — frontend styles ──────────────────────────────────── */

/* ── Kaset Design System (จาก custom HTML block) ──────────────────────────── */

/* Heading */
.kaset-premium-heading-wrapper {
    text-align: center;
    margin: 40px auto 24px auto;
    padding-bottom: 16px;
    position: relative;
    max-width: 600px;
}

.kaset-heading-text {
    font-size: 1.6em;
    font-weight: 800;
    color: #045093;
    margin: 0;
    line-height: 1.5;
}

.kaset-highlight-word {
    position: relative;
    display: inline-block;
    color: #045093;
    z-index: 1;
}

.kaset-highlight-word::after {
    content: '';
    position: absolute;
    left: -2px; right: -2px; bottom: 4px;
    height: 40%;
    background-color: #f2b90c;
    z-index: -1;
    border-radius: 2px;
    opacity: 0.8;
}

.kaset-premium-heading-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 60px; height: 4px;
    background-color: #f2b90c;
    border-radius: 4px;
}

/* Intro paragraph */
.afsi-section-intro {
    text-align: center;
    color: #374151;
    font-size: 1em;
    line-height: 1.7;
    margin: 0 0 24px 0;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Layout: Horizontal (kaset-product-card) ─────────────────────────────── */

.afsi-section-horizontal {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0 0 16px 0;
}

.afsi-section-horizontal a.kaset-product-card {
    text-decoration: none !important;
    color: inherit;
}

.kaset-product-card {
    display: flex;
    align-items: center;
    gap: 24px;
    background-color: #ffffff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(4,80,147,0.08);
    border-left: 6px solid #045093;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kaset-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(4,80,147,0.12);
}

.kaset-card-img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
}

.kaset-card-noimg {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f3f5;
    font-size: 2rem;
    border-radius: 10px;
    flex-shrink: 0;
}

.kaset-card-content {
    flex-grow: 1;
    min-width: 0;
}

.kaset-card-title {
    color: #045093;
    font-size: 1.05em;
    font-weight: 700;
    margin: 0 0 6px 0;
    line-height: 1.4;
}

.kaset-card-desc {
    color: #555555;
    font-size: 0.9em;
    margin: 0 0 14px 0;
    line-height: 1.5;
}

.kaset-card-btn {
    display: inline-block;
    background-color: #f2b90c;
    color: #045093 !important;
    font-size: 0.9em;
    font-weight: 700;
    text-decoration: none !important;
    padding: 8px 24px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(242,185,12,0.3);
    transition: all 0.3s ease;
}

.kaset-card-btn:hover {
    transform: translateY(-2px);
    background-color: #fbcf3b;
}

/* ── Layout: Grid ────────────────────────────────────────────────────────── */

.afsi-section-products.afsi-products-grid {
    margin: 0 0 16px 0;
}

.afsi-card-sold {
    font-size: 11px;
    color: #ee4d2d;
    font-weight: 600;
    margin: 2px 0 0 0;
}

/* ⭐ Rating */
.afsi-card-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 4px 0 2px 0;
}

.afsi-rating-stars {
    color: #f2b90c;
    font-size: 13px;
    letter-spacing: 0.5px;
    line-height: 1;
}

.afsi-rating-value {
    font-size: 12px;
    font-weight: 700;
    color: #555;
    line-height: 1;
}

/* Rating inside horizontal card */
.kaset-card-content .afsi-card-rating {
    margin: 6px 0 10px 0;
}

.kaset-card-content .afsi-rating-stars {
    font-size: 15px;
}

.kaset-card-content .afsi-rating-value {
    font-size: 13px;
}

/* Sold inside horizontal card */
.kaset-card-content .afsi-card-sold {
    font-size: 12px;
    margin: 0 0 10px 0;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .kaset-product-card {
        flex-direction: column;
        text-align: center;
        border-left: none;
        border-top: 6px solid #045093;
        padding: 20px 16px;
        gap: 14px;
    }

    .kaset-heading-text {
        font-size: 1.35em;
    }

    .kaset-card-img,
    .kaset-card-noimg {
        width: 80px;
        height: 80px;
    }
}

/* CTA persuasion / urgency text */
.afsi-section-persuasion {
    text-align: center;
    font-size: 0.95em;
    font-weight: 600;
    color: #045093;
    background: #fff8e1;
    border: 1px solid #f2b90c;
    border-radius: 8px;
    padding: 10px 16px;
    margin: 0 0 20px 0;
}
