/* ==========================================================================
   SI-BAPER AI ASSISTANT (BAPER) - STYLESHEET
   Desain Selaras dengan Pilar Kuning/Amber Layanan Internal Capil Gitan Bersinar
   ========================================================================== */

/* 1. Floating Action Button (Launcher) */
.baper-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #9a3412 0%, #b45309 45%, #d78216 100%);
    color: #ffffff;
    border: 1.5px solid rgba(253, 230, 138, 0.55);
    border-radius: 50px;
    padding: 6px 14px 6px 8px;
    box-shadow: 0 8px 20px -3px rgba(180, 83, 9, 0.35), 0 3px 8px -2px rgba(180, 83, 9, 0.2);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
}

.baper-launcher:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 25px -4px rgba(180, 83, 9, 0.45), 0 0 16px rgba(215, 130, 22, 0.35);
    border-color: #fde68a;
}

.baper-launcher:active {
    transform: translateY(-1px) scale(0.99);
}

.baper-launcher-icon {
    position: relative;
    width: 30px;
    height: 30px;
    background: radial-gradient(circle, #f59e0b, #b45309);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.2px solid #fde68a;
    flex-shrink: 0;
}

.baper-launcher-icon svg {
    width: 17px;
    height: 17px;
    fill: #ffffff;
}

.baper-launcher-pulse {
    position: absolute;
    top: -1px;
    right: -1px;
    width: 8px;
    height: 8px;
    background-color: #f59e0b;
    border: 1.5px solid #b45309;
    border-radius: 50%;
    animation: baper-pulse-animation 2s infinite;
}

@keyframes baper-pulse-animation {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(245, 158, 11, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

.baper-launcher-text {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.15;
}

.baper-launcher-title {
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.15px;
}

.baper-launcher-desc {
    font-size: 9.5px;
    color: #e2cfa7;
    font-weight: 500;
}

/* 2. Chat Widget Window */
.baper-chat-window {
    position: fixed;
    bottom: 70px;
    right: 20px;
    z-index: 99999;
    width: 410px;
    max-width: calc(100vw - 32px);
    height: 600px;
    max-height: calc(100vh - 110px);
    background: #ffffff;
    border-radius: 20px;
    border: 1px solid rgba(215, 130, 22, 0.22);
    box-shadow: 0 20px 45px -8px rgba(180, 83, 9, 0.28), 0 8px 16px -4px rgba(180, 83, 9, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px) scale(0.96);
    transform-origin: bottom right;
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.28s;
}

.baper-chat-window.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.baper-header {
    background: linear-gradient(135deg, #9a3412 0%, #b45309 40%, #d78216 100%);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid rgba(253, 230, 138, 0.6);
    flex-shrink: 0;
}

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

.baper-avatar {
    width: 38px;
    height: 38px;
    background: radial-gradient(circle, #f59e0b, #b45309);
    border: 1.5px solid #fde68a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 800;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.baper-header-titles {
    display: flex;
    flex-direction: column;
}

.baper-header-name {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.baper-ai-badge {
    background: rgba(226, 207, 167, 0.25);
    color: #fce8bb;
    font-size: 9.5px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    border: 0.5px solid rgba(226, 207, 167, 0.5);
}

.baper-header-status {
    font-size: 11px;
    color: #dbeafe;
    display: flex;
    align-items: center;
    gap: 5px;
}

.baper-status-dot {
    width: 7px;
    height: 7px;
    background-color: #38bdf8;
    border-radius: 50%;
    display: inline-block;
}

.baper-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.baper-icon-btn {
    background: transparent;
    border: none;
    color: #dbeafe;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.baper-icon-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* Quick Suggestion Chips */
.baper-quick-pills {
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
    white-space: nowrap;
    flex-shrink: 0;
}

.baper-quick-pills::-webkit-scrollbar {
    height: 4px;
}

.baper-quick-pills::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.baper-pill {
    background: #ffffff;
    color: #b45309;
    border: 1px solid #fde68a;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.baper-pill:hover {
    background: linear-gradient(135deg, #b45309 0%, #d78216 100%);
    color: #ffffff;
    border-color: #d78216;
    transform: translateY(-1px);
}

/* Body / Chat Messages */
.baper-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #f8fafc;
    scrollbar-width: thin;
}

.baper-body::-webkit-scrollbar {
    width: 6px;
}

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

.baper-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: baper-fade-in 0.25s ease-out;
}

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

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

.baper-msg.assistant {
    align-self: flex-start;
}

.baper-bubble {
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

.baper-msg.user .baper-bubble {
    background: linear-gradient(135deg, #b45309 0%, #d78216 50%, #f59e0b 100%);
    color: #ffffff;
    border-bottom-right-radius: 3px;
    box-shadow: 0 4px 12px rgba(215, 130, 22, 0.25);
}

.baper-msg.assistant .baper-bubble {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #ede5d0;
    border-bottom-left-radius: 3px;
    box-shadow: 0 4px 12px rgba(180, 83, 9, 0.05);
}

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

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

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

.baper-bubble li {
    margin-bottom: 4px;
}

.baper-bubble blockquote {
    margin: 8px 0;
    padding: 8px 10px;
    background: #fffbeb;
    border-left: 3px solid #d78216;
    border-radius: 4px;
    font-size: 12px;
    color: #9a3412;
}

.baper-bubble code {
    background: #e2e8f0;
    padding: 2px 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11.5px;
    color: #b91c1c;
}

.baper-msg-time {
    font-size: 10px;
    color: #64748b;
    margin-top: 4px;
    align-self: flex-end;
}

.baper-msg.assistant .baper-msg-time {
    align-self: flex-start;
}

/* Suggested Action Buttons */
.baper-actions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.baper-action-btn {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
    padding: 5px 11px;
    border-radius: 8px;
    font-size: 11.5px;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
    cursor: pointer;
}

.baper-action-btn:hover {
    background: linear-gradient(135deg, #b45309 0%, #d78216 100%);
    color: #ffffff;
    border-color: #d78216;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(215, 130, 22, 0.25);
}

/* Typing Indicator */
.baper-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    width: fit-content;
    border-bottom-left-radius: 3px;
}

.baper-typing-dot {
    width: 6px;
    height: 6px;
    background: #d78216;
    border-radius: 50%;
    animation: baper-bounce 1.4s infinite ease-in-out both;
}

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

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

/* Footer / Input Area */
.baper-footer {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.baper-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.baper-input {
    flex: 1;
    resize: none;
    max-height: 90px;
    min-height: 38px;
    height: 38px;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    color: #0f172a;
    background: #f8fafc;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.baper-input:focus {
    border-color: #d78216;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(215, 130, 22, 0.15);
}

.baper-send-btn {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #b45309 0%, #d78216 50%, #f59e0b 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
}

.baper-send-btn:hover {
    background: linear-gradient(135deg, #9a3412 0%, #b45309 100%);
    transform: scale(1.04);
}

.baper-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.baper-footer-note {
    font-size: 10px;
    color: #64748b;
    text-align: center;
    margin: 0;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .baper-launcher {
        bottom: 14px;
        right: 14px;
        padding: 5px 12px 5px 7px;
        gap: 7px;
    }

    .baper-chat-window {
        bottom: 64px;
        right: 10px;
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        max-height: none;
        border-radius: 16px;
    }
}
