.support-thread {
    max-width: 950px;
    width: 100%;
    margin: auto;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    height: 90vh;
    overflow: hidden;
    position: relative;
    border: 1px solid #f0f2f5;
    margin-top: 5px;
}

.thread-header {
    padding: 12px 16px;
    background: #f0f2f5;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

/* LEFT SIDE */
.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0; /* prevents overflow */
}

/* BACK BUTTON */
.back-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #111b21;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.back-btn:active {
    transform: scale(0.92);
}

/* AVATAR */
.support-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
}

/* TEXT */
.header-text {
    min-width: 0;
}

.header-text h5 {
    margin: 0;
    font-weight: 600;
    font-size: 16px;
    color: #111b21;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-text p {
    margin: 0;
    font-size: 13px;
    color: #667781;
    display: flex;
    align-items: center;
    gap: 4px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ONLINE DOT */
.online-dot {
    width: 8px;
    height: 8px;
    background: #25d366;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* STATUS */
.thread-status {
    font-size: 12px;
    padding: 4px 10px;
    background: #25d36620;
    border-radius: 20px;
    color: #25d366;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

/* =========================
   📱 MOBILE FIX
========================= */
@media (max-width: 576px) {

    .thread-header {
        padding: 10px 12px;
    }

    .header-info {
        gap: 8px;
    }

    .support-avatar {
        width: 34px;
        height: 34px;
        font-size: 18px;
    }

    .back-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .header-text h5 {
        font-size: 14px;
    }

    .header-text p {
        font-size: 11px;
    }

    .thread-status {
        font-size: 11px;
        padding: 4px 8px;
    }
}

.thread-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.thread-message {
    display: flex;
    gap: 8px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.thread-message.user {
    justify-content: flex-end;
}

.thread-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 18px;
}

.thread-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.thread-content {
    max-width: 65%;
}

.thread-message.user .thread-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.thread-card {
    background: #ffffff;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
    border: 1px solid #efeae2;
}

.thread-message.user .thread-card {
    background: #d9fdd3;
    border-bottom-right-radius: 4px;
}

.thread-message.support .thread-card {
    border-bottom-left-radius: 4px;
}

.thread-meta {
    font-size: 11px;
    color: #667781;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}

.thread-message.support .thread-meta {
    justify-content: flex-start;
}

.attachment-image {
    max-width: 240px;
    max-height: 220px;
    border-radius: 16px;
    cursor: pointer;
    transition: 0.2s;
    border: 1px solid #ddd8ce;
    background: #f8f6f0;
}

.attachment-image:hover {
    transform: scale(1.01);
    opacity: 0.95;
}

.attachment-file {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f1f3f7;
    padding: 8px 14px;
    border-radius: 16px;
    cursor: pointer;
    transition: 0.2s;
}

.attachment-file:hover {
    background: #e4e6e9;
}

.attachment-file i {
    font-size: 28px;
    color: #25d366;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    margin-bottom: 2px;
    font-size: 12px;
}

.file-size {
    font-size: 10px;
    color: #667781;
}

.thread-system {
    text-align: center;
    font-size: 12px;
    color: #667781;
    margin: 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.thread-system::before,
.thread-system::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
}

.thread-input {
    padding: 8px 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.input-wrapper {
    position: relative;
    background: white;
    border-radius: 28px;
    display: flex;
    align-items: flex-end;
    padding: 6px 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.message-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    line-height: 1.4;
    resize: none;
    max-height: 120px;
    padding: 8px 0;
    padding-left: 70px;
    padding-right: 45px;
}

.input-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 22px;
    color: #54656f;
    cursor: pointer;
}

.input-icon.left:nth-of-type(1) {
    left: 10px;
}

.input-icon.left:nth-of-type(2) {
    left: 40px;
}

.send-btn {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: none;
    color: #8696a0;
    font-size: 20px;
    cursor: pointer;
}

.send-btn.active {
    color: #25d366;
}

.action-btn {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #54656f;
    cursor: pointer;
    transition: background 0.2s;
}

.action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.message-input::placeholder {
    color: #8696a0;
}

.emoji-picker-container {
    position: absolute;
    bottom: 80px;
    left: 12px;
    z-index: 1000;
    display: none;
    background: white;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    width: 320px;
}

.emoji-picker-container.show {
    display: block;
}

.simple-emoji-picker {
    background: white;
}

.emoji-header {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
}

.emoji-header input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 260px;
    overflow-y: auto;
    padding: 8px;
}

.emoji-item {
    font-size: 24px;
    cursor: pointer;
    text-align: center;
    padding: 6px;
    transition: transform 0.1s;
    border-radius: 8px;
}

.emoji-item:hover {
    transform: scale(1.2);
    background: #f0f2f5;
}

.file-preview {
    background: #f0f2f5;
    border-radius: 12px;
    padding: 6px 10px;
    margin-bottom: 6px;

    display: inline-flex;
    align-items: center;
    gap: 8px;

    width: auto;
    max-width: 260px;

    animation: fadeIn 0.2s ease;
}

.file-preview-info {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.preview-thumbnail {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: #e9ecef;
}

.preview-details {
    flex: 1;
}

.preview-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 2px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}

.preview-size {
    font-size: 11px;
    color: #667781;
}

.remove-file {
    cursor: pointer;
    color: #dc3545;
    font-size: 20px;
    padding: 4px;
    transition: transform 0.2s;
}

.remove-file:hover {
    transform: scale(1.1);
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 8px 12px;
    background: white;
    border-radius: 16px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #8696a0;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Scrollbar */
.thread-body::-webkit-scrollbar {
    width: 6px;
}

.thread-body::-webkit-scrollbar-track {
    background: transparent;
}

.thread-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

@media (max-width: 640px) {
    body {
        padding: 0;
    }

    .support-thread {
        height: 100vh;
        border-radius: 0;
        border: none;
        margin-top: 0;
    }

    .thread-content {
        max-width: 80%;
    }

    .emoji-picker-container {
        width: 280px;
        left: 8px;
    }

    .emoji-grid {
        grid-template-columns: repeat(7, 1fr);
    }
}