* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
body {
    font-family: "Sarabun", sans-serif;
    background: #eef3ee;
    color: #333;
    min-height: 100vh;
}
.navbar {
    background: linear-gradient(135deg, #1b5e20 0%, #2d8b46 50%, #43a047 100%);
    padding: 0;
    box-shadow: 0 4px 20px rgba(27, 94, 32, 0.25);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 72px;
}

.nav-logo a {
    color: white;
    font-size: 1.8rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 1px;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
}

.nav-menu a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    white-space: nowrap;
}

.nav-menu a:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: translateY(-1px);
}

.nav-menu a.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.nav-menu .cart-link {
    position: relative;
}

.cart-badge {
    background: #ff6b6b;
    color: white;
    border-radius: 50%;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 4px;
    position: absolute;
    top: -6px;
    right: -6px;
}

.chat-page {
    max-width: 1180px;
    height: calc(100vh - 108px);
    margin: 18px auto;
    padding: 0 18px;
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
}
.panel {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 5px 24px rgba(0, 0, 0, 0.07);
    overflow: hidden;
}
.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.sidebar-head {
    padding: 20px;
    border-bottom: 1px solid #edf1ed;
}
.sidebar-head h2 {
    color: #1b5e20;
    font-size: 1.25rem;
}
.search-wrap {
    padding: 12px 14px;
    border-bottom: 1px solid #edf1ed;
}
.search-wrap input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid #dce5dc;
    border-radius: 11px;
    font-family: inherit;
    outline: none;
}
.search-wrap input:focus {
    border-color: #2d8b46;
}
.conversation-list {
    overflow-y: auto;
    flex: 1;
}
.conversation-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f2f0;
    cursor: pointer;
    transition: 0.2s;
}
.conversation-item:hover,
.conversation-item.active {
    background: #eef8ee;
}
.conv-avatar,
.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #e8f5e9;
    border: 2px solid #2d8b46;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    font-size: 1.35rem;
}
.conv-avatar img,
.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.conv-main {
    min-width: 0;
    flex: 1;
}
.conv-name {
    font-weight: 700;
    color: #1b5e20;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-preview {
    font-size: 0.82rem;
    color: #777;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}
.conv-time {
    font-size: 0.72rem;
    color: #999;
    white-space: nowrap;
}
.chat-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.chat-header {
    padding: 14px 18px;
    border-bottom: 1px solid #e8eee8;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fbfefb;
}
.chat-header-main {
    flex: 1;
    min-width: 0;
}
.chat-title {
    font-weight: 700;
    color: #1b5e20;
}
.chat-subtitle {
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
}
.chat-product {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 11px;
    background: #eef8ee;
    cursor: pointer;
    max-width: 300px;
    border: none;
    font-family: inherit;
    color: inherit;
    text-align: left;
}
.chat-product.show {
    display: flex;
}
.chat-product img {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 8px;
    background: #eee;
}
.chat-product div {
    min-width: 0;
}
.chat-product-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1b5e20;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-product-note {
    font-size: 0.72rem;
    color: #777;
}
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background:
        radial-gradient(circle at 20% 20%, rgba(76, 175, 80, 0.05), transparent 30%),
        linear-gradient(180deg, #f8fbf8, #f2f7f2);
}
.day-separator {
    text-align: center;
    margin: 14px 0;
}
.day-separator span {
    display: inline-block;
    background: rgba(255, 255, 255, 0.9);
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    color: #888;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.message-row {
    display: flex;
    margin: 8px 0;
}
.message-row.mine {
    justify-content: flex-end;
}
.message-bubble {
    max-width: min(72%, 560px);
    padding: 10px 12px;
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 2px 9px rgba(0, 0, 0, 0.06);
    word-break: break-word;
}
.message-row.mine .message-bubble {
    background: linear-gradient(135deg, #2d8b46, #1b6b30);
    color: #fff;
    border-bottom-right-radius: 5px;
}
.message-row.other .message-bubble {
    border-bottom-left-radius: 5px;
}
.message-text {
    white-space: pre-wrap;
    line-height: 1.55;
    font-size: 0.94rem;
}
.message-media {
    margin-bottom: 7px;
}
.message-media img,
.message-media video {
    display: block;
    max-width: 100%;
    max-height: 360px;
    border-radius: 11px;
    background: #111;
    cursor: pointer;
}
.message-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
    font-size: 0.68rem;
    color: #999;
}
.message-row.mine .message-meta {
    color: rgba(255, 255, 255, 0.75);
}
.message-sender {
    font-size: 0.72rem;
    color: #2d8b46;
    font-weight: 700;
    margin-bottom: 4px;
}
.typing {
    min-height: 22px;
    padding: 0 18px 5px;
    color: #777;
    font-size: 0.8rem;
    background: #f8fbf8;
}
.composer {
    padding: 12px 14px;
    border-top: 1px solid #e2e9e2;
    background: #fff;
}
.preview-box {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 9px;
    margin-bottom: 9px;
    background: #f4f8f4;
    border-radius: 10px;
}
.preview-box.show {
    display: flex;
}
.preview-box img,
.preview-box video {
    width: 72px;
    height: 58px;
    object-fit: cover;
    border-radius: 8px;
    background: #111;
}
.preview-info {
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
    color: #666;
}
.remove-preview {
    border: none;
    background: #e53935;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
}
.composer-row {
    display: flex;
    align-items: flex-end;
    gap: 9px;
}
.attach-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: #e8f5e9;
    color: #1b5e20;
    font-size: 1.15rem;
    cursor: pointer;
    flex-shrink: 0;
}
.attach-btn:hover {
    background: #c8e6c9;
}
.message-input {
    flex: 1;
    min-height: 44px;
    max-height: 130px;
    resize: none;
    padding: 11px 13px;
    border: 1px solid #dce5dc;
    border-radius: 13px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    line-height: 1.45;
}
.message-input:focus {
    border-color: #2d8b46;
    box-shadow: 0 0 0 3px rgba(45, 139, 70, 0.08);
}
.send-btn {
    height: 44px;
    padding: 0 20px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #2d8b46, #1b6b30);
    color: #fff;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
}
.send-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.empty-chat {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #999;
    padding: 30px;
}
.empty-chat .icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 10px;
}
.media-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}
.media-modal.show {
    display: flex;
}
.media-modal img,
.media-modal video {
    max-width: 95vw;
    max-height: 92vh;
    object-fit: contain;
}
.media-modal button {
    position: absolute;
    right: 20px;
    top: 18px;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 1.7rem;
    cursor: pointer;
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #43a047;
    display: inline-block;
    margin-right: 5px;
}
@media (max-width: 850px) {
    .chat-page {
        grid-template-columns: 1fr;
        height: auto;
        min-height: calc(100vh - 90px);
    }
    .sidebar {
        max-height: 260px;
    }
    .chat-panel {
        height: calc(100vh - 110px);
    }
    .chat-product {
        display: none !important;
    }
}
@media (max-width: 768px) {
    .nav-container {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 20px;
        gap: 10px;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
        width: 100%;
    }

    .nav-menu a {
        padding: 6px 12px;
        font-size: 0.82rem;
    }

    .chat-page {
        padding: 0 8px;
        margin: 8px auto;
        gap: 8px;
    }
    .message-bubble {
        max-width: 86%;
    }
    .send-btn {
        padding: 0 14px;
    }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
