:root {
    --bg-main: #F3F4F6; /* Latar luar terang abu bersih */
    --bg-chat: #FFFFFF; /* Chatbox super putih */
    --primary: #8B5CF6; /* Ungu modern (Tailwind Violet-500) */
    --primary-hover: #7C3AED; 
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --user-msg: #8B5CF6;
    --ai-msg: #F9FAFB;
    --border: #F3F4F6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.app-wrapper {
    display: flex;
    gap: 30px;
    width: 100%;
    max-width: 1100px;
    justify-content: center;
    flex-wrap: wrap;
}

.chat-container, .wa-dashboard {
    width: 100%;
    max-width: 500px;
    height: 85vh;
    background: var(--bg-chat);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(139, 92, 246, 0.15); /* Shadow soft keunguan */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(139, 92, 246, 0.1);
}

/* Header Styling */
.chat-header, .wa-header {
    padding: 20px 25px;
    background: linear-gradient(135deg, #7C3AED, #A78BFA); /* Gradien ungu modern */
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 15px;
}

.wa-header {
    background: linear-gradient(135deg, #10B981, #34D399); /* Emerald Green for WA */
}

/* Header Avatar Bulat */
.header-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
    background: white;
}

.header-text h1 {
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.header-text span {
    font-size: 0.8rem;
    opacity: 0.9;
}

/* Chat History Area */
.chat-box {
    flex: 1;
    padding: 30px 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    background: #FAFAFA;
}

.chat-box::-webkit-scrollbar {
    width: 6px;
}

.chat-box::-webkit-scrollbar-thumb {
    background: #D8B4FE; /* Scrollbar ungu tipis */
    border-radius: 10px;
}

.message-row {
    display: flex;
    width: 100%;
    animation: fadeIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.user-row {
    justify-content: flex-end;
}

.ai-row {
    justify-content: flex-start;
    align-items: flex-start;
    gap: 12px;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #EDE9FE;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); /* Sedikit efek terbang */
}

/* Wrapper agar Nama & Bubble tersusun Atas-Bawah */
.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.user-row .message-wrapper {
    align-items: flex-end; /* Supaya rata kanan */
}

.ai-row .message-wrapper {
    align-items: flex-start; /* Supaya rata kiri */
}

/* Teks dr. Rianti di atas chat */
.sender-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
    margin-left: 5px;
    margin-right: 5px;
}

.message-content {
    padding: 14px 18px;
    line-height: 1.6;
    font-size: 0.95rem;
    word-wrap: break-word;
}

/* Gelembung User */
.user-row .message-content {
    background: linear-gradient(135deg, var(--user-msg), #7C3AED);
    color: white;
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

/* Gelembung AI / Dokter */
.ai-row .message-content {
    background: var(--ai-msg);
    color: var(--text-primary);
    border-radius: 20px 20px 20px 4px;
    border: 1px solid #F3F4F6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

/* Input Area */
.input-area {
    padding: 18px 25px;
    background: white;
    display: flex;
    gap: 12px;
    align-items: center;
    border-top: 1px solid #F3F4F6;
}

#user-input {
    flex: 1;
    background: #F3F4F6;
    border: none;
    padding: 14px 20px;
    border-radius: 30px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s;
}

#user-input:focus {
    outline: none;
    background: white;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3);
}

#user-input::placeholder {
    color: #9CA3AF;
}

#send-btn {
    background: var(--primary);
    border: none;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    width: 48px;
    height: 48px;
    border-radius: 50%; /* Tombol send sekarang membulat menawan */
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

#send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05); /* Membesar saat disorot */
}

#send-btn:disabled {
    background: #E5E7EB;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Loading Dots */
.loading-message .message-content {
    display: flex;
    gap: 5px;
    align-items: center;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Dashboard WA styles */
.wa-body {
    flex: 1;
    padding: 30px 25px;
    background: #FAFAFA;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    text-align: center;
}

.wa-status-badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.status-offline { background: #FEE2E2; color: #B91C1C; }
.status-qr { background: #FEF3C7; color: #D97706; }
.status-ready { background: #D1FAE5; color: #047857; }

.qr-box {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: none; /* hidden by default */
}

#wa-qr-container {
    width: 200px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}
