/* ==========================================================================
   AK Designer Art — WhatsApp-style chatbot widget
   Vanilla CSS. Nunito throughout. Classic WhatsApp light theme.
   ========================================================================== */

#ak-chatbot,
#ak-chatbot * {
    font-family: 'Nunito', 'Segoe UI', Arial, sans-serif;
    box-sizing: border-box;
}

#ak-chatbot {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 9995;
}

/* ---------- Floating trigger ---------- */
.akcb-trigger {
    position: relative;
    width: 3.75rem;
    height: 3.75rem;
    border: none;
    border-radius: 50%;
    background: linear-gradient(145deg, #00b894 0%, #00a884 55%, #008069 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 28px rgba(0, 168, 132, 0.38), 0 4px 12px rgba(15, 23, 42, 0.14);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 0;
}

.akcb-trigger:hover {
    transform: translateY(-2px) scale(1.04);
}

.akcb-trigger:focus-visible {
    outline: none;
    box-shadow: 0 14px 34px rgba(0, 168, 132, 0.45), 0 0 0 3px rgba(0, 168, 132, 0.35);
}

.akcb-trigger svg {
    width: 1.9rem;
    height: 1.9rem;
}

.akcb-trigger__pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 168, 132, 0.45);
    animation: akcb-pulse 2.4s ease-out infinite;
    pointer-events: none;
}

@keyframes akcb-pulse {
    0% { transform: scale(1); opacity: 0.7; }
    70% { transform: scale(1.45); opacity: 0; }
    100% { transform: scale(1.45); opacity: 0; }
}

.akcb-trigger__dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 50%;
    background: #ff3b30;
    border: 2px solid #fff;
    display: none;
}

#ak-chatbot.akcb-has-unread .akcb-trigger__dot {
    display: block;
}

/* ---------- Chat panel ---------- */
.akcb-panel {
    position: absolute;
    right: 0;
    bottom: 4.5rem;
    width: 380px;
    max-width: calc(100vw - 2.5rem);
    height: 600px;
    max-height: calc(100dvh - 7rem);
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 24px 70px rgba(11, 20, 26, 0.28), 0 4px 16px rgba(11, 20, 26, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0.6) translateY(16px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.2s ease;
}

#ak-chatbot.akcb-open .akcb-panel {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ---------- Header ---------- */
.akcb-header {
    background: #075e54;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.7rem 0.8rem;
    flex-shrink: 0;
}

.akcb-avatar {
    position: relative;
    width: 2.6rem;
    height: 2.6rem;
    flex-shrink: 0;
}

.akcb-avatar img {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    display: block;
}

.akcb-avatar__status {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    background: #25d366;
    border: 2px solid #075e54;
}

.akcb-header__info {
    flex: 1;
    min-width: 0;
}

.akcb-header__name {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.akcb-header__name svg {
    flex-shrink: 0;
}

.akcb-header__status {
    font-size: 0.78rem;
    color: #d1f4cc;
    font-weight: 600;
}

.akcb-close {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}

.akcb-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ---------- Messages area (classic WhatsApp doodle bg) ---------- */
.akcb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.9rem;
    background-color: #ece5dd;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='none' stroke='%23b9b0a3' stroke-width='1.4' opacity='0.35'%3E%3Ccircle cx='24' cy='30' r='7'/%3E%3Cpath d='M70 22 l4 8 8 4 -8 4 -4 8 -4 -8 -8 -4 8 -4 z'/%3E%3Crect x='104' y='66' width='12' height='12' rx='2'/%3E%3Cpath d='M30 96 q6 -10 12 0 q6 10 12 0'/%3E%3Ccircle cx='112' cy='116' r='4'/%3E%3Cpath d='M62 108 h16 M70 100 v16'/%3E%3C/g%3E%3C/svg%3E");
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}

.akcb-messages::-webkit-scrollbar {
    width: 6px;
}
.akcb-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 3px;
}

.akcb-day {
    align-self: center;
    background: #e2f0fb;
    color: #54656f;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.3rem 0.8rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 1px rgba(11, 20, 26, 0.08);
}

