/* ==========================================================================
   WP AI Live Chat Widget Styles
   ========================================================================== */

#wp-aichat-root {
    position: fixed;
    z-index: 9999999; /* Sit safely above Elementor headers and sliders */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Default: Bottom Right */
#wp-aichat-root.pos-bottom-right {
    bottom: 24px;
    right: 24px;
    left: auto;
}
#wp-aichat-root.pos-bottom-right #wp-aichat-window {
    right: 0;
    left: auto;
}

/* Alternative: Bottom Left (If Tawk.to or WhatsApp already on bottom right) */
#wp-aichat-root.pos-bottom-left {
    bottom: 24px;
    left: 24px;
    right: auto;
}
#wp-aichat-root.pos-bottom-left #wp-aichat-window {
    left: 0;
    right: auto;
}

/* Strict Isolation: Reset all theme-inherited typography, margins, and borders */
#wp-aichat-root,
#wp-aichat-root * {
    box-sizing: border-box !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

#wp-aichat-root button {
    border: none !important;
    background: none;
    box-shadow: none !important;
    text-shadow: none !important;
    padding: 0;
    margin: 0;
    font-size: 14px;
    cursor: pointer;
}

#wp-aichat-root input {
    margin: 0 !important;
    box-shadow: none !important;
    font-family: inherit !important;
}

/* Floating Launcher Bubble */
#wp-aichat-bubble {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    border: 3px solid #ffffff !important;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(30, 58, 138, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s ease;
    padding: 0;
    outline: none;
    overflow: hidden;
    position: relative;
}

#wp-aichat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(30, 58, 138, 0.5);
}

.bubble-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

#wp-aichat-bubble.is-open .bubble-avatar-img {
    display: none;
}

#wp-aichat-bubble .bubble-icon-close {
    display: none;
    width: 28px;
    height: 28px;
    color: #ffffff;
}

#wp-aichat-bubble.is-open .bubble-icon-close {
    display: block;
}

/* Chat Window Container */
#wp-aichat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 385px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 12px 35px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
    border: 1px solid #cbd5e1;
}

#wp-aichat-window.aichat-hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

/* Header */
.aichat-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.aichat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aichat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.aichat-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.aichat-header-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
}

.aichat-header-status {
    font-size: 0.75rem;
    color: #e0f2fe;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.status-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
}

.aichat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.aichat-header-actions button {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.aichat-header-actions button:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.aichat-header-actions svg {
    width: 18px;
    height: 18px;
}

/* Body / Messages List */
.aichat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.aichat-body::-webkit-scrollbar {
    width: 5px;
}

.aichat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Chat Bubbles */
.aichat-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: aichatFadeIn 0.2s ease forwards;
}

@keyframes aichatFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.aichat-msg-user {
    align-self: flex-end;
}

.aichat-msg-user .aichat-msg-bubble {
    background: #1e40af;
    color: #ffffff;
    border-radius: 14px 14px 2px 14px;
    padding: 10px 14px;
    font-size: 0.9rem;
    word-break: break-word;
    box-shadow: 0 1px 3px rgba(30, 64, 175, 0.25);
}

.aichat-msg-bot {
    align-self: flex-start;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 8px;
    max-width: 88%;
}

.aichat-mini-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1.5px solid #ffffff;
}

.aichat-msg-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.aichat-msg-bot .aichat-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border-radius: 14px 14px 14px 2px;
    padding: 11px 14px;
    font-size: 0.9rem;
    word-break: break-word;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.aichat-msg-bubble p {
    margin: 0 0 8px 0;
}

.aichat-msg-bubble p:last-child {
    margin-bottom: 0;
}

.aichat-msg-bubble ul, .aichat-msg-bubble ol {
    margin: 4px 0 8px 18px;
    padding: 0;
}

.aichat-msg-bubble strong {
    font-weight: 600;
}

.aichat-msg-time {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 4px;
}

.aichat-msg-user .aichat-msg-time {
    text-align: right;
}

/* Typing Indicator */
.aichat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: #f8fafc;
}

.aichat-typing.aichat-hidden {
    display: none;
}

.aichat-typing span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: aichatBounce 1.4s infinite ease-in-out both;
}

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

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

/* Footer & Input */
.aichat-footer {
    padding: 10px 14px 8px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
}

#wp-aichat-form {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 24px;
    padding: 4px 6px 4px 14px;
    border: 1px solid #e2e8f0;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#wp-aichat-form:focus-within {
    border-color: #0284c7;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

#wp-aichat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 4px;
    font-size: 0.9rem;
    color: #1e293b;
    outline: none;
}

#wp-aichat-input::placeholder {
    color: #94a3b8;
}

#wp-aichat-send {
    background: #0284c7;
    color: #ffffff;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    outline: none;
    flex-shrink: 0;
}

#wp-aichat-send:hover {
    background: #0369a1;
    transform: scale(1.05);
}

#wp-aichat-send svg {
    width: 16px;
    height: 16px;
    margin-left: 2px;
}

.aichat-disclaimer {
    font-size: 0.72rem;
    color: #94a3b8;
    text-align: center;
    margin-top: 6px;
}

.aichat-disclaimer a {
    color: #16a34a;
    font-weight: 600;
    text-decoration: none;
}

.aichat-disclaimer a:hover {
    text-decoration: underline;
}

/* Indeks Kepuasan Masyarakat (IKM) Feedback Box */
.aichat-ikm-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.76rem;
    color: #64748b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 8px;
    width: fit-content;
}

.aichat-ikm-text {
    font-size: 0.74rem;
    color: #475569;
}

.aichat-ikm-btns {
    display: inline-flex;
    gap: 4px;
}

.aichat-rate-btn {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 4px !important;
    padding: 2px 6px !important;
    font-size: 0.72rem !important;
    color: #334155 !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.aichat-rate-btn:hover {
    background: #eff6ff !important;
    border-color: #3b82f6 !important;
    color: #1d4ed8 !important;
    transform: scale(1.05);
}

.aichat-rate-done {
    color: #16a34a;
    font-weight: 600;
    font-size: 0.74rem;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #wp-aichat-root {
        bottom: 16px;
        right: 16px;
    }
    #wp-aichat-window {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
}
