/* ═══════════════════════════════════════════════════════════════════════
   Chat Showcase — Public Styles
   Scoped under .csp-* — no global pollution
═══════════════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────────── */
:root {
    --csp-client-bg:    #ffffff;
    --csp-client-color: #111827;
    --csp-agent-bg:     #dcf8c6;
    --csp-agent-color:  #111827;
    --csp-chat-bg:      #e5ddd5;
    --csp-chat-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Crect width='60' height='60' fill='%23e5ddd5'/%3E%3Ccircle cx='10' cy='10' r='1.5' fill='%23d4c9bf' opacity='.5'/%3E%3Ccircle cx='30' cy='10' r='1.5' fill='%23d4c9bf' opacity='.5'/%3E%3Ccircle cx='50' cy='10' r='1.5' fill='%23d4c9bf' opacity='.5'/%3E%3Ccircle cx='10' cy='30' r='1.5' fill='%23d4c9bf' opacity='.5'/%3E%3Ccircle cx='30' cy='30' r='1.5' fill='%23d4c9bf' opacity='.5'/%3E%3Ccircle cx='50' cy='30' r='1.5' fill='%23d4c9bf' opacity='.5'/%3E%3Ccircle cx='10' cy='50' r='1.5' fill='%23d4c9bf' opacity='.5'/%3E%3Ccircle cx='30' cy='50' r='1.5' fill='%23d4c9bf' opacity='.5'/%3E%3Ccircle cx='50' cy='50' r='1.5' fill='%23d4c9bf' opacity='.5'/%3E%3C/svg%3E");
    --csp-bubble-radius: 12px;
    --csp-font:          -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --csp-accent:        #075e54;
    --csp-accent-light:  #25d366;
    --csp-text:          #111827;
    --csp-muted:         #6b7280;
    --csp-border:        #e5e7eb;
    --csp-radius:        10px;
    --csp-shadow:        0 2px 12px rgba(0,0,0,.08);
}

/* ── Archive grid ──────────────────────────────────────────────────── */
.csp-archive {
    font-family: var(--csp-font);
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px;
}

.csp-archive__header { margin-bottom: 28px; }
.csp-archive__title  { font-size: 2rem; font-weight: 700; color: var(--csp-text); margin: 0 0 8px; }
.csp-archive__desc   { color: var(--csp-muted); margin: 0; font-size: 1rem; }

.csp-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

@media (max-width: 1024px) { .csp-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .csp-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; } }
@media (max-width: 400px)  { .csp-grid { grid-template-columns: 1fr; } }

