/* =========================
   PTK CHAT LITE
========================= */

.ptk-chat-lite-wrap,
.ptk-chat-lite-box {
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px;
    background: #fff;
    box-sizing: border-box;
    color: #111827;
}

/* =========================
   TOPBAR
========================= */
.ptk-chat-topbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.ptk-chat-title {
    margin: 0 0 6px;
    font-size: 22px;
    line-height: 1.3;
}

.ptk-chat-submeta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    color: #6b7280;
    font-size: 14px;
}

.ptk-chat-topbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.ptk-chat-inline-form {
    margin: 0;
}

/* =========================
   BUTTONS
========================= */
.ptk-chat-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 999px;
    background: #111827;
    color: #fff;
    text-decoration: none;
    border: 0;
    cursor: pointer;
    font-size: 14px;
}

.ptk-chat-btn--ghost {
    background: #f3f4f6;
    color: #111827;
}

.ptk-chat-btn--danger {
    background: #b91c1c;
    color: #fff;
}

/* =========================
   MESSAGE LIST
========================= */
.ptk-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.ptk-chat-message {
    max-width: 82%;
    padding: 12px 14px;
    border-radius: 14px;
    background: #f3f4f6;
}

.ptk-chat-message.is-me {
    align-self: flex-end;
    background: #eef7ff;
}

.ptk-chat-message.is-other {
    align-self: flex-start;
}

.ptk-chat-message__meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
}

.ptk-chat-message__body {
    white-space: normal;
    word-break: break-word;
    line-height: 1.55;
}

.ptk-chat-message.is-new { opacity: 1; }
.ptk-chat-message.is-mid { opacity: 0.9; }
.ptk-chat-message.is-old { opacity: 0.75; }

/* =========================
   FORM
========================= */
.ptk-chat-form textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 12px;
    min-height: 110px;
    box-sizing: border-box;
}

.ptk-chat-form__actions {
    margin-top: 12px;
}

/* =========================
   ROOM LIST
========================= */
.ptk-chat-room-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ptk-chat-room-card {
    display: block;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 14px;
    text-decoration: none;
    color: inherit;
    background: #fff;
}

.ptk-chat-room-card__head,
.ptk-chat-room-card__meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.ptk-chat-room-card__meta {
    margin-top: 8px;
    color: #6b7280;
    font-size: 14px;
}

.ptk-chat-room-card__snippet {
    margin-top: 10px;
    color: #374151;
}

.ptk-chat-room-card__link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.ptk-chat-room-card__actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.ptk-chat-room-card.is-new {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px rgba(59,130,246,0.15);
}

.ptk-chat-room-card.is-mid {
    opacity: 0.92;
}

.ptk-chat-room-card.is-old {
    opacity: 0.8;
}

/* =========================
   ROOM CARD LAYOUT
========================= */
.ptk-chat-room-card__layout {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 12px;
    align-items: start;
}

.ptk-chat-room-card__thumb {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    overflow: hidden;
    background: #f3f4f6;
}

.ptk-chat-room-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ptk-chat-room-card__no-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #6b7280;
}

/* =========================
   ROOM HEADER
========================= */
.ptk-chat-room-header {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 14px;
    align-items: start;
}

.ptk-chat-room-header__thumb {
    width: 88px;
    height: 88px;
    border-radius: 14px;
    overflow: hidden;
    background: #f3f4f6;
}

.ptk-chat-room-header__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ptk-chat-room-header__no-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #6b7280;
}

.ptk-chat-room-header__links {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =========================
   UNREAD BADGES
========================= */
.ptk-chat-badge,
.ptk-chat-badge-target .ptk-chat-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    padding: 0 5px;
    height: 18px;
    border-radius: 999px;
    background: #e11d48;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.ptk-chat-badge {
    min-width: 24px;
    padding: 4px 10px;
    height: auto;
    background: #dc2626;
    font-size: 12px;
}

.ptk-chat-badge-target {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ptk-badge-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.ptk-chat-room-card.has-unread {
    border-color: #dc2626;
    box-shadow: 0 0 0 1px rgba(220,38,38,0.12);
}

.ptk-chat-room-card__unread {
    margin-top: 10px;
}

/* =========================
   NOTICE BOX
========================= */
.ptk-chat-lite-box.success {
    background: #ecfdf5;
    border-color: #10b981;
    color: #065f46;
}

.ptk-chat-lite-box.error {
    background: #fef2f2;
    border-color: #dc2626;
    color: #7f1d1d;
}

.ptk-chat-lite-box.notice {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1e3a8a;
}

.ptk-chat-lite-box {
    animation: ptkFadeIn 0.3s ease;
}

@keyframes ptkFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================
   MOBILE
========================= */
@media (max-width: 768px) {
    .ptk-chat-message {
        max-width: 100%;
    }

    .ptk-chat-room-card__layout,
    .ptk-chat-room-header {
        grid-template-columns: 1fr;
    }

    .ptk-chat-room-card__thumb,
    .ptk-chat-room-header__thumb {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }
}


/* =========================================================
   📌 FIX GOLD COLOR IN CHAT (READABILITY)
   ป้องกันสีทองอ่านไม่ออกบนพื้นขาว
========================================================= */

/* หัวข้อใน chat */
.ptk-chat-lite-wrap h1,
.ptk-chat-lite-wrap h2,
.ptk-chat-lite-wrap h3,
.ptk-chat-lite-wrap h4,
.ptk-chat-lite-wrap strong {
    color: #111827; /* 🔥 บังคับเป็นเข้ม */
}

/* ลิงก์ */
.ptk-chat-lite-wrap a {
    color: #1f2937;
}

.ptk-chat-lite-wrap a:hover {
    color: #c49a3d; /* hover ค่อยเป็นทอง */
}

/* badge / highlight */
.ptk-chat-lite-wrap .ptk-highlight,
.ptk-chat-lite-wrap .ptk-gold {
    color: #92400e; /* 🔥 ทองเข้ม (อ่านง่ายบนขาว) */
}
