/* ====================================================================================
   DJCRAFTS WA WEB & APP CSS - THE MASTERPIECE EDITION
   ==================================================================================== */

/* STRICT RESET FOR ZERO OVERFLOW */
html { box-sizing: border-box; }
*, *:before, *:after { box-sizing: inherit; margin: 0; padding: 0; }

:root { 
    --wa-dark-green: #008069; --wa-light-green: #00a884;
    --wa-bg-chat: #efeae2; --wa-bg-sidebar: #ffffff; --wa-bg-panel: #f0f2f5;
    --wa-bubble-in: #ffffff; --wa-bubble-out: #d9fdd3; 
    --wa-text: #111b21; --wa-muted: #667781;
    --wa-system: #ffeecd; --wa-blue-tick: #53bdeb;
}

body, html {
    width: 100%; height: 100%; 
    overflow: hidden; /* CRITICAL: Prevents entire page from bouncing/scrolling */
    background-color: #d1d7db; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent; 
}

/* THE DESKTOP GREEN STRIP (Absolute Realism) */
.wa-desktop-background {
    position: absolute; top: 0; left: 0; width: 100%; height: 127px;
    background-color: var(--wa-light-green); z-index: -1;
    display: none; /* Hidden on mobile */
}

/* --- THE MAIN LAYOUT --- */
.wa-web-layout {
    display: flex; justify-content: center; align-items: center;
    width: 100%; height: 100dvh;
}

.wa-app-wrapper {
    display: flex; width: 100%; height: 100%;
    background: var(--wa-bg-panel); position: relative;
    overflow: hidden;
}

/* Desktop Realism WA Web */
@media (min-width: 768px) {
    .wa-desktop-background { display: block; }
    .wa-web-layout { padding: 20px; }
    .wa-app-wrapper {
        width: 100%; max-width: 1600px; height: calc(100vh - 40px);
        box-shadow: 0 6px 18px rgba(0,0,0,0.05); border-radius: 0;
    }
}

/* --- SIDEBAR (Desktop Only) --- */
.wa-sidebar {
    width: 30%; min-width: 320px; max-width: 420px;
    background: var(--wa-bg-sidebar); border-right: 1px solid #d1d7db;
    display: flex; flex-direction: column;
}