/* ── Case card ─────────────────────────────────────────────────────── */
.csp-card {
    background: #fff;
    border: 1px solid var(--csp-border);
    border-radius: var(--csp-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s, transform .2s;
}

.csp-card:hover {
    box-shadow: var(--csp-shadow);
    transform: translateY(-2px);
}

.csp-card--featured { border-color: var(--csp-accent-light); }

.csp-card__image-link { display: block; overflow: hidden; }
.csp-card__thumb      { width: 100%; height: 160px; object-fit: cover; display: block; transition: transform .3s; }
.csp-card__image-link:hover .csp-card__thumb { transform: scale(1.04); }

.csp-card__body    { padding: 14px; flex: 1; display: flex; flex-direction: column; }
.csp-card__meta    { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }

.csp-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.csp-badge--whatsapp { background: #e8f8ee; color: #075e54; }
.csp-badge--email    { background: #e8eeff; color: #1a56db; }
.csp-badge--featured { background: #fff3cd; color: #92400e; }

.csp-card__title {
    font-size: .95rem;
    font-weight: 700;
    margin: 0 0 8px;
    line-height: 1.35;
    color: var(--csp-text);
}

.csp-card__title a { color: inherit; text-decoration: none; }
.csp-card__title a:hover { color: var(--csp-accent); }

.csp-card__summary {
    font-size: .84rem;
    color: var(--csp-muted);
    margin: 0 0 12px;
    flex: 1;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.csp-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--csp-border);
}

.csp-card__cta {
    font-size: .82rem;
    font-weight: 600;
    color: var(--csp-accent);
    text-decoration: none;
}

.csp-card__cta:hover { text-decoration: underline; }

.csp-card__views {
    font-size: .75rem;
    color: var(--csp-muted);
}

/* ── Single page layout ────────────────────────────────────────────── */
.csp-single {
    font-family: var(--csp-font);
    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 20px 48px;
    color: var(--csp-text);
}

.csp-single__header  { margin-bottom: 20px; }
.csp-single__title   { font-size: 1.85rem; font-weight: 800; margin: 0 0 10px; line-height: 1.2; }
.csp-single__summary { font-size: 1.05rem; color: var(--csp-muted); margin: 0; line-height: 1.6; }

/* ── Conversation group — two-column layout ───────────────────────── */
.csp-convo-group {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 28px;
    margin-bottom: 40px;
    align-items: flex-start;
}

@media (max-width: 860px) {
    .csp-convo-group { grid-template-columns: 1fr; }
}

/* ── Chat window ───────────────────────────────────────────────────── */
.csp-chat-window {
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--csp-shadow);
    border: 1px solid rgba(0,0,0,.08);
}

.csp-chat-topbar {
    background: var(--csp-accent);
    color: #fff;
    padding: 10px 16px;
    font-size: .85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.csp-chat-topbar__dot {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.csp-chat-body {
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 160px;
    max-height: 480px;
    overflow-y: auto;
}

/* WhatsApp background */
.csp-chat-body--whatsapp {
    background-color:  var(--csp-chat-bg);
    background-image:  var(--csp-chat-pattern);
    background-repeat: repeat;
}

/* White background */
.csp-chat-body--white { background: #fff; }

/* ── Bubbles ───────────────────────────────────────────────────────── */
.csp-bubble {
    max-width: 82%;
    padding: 8px 12px;
    border-radius: var(--csp-bubble-radius);
    font-size: .88rem;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,.12);
    animation: csp-bubble-in .15s ease-out;
}

@keyframes csp-bubble-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.csp-bubble--a {
    background: var(--csp-client-bg);
    color: var(--csp-client-color);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.csp-bubble--b {
    background: var(--csp-agent-bg);
    color: var(--csp-agent-color);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.csp-bubble__role {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    margin-bottom: 3px;
    opacity: .65;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ── Conversation group — two equal columns on desktop ─────────────── */
/* Override: both columns share the same computed width */
.csp-convo-group {
    /* relative so mobile float panel is scoped to this group */
    position: relative;
}

/* ── Screenshot area — DESKTOP ─────────────────────────────────────── */
.csp-screenshot {
    position: sticky;
    top: 80px;
    /* width is already constrained by the grid column = chat window width */
}

/* Thumbnail wrapper — clips the image to a fixed preview height */
.csp-screenshot__thumb-wrap {
    width: 100%;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid var(--csp-border);
    box-shadow: var(--csp-shadow);
    cursor: zoom-in;
    background: #f3f4f6;
    /* Fixed thumbnail height */
    height: 220px;
    transition: height .3s ease, border-radius .3s ease;
    position: relative;
}

.csp-screenshot__thumb-wrap.csp-expanded {
    /* Expand to natural image height — JS sets explicit px height */
    cursor: zoom-out;
    box-shadow: 0 6px 28px rgba(0,0,0,.15);
}

.csp-screenshot__img {
    /* Fill width of column exactly, preserve aspect ratio — no stretching */
    width: 100%;
    height: 100%;
    object-fit: cover;        /* thumbnail: crop-fill */
    object-position: top;     /* show top of image in thumbnail */
    display: block;
    transition: object-fit 0s, height .3s ease;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

.csp-screenshot__thumb-wrap.csp-expanded .csp-screenshot__img {
    object-fit: contain;      /* expanded: full image, no crop, no stretch */
    height: auto;
    width: 100%;
}

/* Zoom hint badge */
.csp-screenshot__hint {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: .7rem;
    padding: 3px 8px;
    border-radius: 20px;
    pointer-events: none;
    transition: opacity .2s;
    font-family: var(--csp-font);
}

.csp-screenshot__thumb-wrap.csp-expanded .csp-screenshot__hint {
    opacity: 0;
}

/* Alt caption */
.csp-screenshot__caption {
    font-size: .75rem;
    color: var(--csp-muted);
    margin: 5px 0 0;
    text-align: center;
    display: block;
}

/* ── Screenshot area — MOBILE (≤860px) ─────────────────────────────── */
@media (max-width: 860px) {
    /* Remove from normal flow — becomes a floating panel inside the group */
    .csp-screenshot {
        position: absolute;
        bottom: 12px;
        right: 12px;
        top: auto;
        width: 88px;           /* collapsed thumbnail size */
        z-index: 20;
        transition: width .25s ease, bottom .25s ease;
    }

    /* Hide screenshot when group is not in viewport (toggled by JS) */
    .csp-screenshot.csp-mob-hidden {
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s;
    }

    .csp-screenshot__thumb-wrap {
        height: 88px;          /* square thumbnail on mobile */
        border-radius: 8px;
        box-shadow: 0 4px 16px rgba(0,0,0,.22);
        transition: width .25s ease, height .25s ease, border-radius .25s ease;
    }

    /* Expanded state on mobile — grows to a comfortable panel */
    .csp-screenshot__thumb-wrap.csp-expanded {
        height: auto;
        border-radius: 10px;
    }

    /* When expanded, the float panel widens to ~75vw */
    .csp-screenshot.csp-mob-open {
        width: min(75vw, 280px);
        bottom: 12px;
        right: 12px;
    }

    .csp-screenshot__img {
        object-fit: cover;
        height: 100%;
    }

    .csp-screenshot.csp-mob-open .csp-screenshot__thumb-wrap {
        height: auto;
    }

    .csp-screenshot.csp-mob-open .csp-screenshot__img {
        object-fit: contain;
        height: auto;
        width: 100%;
    }

    .csp-screenshot__caption { display: none; }

    /* Push chat body bottom padding so floating thumb doesn't overlap messages */
    .csp-chat-body {
        padding-bottom: 110px;
    }
}

/* ── Breadcrumb ────────────────────────────────────────────────────── */
.csp-breadcrumb { margin-bottom: 18px; }

.csp-breadcrumb__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: .82rem;
    color: var(--csp-muted);
}

.csp-breadcrumb__item + .csp-breadcrumb__item::before { content: '›'; margin-right: 4px; }

.csp-breadcrumb__item a { color: var(--csp-accent); text-decoration: none; }
.csp-breadcrumb__item a:hover { text-decoration: underline; }

/* ── FAQ section ───────────────────────────────────────────────────── */
.csp-faq { margin: 40px 0; }
.csp-faq__title { font-size: 1.25rem; font-weight: 700; margin-bottom: 14px; }

.csp-faq__item {
    border: 1px solid var(--csp-border);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.csp-faq__question {
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    padding: 14px 16px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    color: var(--csp-text);
    transition: background .15s;
}

.csp-faq__question:hover { background: #f9fafb; }

.csp-faq__icon {
    flex-shrink: 0;
    font-size: 18px;
    font-weight: 300;
    color: var(--csp-muted);
    transition: transform .2s;
}

.csp-faq__item.open .csp-faq__icon { transform: rotate(45deg); }

.csp-faq__answer {
    display: none;
    padding: 0 16px 14px;
    font-size: .9rem;
    line-height: 1.65;
    color: #374151;
}

.csp-faq__item.open .csp-faq__answer { display: block; }

/* ── CTA block ─────────────────────────────────────────────────────── */
.csp-cta {
    background: linear-gradient(135deg, var(--csp-accent) 0%, #128c7e 100%);
    color: #fff;
    border-radius: 14px;
    padding: 32px 28px;
    margin: 40px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.csp-cta__text { font-size: 1.1rem; font-weight: 600; margin: 0; }

.csp-cta__btn {
    display: inline-block;
    background: #fff;
    color: var(--csp-accent);
    font-weight: 700;
    font-size: .95rem;
    padding: 12px 26px;
    border-radius: 8px;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity .15s;
}

.csp-cta__btn:hover { opacity: .9; }

/* ── Related / Popular ─────────────────────────────────────────────── */
.csp-related { margin: 40px 0; }
.csp-related__title { font-size: 1.2rem; font-weight: 700; margin-bottom: 16px; }

/* ── Copy link button ──────────────────────────────────────────────── */
.csp-copy-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .82rem;
    color: var(--csp-muted);
    background: #f3f4f6;
    border: 1px solid var(--csp-border);
    border-radius: 6px;
    padding: 5px 12px;
    cursor: pointer;
    font-family: var(--csp-font);
    transition: background .15s;
}

.csp-copy-link:hover  { background: #e5e7eb; }
.csp-copy-link.copied { background: #ecfdf5; color: #065f46; border-color: #6ee7b7; }

/* ── Toolbar (copy, views) ──────────────────────────────────────────── */
.csp-single__toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0 28px;
    flex-wrap: wrap;
}

.csp-single__views {
    font-size: .8rem;
    color: var(--csp-muted);
}

/* ── Category filter bar ────────────────────────────────────────────── */
.csp-filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.csp-filter-btn {
    background: #f3f4f6;
    border: 1px solid var(--csp-border);
    border-radius: 20px;
    padding: 5px 16px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--csp-text);
    text-decoration: none;
    transition: background .15s, border-color .15s;
}

.csp-filter-btn:hover,
.csp-filter-btn--active { background: var(--csp-accent); color: #fff; border-color: var(--csp-accent); }
