/* ============================================================
   style.css — Winsee Chatbot · Mobile-first Responsive
============================================================ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    height: 100%;
    height: -webkit-fill-available;
}

body {
    height: 100%;
    height: 100dvh;
    min-height: -webkit-fill-available;
    overflow: hidden;
    background: url('bgw.png') no-repeat center center fixed;
    background-size: cover;
    font-family: 'Segoe UI', Arial, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   CHAT WRAPPER — inti layout
============================================================ */
.chat-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;           /* full layar di mobile */
    max-width: 480px;
    max-height: 100dvh;
    background: rgba(255,255,255,0.96);
    overflow: hidden;
    /* Desktop: tampil sebagai card mengambang */
    border-radius: 0;
    box-shadow: none;
}

/* Tablet ke atas: tampil sebagai card */
@media (min-width: 520px) {
    body {
        padding: 16px;
        overflow: auto;
        align-items: center;
    }
    .chat-wrapper {
        height: 90dvh;
        max-height: 820px;
        border-radius: 20px;
        box-shadow: 0 24px 64px rgba(0,0,0,0.28);
        background: rgba(255,255,255,0.95);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
}

/* Desktop lebar */
@media (min-width: 900px) {
    .chat-wrapper {
        max-width: 440px;
        height: 85dvh;
        max-height: 780px;
    }
}

/* ============================================================
   HEADER
============================================================ */
.chat-header {
    flex-shrink: 0;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    background: linear-gradient(135deg, #0d6efd, #3d8bfd);
    color: #fff;
    text-align: center;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: .3px;
}

/* ============================================================
   CHAT BOX — scrollable area
============================================================ */
.chat-box {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 12px;
    background: #ece5dd;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Scrollbar tipis */
.chat-box::-webkit-scrollbar { width: 3px; }
.chat-box::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 10px;
}

/* ============================================================
   MESSAGE ROW
============================================================ */
.msg { margin-bottom: 10px; display: flex; }
.msg.user { justify-content: flex-end; }
.msg.bot  { justify-content: flex-start; }

/* ============================================================
   BUBBLE
============================================================ */
.bubble {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    animation: fadeIn 0.22s ease-out;
}

@media (max-width: 360px) {
    .bubble { font-size: 13px; padding: 9px 11px; max-width: 90%; }
}

.user .bubble {
    background: linear-gradient(135deg, #dcf8c6, #c5f0a4);
    color: #111;
    border-bottom-right-radius: 4px;
}
.bot .bubble {
    background: #fff;
    color: #111;
    border-bottom-left-radius: 4px;
}
.bubble a {
    color: #0d6efd;
    text-decoration: underline;
    word-break: break-all;
}

/* ============================================================
   INPUT AREA — selalu di bawah, aman dari keyboard
============================================================ */
.chat-input {
    flex-shrink: 0;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: #f0f0f0;
    border-top: 1px solid #ddd;
}

.input-modern {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #fff;
    border-radius: 26px;
    padding: 6px 8px 6px 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.09);
}
.input-modern:focus-within {
    box-shadow: 0 0 0 2px rgba(13,110,253,0.25), 0 2px 10px rgba(0,0,0,0.09);
}

.input-modern textarea {
    flex: 1;
    border: none;
    resize: none;
    outline: none;
    font-size: 15px;   /* 15px+ mencegah zoom iOS */
    padding: 8px 0;
    font-family: inherit;
    max-height: 100px;
    line-height: 1.45;
    background: transparent;
    color: #111;
}
.input-modern textarea::placeholder { color: #aaa; }

/* Animasi breathing saat idle */
.input-modern textarea { animation: breathing 3s ease-in-out infinite; }
.input-modern textarea:focus { animation: none; }

/* ── Send button ── */
.send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #0d6efd, #3d8bfd);
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, box-shadow .2s;
    flex-shrink: 0;
    margin-bottom: 2px;
}
.send-btn:hover  { transform: scale(1.08); box-shadow: 0 4px 14px rgba(13,110,253,0.4); }
.send-btn:active { transform: scale(0.92); }

/* ============================================================
   QUICK REPLY
============================================================ */
.quick-reply-block {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 4px 10px 12px;
}
.quick-reply-btn {
    background: #fff;
    border: 1.5px solid #4a90d9;
    color: #4a90d9;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background .15s, color .15s, transform .1s;
    width: 100%;
    min-height: 40px;
    font-family: inherit;
}
.quick-reply-btn:hover  { background: #4a90d9; color: #fff; transform: translateY(-1px); }
.quick-reply-btn:active { transform: scale(0.97); }

/* ============================================================
   TYPING INDICATOR
============================================================ */
.typing-bubble {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    padding: 10px 14px;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 72%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    animation: fadeIn 0.22s ease-out;
}
.typing-text { font-size: 12.5px; color: #777; }
.typing-dots { display: flex; gap: 4px; }
.typing-dots span {
    width: 6px; height: 6px;
    background: #aaa;
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }

/* ============================================================
   ONLINE DOT
============================================================ */
.online-dot {
    display: inline-block;
    width: 7px; height: 7px;
    background: #22c55e;
    border-radius: 50%;
    position: relative;
}
.online-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(34,197,94,0.55);
    animation: pulseRing 1.6s ease-out infinite;
}

/* ============================================================
   BUBBLE VARIANTS
============================================================ */
.bubble.countdown { background: #fff3cd; color: #856404; }
.bubble.success   { background: #d4edda; color: #155724; }

/* ============================================================
   MODAL — responsive
============================================================ */
#tipsModal .bg-white,
#myChatModal > div {
    width: 100%;
    max-width: 400px;
    max-height: 90dvh;
    overflow-y: auto;
}

@media (max-width: 440px) {
    #tipsModal { padding: 12px; }
    #myChatModal { padding: 0; align-items: flex-end; }
    #myChatModal > div {
        max-width: 100%;
        max-height: 92dvh;
        border-radius: 20px 20px 0 0;
    }
}

/* ============================================================
   ANIMATIONS
============================================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes bounce {
    0%,80%,100% { transform: translateY(0); opacity: .3; }
    40%          { transform: translateY(-4px); opacity: 1; }
}
@keyframes breathing {
    0%,100% { opacity: .8; }
    50%      { opacity: 1; }
}
@keyframes pulseRing {
    0%   { transform: scale(1); opacity: 1; }
    100% { transform: scale(2.4); opacity: 0; }
}
