﻿/* ========== Wamin - ZET Theme ========== */
:root {
    --zet-primary: #7c1f87;
    --zet-dark: #5b1466;
    --zet-darker: #3d0e44;
    --zet-light: #f3e8f5;
    --zet-lighter: #f9f3fa;
}

* {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-size: 14px;
    overscroll-behavior: none;
}

.hidden { display: none !important; }

/* ========== Split Layout ========== */
.chat-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Desktop */
@media (min-width: 1024px) {
    body {
        background: #1a0d1e;
    }
    .chat-container {
        max-width: 100%;
        margin: 0;
        height: 100vh;
    }
}

.panel-left {
    width: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e5e7eb;
    background: white;
}

.panel-right {
    display: none;
    flex-direction: column;
    background: #f0ebe4;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    color: white;
    background: linear-gradient(135deg, #7c1f87, #5b1466);
    flex-shrink: 0;
}

/* Desktop: side-by-side */
@media (min-width: 768px) {
    .panel-left {
        width: 280px;
        min-width: 280px;
        max-width: 280px;
    }
    .panel-right {
        display: flex;
        flex: 1;
    }
    .md-hide {
        display: none !important;
    }
    .chat-item.active {
        background-color: var(--zet-light);
    }
    .chat-item {
        padding: 8px 12px;
        gap: 10px;
    }
    .chat-item .avatar {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
}

/* Mobile: full screen switch */
@media (max-width: 767px) {
    .panel-left.mobile-hidden {
        display: none !important;
    }
    .panel-right {
        display: none;
        width: 100%;
    }
    .panel-right.mobile-show {
        display: flex !important;
    }
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1c4d6; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--zet-primary); }

/* ========== SweetAlert Overrides ========== */
.swal2-title { font-size: 1rem; }
.swal2-popup {
    font-size: 0.8rem;
    border-radius: 16px;
    padding: 1.5em;
}
.swal2-popup .swal2-styled.swal2-confirm {
    background-color: var(--zet-primary);
    border-radius: 10px;
    font-size: 0.9em;
    padding: 10px 28px;
}

/* ========== Animations ========== */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-slideUp {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========== Chat List ========== */
.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
}
.chat-item:hover {
    background-color: var(--zet-lighter);
}
.chat-item:active {
    background-color: var(--zet-light);
}
.chat-item .avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
}
.chat-item .chat-info {
    flex: 1;
    min-width: 0;
}
.chat-item .chat-name {
    font-weight: 600;
    font-size: 14px;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-item .chat-preview {
    font-size: 13px;
    color: #8696a0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.chat-kategori {
    display: inline-block;
    background: var(--zet-light);
    color: var(--zet-primary);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: capitalize;
}
.chat-status-open {
    font-size: 11px;
    color: #e74c3c;
    font-weight: 500;
}
.chat-item .chat-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.chat-item .chat-time {
    font-size: 11px;
    color: #8696a0;
}
.chat-item .chat-time.unread {
    color: var(--zet-primary);
    font-weight: 600;
}
.chat-item .chat-badge {
    background: var(--zet-primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* ========== Messages ========== */
.msg-bubble {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
    position: relative;
    word-wrap: break-word;
    animation: fadeIn 0.2s ease-out;
}
.msg-incoming {
    background: white;
    color: #1a1a1a;
    border-top-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 1px rgba(0,0,0,0.06);
}
.msg-outgoing {
    background: #dcf8c6;
    color: #1a1a1a;
    border-top-right-radius: 4px;
    align-self: flex-end;
    margin-left: auto;
    box-shadow: 0 1px 1px rgba(0,0,0,0.06);
}
.msg-time {
    font-size: 10px;
    color: #8696a0;
    margin-top: 4px;
    text-align: right;
}
.msg-image {
    width: 100%;
    max-width: 200px;
    max-height: 220px;
    object-fit: cover;
    display: block;
    cursor: pointer;
}
.msg-image-wrap {
    min-height: 50px;
    max-height: 220px;
    background: #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
}
.msg-bubble-image {
    padding: 3px !important;
    width: 200px;
    max-width: 60%;
    min-width: 120px;
    position: relative;
}
.msg-bubble-image .msg-image-caption {
    padding: 6px 10px 0;
    font-size: 13px;
    line-height: 1.4;
}
.msg-image-fail {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px;
    color: #999;
    font-size: 12px;
    background: #f0f0f0;
    min-height: 80px;
}
.msg-time-media {
    padding: 0 8px 6px;
}
.swal-image-preview {
    box-shadow: none !important;
    border: none !important;
}
.swal-image-preview .swal2-image {
    max-height: 80vh;
    max-width: 90vw;
    border-radius: 8px;
    margin: 0;
}
.swal-image-preview .swal2-close {
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
    font-size: 28px;
}
.msg-date-separator {
    text-align: center;
    margin: 12px 0;
}
.msg-video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    pointer-events: none;
    transition: opacity 0.2s;
}
.msg-video-play i {
    margin-left: 3px;
}

/* ========== Voice Note Bubble ========== */
.msg-bubble-audio {
    min-width: 240px;
    max-width: 340px;
    padding: 5px 6px !important;
}
.msg-bubble-audio audio { display: none; }
.vn-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.vn-play-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #54656f;
    font-size: 15px;
    padding: 0;
}
.msg-outgoing .vn-play-btn { color: #0d7c47; }
.vn-play-btn:hover { opacity: .8; }
.vn-body { flex: 1; min-width: 0; }
.vn-wave {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 28px;
}
.vn-wave span {
    width: 3px;
    border-radius: 2px;
    flex-shrink: 0;
    opacity: 0.4;
    transition: opacity .15s;
}
.vn-meta {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #8696a0;
    margin-top: 1px;
}
.vn-mic {
    width: 24px; height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.msg-date-separator span {
    background: #e1d8c7;
    color: #54656f;
    font-size: 11px;
    padding: 4px 14px;
    border-radius: 8px;
    font-weight: 500;
    box-shadow: 0 1px 1px rgba(0,0,0,0.06);
}

/* ========== Message Input ========== */
#msg-input {
    line-height: 1.4;
    scrollbar-width: none;
}
#msg-input::-webkit-scrollbar { display: none; }

/* ========== Utilities ========== */
.avatar-green { background: #25d366; }
.avatar-blue { background: #00a5cf; }
.avatar-orange { background: #ff6b35; }
.avatar-pink { background: #e84393; }
.avatar-teal { background: #00b894; }
.avatar-red { background: #e74c3c; }
.avatar-purple { background: var(--zet-primary); }
.avatar-indigo { background: #6c5ce7; }

/* ========== Messages Area ========== */
#messages-area {
    display: flex;
    flex-direction: column;
}