/* ---------- Bubbles ---------- */
.akcb-msg {
    max-width: 78%;
    padding: 0.45rem 0.55rem 0.3rem 0.65rem;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #111b21;
    position: relative;
    box-shadow: 0 1px 1px rgba(11, 20, 26, 0.12);
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: akcb-msg-in 0.22s ease;
}

@keyframes akcb-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.akcb-msg--in {
    align-self: flex-start;
    background: #ffffff;
    border-radius: 0 0.5rem 0.5rem 0.5rem;
}

.akcb-msg--out {
    align-self: flex-end;
    background: #d9fdd3;
    border-radius: 0.5rem 0 0.5rem 0.5rem;
}

.akcb-msg__text {
    display: inline;
}

.akcb-msg__text a {
    color: #027eb5;
    font-weight: 700;
    text-decoration: underline;
    word-break: break-all;
}

.akcb-msg--out .akcb-msg__text a {
    color: #00694f;
}

.akcb-msg__meta {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    float: right;
    margin: 0.55rem 0 0 0.5rem;
    font-size: 0.68rem;
    color: #667781;
    font-weight: 600;
    line-height: 1;
}

.akcb-msg__ticks {
    display: inline-flex;
    font-size: 0.8rem;
    line-height: 1;
    color: #8696a0;
}

.akcb-msg__ticks.akcb-read {
    color: #53bdeb;
}

/* ---------- Typing indicator ---------- */
.akcb-typing {
    align-self: flex-start;
    width: fit-content;
    max-width: 78%;
    flex-shrink: 0;
    background: #ffffff;
    border-radius: 0 0.5rem 0.5rem 0.5rem;
    padding: 0.8rem 0.9rem;
    box-shadow: 0 1px 1px rgba(11, 20, 26, 0.12);
    display: none;
    align-items: center;
    gap: 0.28rem;
}

#ak-chatbot.akcb-waiting .akcb-typing {
    display: inline-flex;
}

.akcb-typing span {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #8696a0;
    animation: akcb-typing 1.2s infinite;
}

.akcb-typing span:nth-child(2) { animation-delay: 0.15s; }
.akcb-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes akcb-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ---------- Error bar ---------- */
.akcb-error {
    display: none;
    background: #fdecea;
    color: #b3261e;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.5rem 0.9rem;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    border-top: 1px solid #f5c6c2;
}

#ak-chatbot.akcb-error-visible .akcb-error {
    display: flex;
    animation: akcb-msg-in 0.22s ease;
}

/* ---------- Input bar ---------- */
.akcb-inputbar {
    background: #f0f0f0;
    padding: 0.55rem 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-shrink: 0;
}

.akcb-input {
    flex: 1;
    border: none;
    outline: none;
    background: #ffffff;
    border-radius: 999px;
    padding: 0.7rem 1rem;
    font-size: 0.92rem;
    color: #111b21;
    min-width: 0;
}

.akcb-input::placeholder {
    color: #8696a0;
}

.akcb-input:disabled {
    background: #f5f5f5;
    color: #8696a0;
}

.akcb-input.akcb-shake {
    animation: akcb-shake 0.35s ease;
}

@keyframes akcb-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.akcb-send {
    width: 3rem;
    height: 3rem;
    border: none;
    border-radius: 50%;
    background: #00a884;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
    padding: 0;
}

.akcb-send:hover:not(:disabled) {
    background: #06cf9c;
    transform: scale(1.05);
}

.akcb-send:disabled {
    background: #8696a0;
    cursor: not-allowed;
    transform: none;
}

.akcb-send svg {
    width: 1.35rem;
    height: 1.35rem;
}

.akcb-send__spinner {
    display: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: akcb-spin 0.7s linear infinite;
}

@keyframes akcb-spin {
    to { transform: rotate(360deg); }
}

#ak-chatbot.akcb-waiting .akcb-send__spinner {
    display: block;
}

#ak-chatbot.akcb-waiting .akcb-send__icon {
    display: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    #ak-chatbot {
        right: 1rem;
        bottom: 1rem;
    }

    .akcb-panel {
        position: fixed;
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 92dvh;
        max-height: 92dvh;
        border-radius: 1.25rem 1.25rem 0 0;
        transform-origin: bottom center;
    }
}

@media (prefers-reduced-motion: reduce) {
    #ak-chatbot *,
    #ak-chatbot *::before,
    #ak-chatbot *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