.wa-sidebar-header {
    height: 60px; background: var(--wa-bg-panel); padding: 10px 15px;
    display: flex; justify-content: space-between; align-items: center; 
}
.wa-sidebar-icons i { color: #54656f; font-size: 1.2rem; margin-left: 20px; cursor: pointer; }
.wa-sidebar-icons a { color: #54656f; text-decoration: none; }

.wa-search-bar { background: var(--wa-bg-sidebar); padding: 8px 12px; border-bottom: 1px solid #e9edef; }
.wa-search-input-wrapper { background: var(--wa-bg-panel); border-radius: 8px; display: flex; align-items: center; padding: 6px 12px; }
.wa-search-input-wrapper i { color: #54656f; font-size: 0.9rem; margin-right: 15px; }
.wa-search-input-wrapper input { border: none; background: transparent; outline: none; width: 100%; font-size: 0.9rem; }

.wa-contact-list { flex: 1; overflow-y: auto; background: #fff; }
.wa-contact-list::-webkit-scrollbar { width: 6px; }
.wa-contact-list::-webkit-scrollbar-thumb { background: #ccc; }
.wa-contact-item { display: flex; padding: 12px 15px; cursor: pointer; transition: 0.2s; border-bottom: 1px solid #f2f2f2; }
.wa-contact-item:hover { background: #f5f6f6; }
.wa-contact-item.active { background: #f0f2f5; }
.wa-contact-info { flex: 1; margin-left: 15px; display: flex; flex-direction: column; justify-content: center; }
.wa-contact-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.wa-contact-top h4 { font-size: 1.05rem; font-weight: 400; color: #111b21; }
.wa-contact-top span { font-size: 0.75rem; color: #667781; }
.wa-contact-bottom p { font-size: 0.85rem; color: #667781; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

.action-pic { display: flex; justify-content: center; align-items: center; color: #fff; font-size: 1.2rem; border-radius: 50%; }

@media (max-width: 767px) { .wa-sidebar { display: none; } }

/* --- MAIN CHAT AREA --- */
.wa-main-chat {
    flex: 1; display: flex; flex-direction: column; position: relative;
    background: var(--wa-bg-chat); width: 100%;
}
.wa-main-chat::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    opacity: 0.06; z-index: 0; pointer-events: none;
}

/* Chat Header */
.wa-header {
    height: 60px; background: var(--wa-bg-panel); padding: 10px 15px;
    display: flex; justify-content: space-between; align-items: center; z-index: 10; border-bottom: 1px solid #e9edef;
}
.wa-header-left { display: flex; align-items: center; gap: 12px; cursor: pointer; flex: 1; overflow: hidden;}
.wa-back-btn { color: #54656f; font-size: 1.2rem; text-decoration: none; padding-right: 5px; }

@media (max-width: 767px) { 
    .hide-on-desktop { display: flex; } 
    .wa-header { background: var(--wa-dark-green); color: #fff; border-bottom: none;} 
    .wa-back-btn, .wa-header-right i { color: #fff; } 
    .wa-contact-name {color: #fff;} 
}
@media (min-width: 768px) { .hide-on-desktop { display: none; } }

.wa-profile-pic img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0;}
.wa-user-info { display: flex; flex-direction: column; overflow: hidden;}
.wa-contact-name { font-size: 1.05rem; font-weight: 500; margin-bottom: 2px; white-space: nowrap; text-overflow: ellipsis;}
.verified-badge { font-size: 0.85rem; color: #00a884; }
@media (max-width: 767px) { .verified-badge {color: #fff;} }
.wa-status { font-size: 0.8rem; color: #667781; }
@media (max-width: 767px) { .wa-status {color: rgba(255,255,255,0.9);} }
.typing-text { color: var(--wa-light-green); font-weight: 500; font-style: italic;}

.wa-header-right { display: flex; gap: 20px; font-size: 1.2rem; align-items: center; color: #54656f; position: relative;}
.wa-dropdown-menu { 
    display: none; position: absolute; right: 0; top: 40px; 
    background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.2); border-radius: 5px; 
    width: 150px; z-index: 100; flex-direction: column; 
}
.wa-dropdown-menu.show { display: flex; }
.wa-dropdown-menu a { padding: 12px 15px; text-decoration: none; color: #111b21; font-size: 0.95rem; border-bottom: 1px solid #eee;}
.wa-dropdown-menu a:hover { background: #f0f2f5; }

/* --- CHAT HISTORY AREA --- */
.wa-chat-area { 
    flex: 1; padding: 20px 5%; overflow-y: auto; overflow-x: hidden;
    display: flex; flex-direction: column; gap: 15px; z-index: 5; scroll-behavior: smooth; 
}
.wa-chat-area::-webkit-scrollbar { width: 6px; }
.wa-chat-area::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 10px; }

.wa-date-badge, .wa-security-msg {
    align-self: center; background: #fff; color: #54656f; font-size: 0.75rem;
    padding: 6px 12px; border-radius: 8px; box-shadow: 0 1px 1px rgba(0,0,0,0.05); text-align: center;
}
.wa-security-msg { background: var(--wa-system); color: #544324; max-width: 90%; }

/* BUBBLE WRAPPERS & INLINE AVATARS */
.wa-msg-wrapper { display: flex; align-items: flex-end; gap: 8px; max-width: 85%; animation: popIn 0.2s ease;}
.bot-msg-wrapper { align-self: flex-start; }
.user-msg-wrapper { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; box-shadow: 0 1px 2px rgba(0,0,0,0.1);}

.wa-msg-row { display: flex; flex-direction: column; position: relative; }
@keyframes popIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.wa-bubble { 
    padding: 8px 12px; border-radius: 12px; font-size: 0.95rem; 
    line-height: 1.4; box-shadow: 0 1px 1px rgba(0,0,0,0.1); word-break: break-word; min-width: 80px;
}

/* Modern Rounded Bubbles for Avatar style */
.bot-bubble { background: var(--wa-bubble-in); border-bottom-left-radius: 4px; color: var(--wa-text);}
.user-bubble { background: var(--wa-bubble-out); border-bottom-right-radius: 4px; color: var(--wa-text);}

.wa-time { display: inline-block; font-size: 0.65rem; color: var(--wa-muted); float: right; margin: 8px 0 -5px 15px; }

/* Typing Indicator */
.typing-bubble { display: flex; gap: 4px; padding: 14px 18px !important; }
.typing-dots { width: 6px; height: 6px; background: var(--wa-muted); border-radius: 50%; animation: typing 1.4s infinite; opacity: 0.6; }
.typing-dots:nth-child(2) { animation-delay: 0.2s; } .typing-dots:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

.wa-link { color: #027eb5; text-decoration: none; font-weight: 500;}

/* --- INPUT FOOTER --- */
.wa-input-section { 
    background: var(--wa-bg-panel); padding: 10px 15px; z-index: 10; width: 100%; flex-shrink: 0;
}
.wa-input-bar { display: flex; gap: 10px; align-items: flex-end; width: 100%;}
.wa-input-wrapper { 
    flex: 1; background: #fff; border-radius: 24px; padding: 10px 15px; 
    display: flex; align-items: center; gap: 12px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); 
}
.wa-icon { color: #54656f; font-size: 1.4rem; cursor: pointer; flex-shrink: 0;}
.wa-input { flex: 1; border: none; outline: none; font-size: 1rem; background: transparent; width: 100%; }
.wa-send-btn { 
    width: 48px; height: 48px; border-radius: 50%; background: var(--wa-dark-green); 
    color: #fff; border: none; font-size: 1.2rem; cursor: pointer; flex-shrink: 0; transition: 0.2s;
}

.toast {
    visibility: hidden; min-width: 250px; background-color: #333; color: #fff;
    text-align: center; border-radius: 50px; padding: 12px 20px;
    position: fixed; z-index: 1000; left: 50%; bottom: 30px; transform: translateX(-50%);
    font-size: 0.9rem; opacity: 0; transition: opacity 0.3s, bottom 0.3s;
}
.toast.show { visibility: visible; opacity: 1; bottom: 80px; }

@media (max-width: 450px) { 
    .hide-on-mobile { display: none; } 
    .wa-chat-area { padding: 15px 3%; }
    .wa-input-wrapper { padding: 8px 12px; gap: 8px;} 
    .wa-input-section { padding: 8px; }
}