/* ================== AI CHAT INLINE PANEL (disesuaikan style app) ================== */
.aichat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(0.2rem);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1200;
}

.aichat-overlay.active {
    opacity: 1;
    visibility: visible;
}

.aichat-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100dvh;
    height: var(--aichat-panel-height, 100dvh);
    background: #f8f9fa;
    z-index: 1201;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    font-family: 'Poppins', system-ui, sans-serif;
}

.aichat-panel.active {
    transform: translateY(0);
}

.aichat-header {
    flex-shrink: 0;
    background: linear-gradient(135deg, #3498db, #2c3e50);
    color: #fff;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.aichat-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}

.aichat-header-info {
    flex: 1;
    min-width: 0;
}

.aichat-header-info h1 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.25;
}

.aichat-status {
    font-size: 0.75rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.1rem;
}

.aichat-status-dot {
    width: 0.45rem;
    height: 0.45rem;
    background: #2ecc71;
    border-radius: 50%;
    animation: aichatPulse 2s infinite;
}

@keyframes aichatPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.45;
    }
}

.aichat-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}

.aichat-close-btn:active {
    background: rgba(255, 255, 255, 0.25);
}

.aichat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    scroll-behavior: smooth;
    background: #f8f9fa;
}

.aichat-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
}

.aichat-message.user {
    align-self: flex-end;
}

.aichat-message.ai {
    align-self: flex-start;
}

.aichat-bubble {
    padding: 0.6rem 0.9rem;
    border-radius: 0.85rem;
    font-size: 0.9rem;
    line-height: 1.45;
    word-wrap: break-word;
}

.aichat-message.user .aichat-bubble {
    background: #3498db;
    color: #fff;
    border-bottom-right-radius: 0.25rem;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.25);
}

.aichat-message.ai .aichat-bubble {
    background: #fff;
    color: #2c3e50;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 0.25rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.aichat-message-meta {
    font-size: 0.65rem;
    color: #95a5a6;
    margin-top: 0.2rem;
    padding: 0 0.35rem;
}

.aichat-message.user .aichat-message-meta {
    text-align: right;
}

.aichat-typing {
    display: none;
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 0.85rem;
    border-bottom-left-radius: 0.25rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    gap: 0.3rem;
}

.aichat-typing.active {
    display: flex;
}

.aichat-typing span {
    width: 0.4rem;
    height: 0.4rem;
    background: #95a5a6;
    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);
    }
}

.aichat-welcome {
    text-align: center;
    padding: 1.75rem 1rem;
    color: #7f8c8d;
}

.aichat-welcome-icon {
    font-size: 2.5rem;
    margin-bottom: 0.6rem;
    color: #3498db;
}

.aichat-welcome h3 {
    font-size: 1.05rem;
    color: #2c3e50;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.aichat-welcome p {
    font-size: 0.85rem;
    margin: 0;
    line-height: 1.4;
}

.aichat-suggestions {
    flex-shrink: 0;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0.55rem 0;
    background: #f8f9fa;
    position: relative;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
}

.aichat-suggestions::-webkit-scrollbar {
    display: none;
}

.aichat-suggestions.is-dragging {
    cursor: grabbing;
}

.aichat-suggestions-track {
    display: flex;
    gap: 0.5rem;
    padding: 0 0.85rem;
    width: max-content;
    animation: aichatSuggestMarquee 25s linear infinite;
    will-change: transform;
}

/* Pause marquee: hover desktop + class dari JS (touch/drag) */
.aichat-suggestions:hover .aichat-suggestions-track,
.aichat-suggestions.is-paused .aichat-suggestions-track {
    animation-play-state: paused;
}

@keyframes aichatSuggestMarquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-49.3%);
    }
}

.aichat-suggestion-chip {
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 2rem;
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: #3498db;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.aichat-suggestion-chip:hover,
.aichat-suggestion-chip:active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

.aichat-input-area {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid #e9ecef;
    padding: 0.65rem 0.75rem;
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    /* cegah keluar layar */
}

.aichat-input-wrapper {
    flex: 1 1 0;
    /* penting */
    min-width: 0;
    /* kunci agar tidak mendorong tombol keluar */
    background: #f1f3f5;
    border-radius: 1.25rem;
    padding: 0.55rem 0.9rem;
    display: flex;
    align-items: center;
    border: 1.5px solid transparent;
    transition: border-color 0.2s, background 0.2s;
    box-sizing: border-box;
}

.aichat-input-wrapper:focus-within {
    border-color: #3498db;
    background: #fff;
}

.aichat-input-area textarea {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9rem;
    resize: none;
    max-height: 6rem;
    line-height: 1.4;
    font-family: inherit;
    color: #2c3e50;
}

.aichat-send-btn {
    width: 2.6rem;
    height: 2.6rem;
    min-width: 2.6rem;
    max-width: 2.6rem;
    border-radius: 50%;
    border: none;
    background: #3498db;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.35);
    transition: background 0.2s, transform 0.15s;
}

.aichat-send-btn i {
    transform: translateX(-0.1rem);
    /* fa-paper-plane sering terlihat condong kanan */
}

.aichat-send-btn:hover {
    background: #2980b9;
}

.aichat-send-btn:active {
    transform: scale(0.94);
}

.aichat-send-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}