/* ==========================================================
   Chat Page — DokterTaman.com
   Path: vendors/chat.css
   ========================================================== */

:root {
    --green-50:  #f0fdf4;
    --green-100: #dcfce7;
    --green-200: #bbf7d0;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --green-700: #15803d;
    --gray-50:   #f9fafb;
    --gray-100:  #f3f4f6;
    --gray-200:  #e5e7eb;
    --gray-400:  #9ca3af;
    --gray-600:  #4b5563;
    --gray-800:  #1f2937;
    --white:     #ffffff;
    --red-500:   #ef4444;
    --blue-500:  #3b82f6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: 'Poppins', system-ui, -apple-system, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    -webkit-font-smoothing: antialiased;
}

body {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 720px;
    margin: 0 auto;
    background: var(--white);
    box-shadow: 0 0 40px rgba(0,0,0,.04);
}

/* ---------- HEADER ---------- */
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--green-600), var(--green-700));
    color: var(--white);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 10;
}
.chat-back, .chat-header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 50%;
    color: var(--white);
    background: rgba(255,255,255,.15);
    text-decoration: none;
    transition: background .2s;
    flex-shrink: 0;
}
.chat-back:hover, .chat-header-btn:hover { background: rgba(255,255,255,.28); }
.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.chat-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--white);
    color: var(--green-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.chat-title {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-status {
    font-size: 12px;
    opacity: .9;
    display: flex;
    align-items: center;
    gap: 6px;
}
.chat-status .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #86efac;
    box-shadow: 0 0 0 2px rgba(134,239,172,.35);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .55; }
}

/* ---------- ORDER BANNER ---------- */
.chat-order-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--green-50);
    border-bottom: 1px solid var(--green-100);
    color: var(--green-700);
    font-size: 13px;
}
.chat-order-banner strong { display: block; font-size: 14px; }
.chat-order-banner small { opacity: .8; font-size: 12px; }
.chat-order-banner i { font-size: 20px; opacity: .7; }

/* ---------- BODY ---------- */
.chat-body {
    flex: 1;
    overflow-y: auto;
    background:
        radial-gradient(circle at 20% 10%, rgba(34,197,94,.06), transparent 40%),
        radial-gradient(circle at 80% 90%, rgba(59,130,246,.04), transparent 40%),
        var(--gray-50);
    padding: 16px 12px;
    scroll-behavior: smooth;
}
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-loading {
    text-align: center;
    color: var(--gray-400);
    font-size: 13px;
    padding: 20px 0;
}

/* ---------- BUBBLE ---------- */
.msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: fadeIn .25s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.msg-row.user  { justify-content: flex-end; }
.msg-row.admin { justify-content: flex-start; }

.msg-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    color: var(--white);
}
.msg-row.admin .msg-avatar { background: var(--green-600); }
.msg-row.user  .msg-avatar { background: var(--blue-500); order: 2; }

.msg-content {
    max-width: 78%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.msg-row.user .msg-content { align-items: flex-end; }

.msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: var(--shadow-sm);
}
.msg-row.admin .msg-bubble {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-bottom-left-radius: 4px;
    color: var(--gray-800);
}
.msg-row.user .msg-bubble {
    background: linear-gradient(135deg, var(--green-600), var(--green-700));
    color: var(--white);
    border-bottom-right-radius: 4px;
}
.msg-time {
    font-size: 10px;
    color: var(--gray-400);
    padding: 0 4px;
}

/* ---------- ORDER CARD ---------- */
.order-card {
    background: var(--green-50);
    border: 1px solid var(--green-100);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    font-size: 13px;
}
.order-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.order-card-code {
    font-weight: 700;
    color: var(--green-700);
}
.order-status {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.order-status.pending   { background: #fef3c7; color: #92400e; }
.order-status.paid      { background: #dbeafe; color: #1e40af; }
.order-status.shipped   { background: #ede9fe; color: #5b21b6; }
.order-status.completed { background: #dcfce7; color: #166534; }
.order-status.cancelled { background: #fee2e2; color: #991b1b; }

.order-card-row {
    display: flex;
    gap: 6px;
    margin: 3px 0;
    color: var(--gray-600);
    font-size: 12px;
}
.order-card-row i {
    width: 14px;
    text-align: center;
    color: var(--green-600);
    margin-top: 2px;
}
.order-card-items {
    list-style: none;
    margin: 8px 0 6px;
    padding: 6px 0;
    border-top: 1px dashed var(--green-200);
    border-bottom: 1px dashed var(--green-200);
}
.order-card-items li {
    font-size: 12px;
    color: var(--gray-600);
    padding: 2px 0;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.order-card-items li span:first-child { flex: 1; }
.order-card-total {
    font-weight: 700;
    color: var(--green-700);
    text-align: right;
    font-size: 13px;
    margin-top: 4px;
}

/* ---------- INPUT BAR ---------- */
.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -2px 8px rgba(0,0,0,.03);
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
}
.chat-input-bar input {
    flex: 1;
    height: 44px;
    border: 1px solid var(--gray-200);
    border-radius: 22px;
    padding: 0 18px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    background: var(--gray-50);
    transition: border-color .2s, background .2s;
}
.chat-input-bar input:focus {
    border-color: var(--green-500);
    background: var(--white);
}
.chat-input-bar button {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--green-600), var(--green-700));
    color: var(--white);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s, box-shadow .2s;
    box-shadow: 0 4px 12px rgba(22,163,74,.35);
    flex-shrink: 0;
}
.chat-input-bar button:hover:not(:disabled) { transform: scale(1.05); }
.chat-input-bar button:disabled { opacity: .6; cursor: not-allowed; }

/* ---------- TOAST ---------- */
.chat-toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--gray-800);
    color: var(--white);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: all .3s;
    z-index: 99;
    max-width: 90vw;
    text-align: center;
}
.chat-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.chat-toast.error { background: var(--red-500); }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 480px) {
    .msg-content { max-width: 85%; }
    .order-card { font-size: 12px; padding: 10px; }
    .order-card-items li { font-size: 11px; }
}