/* /thanhtoan/assets/css/chat.css */

/* ======================== */
/* INLINE CHAT              */
/* ======================== */
.inline-chat {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}
.inline-chat-header {
    padding: 14px 18px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.inline-chat-title {
    font-weight: 700;
    font-size: 15px;
    color: #1e293b;
}
.inline-chat-hint {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}
.inline-chat-messages {
    height: 360px;
    overflow-y: auto;
    padding: 16px;
    background: #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.inline-chat-input {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

/* ======================== */
/* CHAT MODAL (admin)       */
/* ======================== */
.chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: chatFadeIn 0.2s ease;
}
.chat-panel {
    background: #fff;
    width: 95%;
    max-width: 520px;
    height: 80vh;
    max-height: 650px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    overflow: hidden;
}
.chat-panel .inline-chat-messages {
    flex: 1;
    height: auto;
}
.chat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
}
.chat-modal-title { font-weight: 700; font-size: 15px; }
.chat-modal-sub { font-size: 12px; opacity: 0.8; margin-top: 2px; }
.chat-close-btn {
    width: 36px; height: 36px; border-radius: 50%;
    border: none; background: rgba(255,255,255,0.15);
    color: #fff; font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.chat-close-btn:hover { background: rgba(255,255,255,0.25); }

/* ======================== */
/* EMPTY & LOADING          */
/* ======================== */
.chat-empty {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 100%;
    color: #94a3b8; font-size: 14px; text-align: center; gap: 8px;
}
.chat-empty-icon { font-size: 40px; }
.chat-empty-hint { font-size: 12px; max-width: 240px; }
.chat-loading { text-align: center; padding: 40px; color: #94a3b8; }

/* ======================== */
/* MESSAGE BUBBLES          */
/* ======================== */
.chat-msg { display: flex; max-width: 80%; animation: chatMsgIn 0.2s ease; }

.chat-msg-mine { align-self: flex-end; }
.chat-msg-mine .chat-msg-bubble {
    background: #2563eb; color: #fff;
    border-radius: 16px 16px 4px 16px;
}
.chat-msg-mine .chat-msg-sender { color: rgba(255,255,255,0.7); }
.chat-msg-mine .chat-msg-time { color: rgba(255,255,255,0.6); }

.chat-msg-other { align-self: flex-start; }
.chat-msg-other .chat-msg-bubble {
    background: #fff; color: #1e293b;
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.chat-msg-other .chat-msg-sender { color: #2563eb; }
.chat-msg-other .chat-msg-time { color: #94a3b8; }

.chat-msg-bubble { padding: 10px 14px; max-width: 100%; word-break: break-word; }
.chat-msg-sender { font-size: 11px; font-weight: 600; margin-bottom: 4px; }
.chat-msg-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.chat-msg-time { font-size: 10px; margin-top: 4px; text-align: right; }

.chat-msg-image { margin-bottom: 4px; }
.chat-msg-image img {
    max-width: 260px; max-height: 260px;
    border-radius: 10px; cursor: pointer;
    display: block; object-fit: cover;
}
.chat-msg-image img:hover { opacity: 0.9; }

/* ======================== */
/* INPUT AREA               */
/* ======================== */
.chat-image-preview {
    display: flex; align-items: center; gap: 8px;
    padding: 8px; margin-bottom: 8px;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px;
}
.chat-image-preview img {
    width: 60px; height: 60px; border-radius: 8px; object-fit: cover;
}
.chat-image-preview button {
    width: 24px; height: 24px; border-radius: 50%;
    border: none; background: #ef4444; color: #fff;
    font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.chat-input-row { display: flex; align-items: center; gap: 8px; }
.chat-attach-btn {
    width: 40px; height: 40px; border-radius: 50%;
    border: 1px solid #e2e8f0; background: #f8fafc;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 18px; flex-shrink: 0;
}
.chat-attach-btn:hover { background: #e2e8f0; }
.chat-text-input {
    flex: 1; padding: 10px 16px;
    border: 1px solid #e2e8f0; border-radius: 24px;
    font-size: 14px; outline: none;
    background: #f8fafc; color: #1e293b; font-family: inherit;
}
.chat-text-input:focus { border-color: #2563eb; background: #fff; }
.chat-text-input::placeholder { color: #94a3b8; }
.chat-send-btn {
    width: 40px; height: 40px; border-radius: 50%;
    border: none; background: #2563eb; color: #fff;
    font-size: 18px; cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.chat-send-btn:hover { background: #1d4ed8; }
.chat-send-btn:active { transform: scale(0.92); }

/* ======================== */
/* IMAGE VIEWER             */
/* ======================== */
.chat-image-viewer {
    position: fixed; inset: 0; background: rgba(0,0,0,0.9);
    z-index: 10000; display: flex;
    align-items: center; justify-content: center;
    cursor: pointer; animation: chatFadeIn 0.2s ease;
}
.chat-image-viewer img {
    max-width: 95%; max-height: 95%;
    border-radius: 8px; object-fit: contain;
}

/* ======================== */
/* ANIMATIONS               */
/* ======================== */
@keyframes chatFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes chatMsgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ======================== */
/* MOBILE                   */
/* ======================== */
@media (max-width: 640px) {
    .chat-panel {
        width: 100%; height: 100vh; max-height: 100vh; border-radius: 0;
    }
    .chat-msg { max-width: 88%; }
    .chat-msg-image img { max-width: 200px; }
    .inline-chat-input { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .inline-chat-messages { height: 300px; }
}

/* ======================== */
/* PRE-CHAT BOX             */
/* (ô thông tin trước tạo đơn) */
/* ======================== */
.pre-chat-box {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}
.pre-chat-messages {
    min-height: 120px;
    max-height: 300px;
    overflow-y: auto;
    padding: 14px;
    background: #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pre-chat-placeholder {
    color: #94a3b8;
    font-size: 13px;
    text-align: center;
    padding: 30px 10px;
}
.pre-chat-bubble {
    background: #2563eb;
    color: #fff;
    padding: 10px 14px;
    border-radius: 14px 14px 4px 14px;
    align-self: flex-end;
    max-width: 85%;
    word-break: break-word;
    position: relative;
    animation: chatMsgIn 0.2s ease;
}
.pre-chat-bubble-text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}
.pre-chat-bubble-img {
    margin-bottom: 4px;
}
.pre-chat-bubble-img img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
    object-fit: cover;
}
.pre-chat-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}
.pre-chat-bubble:hover .pre-chat-remove {
    display: flex;
}
.pre-chat-image-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}
.pre-chat-image-preview img {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
}
.pre-chat-image-preview button {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pre-chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

/* ======================== */
/* PAYMENT IMAGE THUMBNAILS */
/* ======================== */
.payment-images-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.payment-img-thumb {
    position: relative;
    display: inline-block;
}
.payment-img-thumb img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid #e2e8f0;
}
.payment-img-thumb img:hover {
    opacity: 0.85;
}
.payment-img-thumb button {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ======================== */
/* HEADER RATE BADGE        */
/* ======================== */
.header-rate-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 8px;
    background: linear-gradient(135deg, #dbeafe, #e0f2fe);
    border: 1px solid #93c5fd;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    margin-left: 12px;
}
@media (max-width: 768px) {
    .header-rate-badge {
        font-size: 10px;
        padding: 3px 8px;
        margin-left: 0;
    }
}

/* ======================== */
/* ORDER TIMELINE           */
/* ======================== */
.order-timeline {
    display: flex;
    align-items: flex-start;
    gap: 0;
    overflow-x: auto;
    padding: 8px 0;
}
.timeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 80px;
    position: relative;
    text-align: center;
}
.timeline-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 16px;
    left: 50%;
    width: 100%;
    height: 3px;
    background: #e2e8f0;
    z-index: 0;
}
.timeline-step.active:not(:last-child)::after {
    background: #2563eb;
}
.timeline-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #f1f5f9;
    border: 3px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    z-index: 1;
    color: #94a3b8;
}
.timeline-step.active .timeline-dot {
    background: #dbeafe;
    border-color: #2563eb;
    color: #2563eb;
}
.timeline-label {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 6px;
    line-height: 1.3;
}
.timeline-step.active .timeline-label {
    color: #1e293b;
    font-weight: 600;
}

@media (max-width: 640px) {
    .timeline-step {
        min-width: 60px;
    }
    .timeline-label {
        font-size: 9px;
    }
    .timeline-dot {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* ======================== */
/* SUB ORDER CARD EXPAND    */
/* ======================== */
.sub-order-card {
    margin-bottom: 12px;
}
.sub-order-card [id^="sub-order-expand-"] {
    animation: chatFadeIn 0.2s ease;
}

/* ======================== */
/* COPY CODE BUTTON         */
/* ======================== */
.btn-copy-code {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    margin-left: 4px;
    border-radius: 4px;
    vertical-align: middle;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.btn-copy-code:hover {
    opacity: 1;
    background: #e2e8f0;
}

/* ======================== */
/* TIMELINE TIMESTAMPS      */
/* ======================== */
.timeline-time {
    font-size: 9px;
    color: #94a3b8;
    margin-top: 2px;
}
.timeline-step.active .timeline-time {
    color: #3b82f6;
}
