/* Live chat AI "Hubungi Admin" (draf Fase 1, rev16.33).
   Widget membangun DOM sendiri lewat ai-chat.js; berkas ini hanya gaya tampilan.
   Tema hijau LapakSMD #137A2A / #0F6B23, radius 16px. */
.ai-chat-root {
    position: fixed;
    z-index: 9999;
    font-family: inherit;
    color: #1f2937;
    box-sizing: border-box;
}
.ai-chat-root *, .ai-chat-root *::before, .ai-chat-root *::after { box-sizing: border-box; }

/* Balon "Hubungi Admin" (mobile dulu: bottom 16, right 16). */
.ai-chat-balloon {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
}
.ai-chat-balloon__avatar {
    display: block;
    width: 96px;
    height: 96px;
    object-fit: cover;
    border: 4px solid #137A2A;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 6px 20px rgba(0,0,0,.35);
    flex: none;
}
.ai-chat-balloon__label {
    margin-top: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: #137A2A;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0,.25);
    white-space: nowrap;
}
.ai-chat-balloon__badge {
    position: absolute;
    top: -6px;
    left: 0;
    display: none;
    padding: 2px 8px;
    border-radius: 999px;
    background: #DC2626;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.ai-chat-balloon__badge--pulse { animation: ai-chat-pulse 1.2s ease-in-out infinite; }
@keyframes ai-chat-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}
.ai-chat-balloon__close {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    background: #DC2626;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0,.3);
}
.ai-chat-balloon__close:hover { color: #fff; background: #B91C1C; }
/* Jendela chat (mobile dulu: width calc(100vw - 32px), max-height 75vh). */
.ai-chat-window {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: none;
    flex-direction: column;
    width: calc(100vw - 32px);
    max-width: 390px;
    height: 550px;
    max-height: 75vh;
    overflow: hidden;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .3);
}
.ai-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    background: #137A2A;
    color: #fff;
    flex: none;
}
.ai-chat-header__avatar {
    display: block;
    object-fit: cover;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #fff;
    flex: none;
}
.ai-chat-header__text { flex: 1; min-width: 0; }
.ai-chat-header__title { font-size: 15px; font-weight: 700; line-height: 1.3; }
.ai-chat-header__sub { font-size: 12px; opacity: .85; line-height: 1.3; }
.ai-chat-header__btn {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
}
.ai-chat-header__btn:hover { background: rgba(255, 255, 255, .2); }
.ai-chat-header__btn--close { top: 0; }
.ai-chat-header__btn--close:hover { background: #DC2626; color: #fff; }
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f3f4f6;
}
.ai-chat-typing {
    display: none;
    padding: 8px 14px;
    font-size: 12px;
    color: #6b7280;
    background: #fff;
    border-top: 1px solid #e5e7eb;
}
.ai-chat-input {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 10px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    flex: none;
}
.ai-chat-input__textarea {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    resize: none;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 16px;
    font: inherit;
    font-size: 14px;
    outline: none;
}
.ai-chat-input__textarea:focus { border-color: #137A2A; }
.ai-chat-input__btn {
    border: 0;
    border-radius: 16px;
    background: #137A2A;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 11px 16px;
    cursor: pointer;
    flex: none;
}
.ai-chat-input__btn:hover { background: #0F6B23; }
.ai-chat-input__btn:disabled { opacity: .6; cursor: default; }
/* Gelembung pesan: AI kiri (putih, nama hijau), user kanan (#DCF8C6). */
.ai-chat-bubble {
    max-width: 82%;
    padding: 10px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}
.ai-chat-bubble--ai {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}
.ai-chat-bubble--user {
    align-self: flex-end;
    background: #DCF8C6;
    border-bottom-right-radius: 4px;
}
.ai-chat-bubble__name {
    font-size: 12px;
    font-weight: 700;
    color: #137A2A;
    margin-bottom: 2px;
}
.ai-chat-bubble__meta {
    margin-top: 4px;
    font-size: 11px;
    color: #6b7280;
    text-align: right;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
}
.ai-chat-checks { color: #9ca3af; font-size: 12px; }
.ai-chat-checks--done { color: #2563eb; }
.ai-chat-welcome {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 12px 14px;
}
.ai-chat-welcome__title { font-size: 15px; font-weight: 700; color: #137A2A; margin-bottom: 4px; }
.ai-chat-welcome__text { font-size: 13px; line-height: 1.5; color: #374151; }
.ai-chat-identity {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 12px;
}
.ai-chat-identity__input, .ai-chat-identity__textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    font: inherit;
    font-size: 14px;
    outline: none;
}
.ai-chat-identity__input:focus, .ai-chat-identity__textarea:focus { border-color: #137A2A; }
.ai-chat-identity__textarea { resize: vertical; min-height: 72px; }
.ai-chat-identity__btn {
    border: 0;
    border-radius: 12px;
    background: #137A2A;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 11px;
    cursor: pointer;
}
.ai-chat-identity__btn:hover { background: #0F6B23; }
.ai-chat-note {
    align-self: center;
    max-width: 90%;
    text-align: center;
    font-size: 12px;
    color: #6b7280;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 12px;
    padding: 8px 12px;
}

/* Desktop (>= 640px): balon 24/24 + hover, jendela 390x550, max-height 82vh. */
@media (min-width: 640px) {
    .ai-chat-balloon { right: 24px; bottom: 24px; }
    .ai-chat-balloon__avatar { width: 104px; height: 104px; }
    .ai-chat-balloon:hover .ai-chat-balloon__label { background: #0F6B23; }
    .ai-chat-window { right: 24px; bottom: 24px; width: 390px; height: 550px; max-height: 82vh; }
}
/* #15: status pesan gagal. */
.ai-chat-message--failed {
    border-color: #fca5a5;
    background: #fef2f2;
    color: #991b1b;
}
