/* Chatbot Floating Widget Styles */
:root {
    --cb-primary: #b20606;
    --cb-secondary: #f1c40f;
    --cb-bg: rgba(15, 15, 15, 0.95);
    --cb-text: #ffffff;
    --cb-glass: rgba(255, 255, 255, 0.05);
}

/* Chat Container (Transformed to Centered Popup) */
#cb-widget-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 450px;
    height: 80vh;
    max-height: 650px;
    background: var(--cb-bg);
    backdrop-filter: blur(25px);
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 200000;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.9);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
}

#cb-widget-container.active {
    display: flex;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Overlay for Chat Popup */
#cb-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    z-index: 199999;
}

#cb-overlay.active {
    display: block;
}

/* Removed Floating Button Styles */

/* Header */
.cb-header {
    padding: 20px;
    background: linear-gradient(90deg, rgba(178, 6, 6, 0.1), transparent);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.cb-avatar {
    width: 40px;
    height: 40px;
    background: var(--cb-primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(178, 6, 6, 0.3);
}

.cb-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
}

.cb-status {
    font-size: 0.75rem;
    color: #2ecc71;
    display: flex;
    align-items: center;
    gap: 5px;
}

.cb-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
}

.cb-close {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.5rem;
    padding: 5px;
    transition: 0.2s;
}

.cb-close:hover { color: white; }

/* Messages Area */
.cb-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scrollbar-width: thin;
    scrollbar-color: var(--cb-primary) transparent;
}

.cb-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
}

.cb-message.ai {
    background: var(--cb-glass);
    color: #eee;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255,255,255,0.05);
}

.cb-message.user {
    background: var(--cb-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(178, 6, 6, 0.2);
}

.cb-time {
    font-size: 0.7rem;
    opacity: 0.5;
    margin-top: 5px;
    display: block;
}

/* Typing Indicator */
.cb-typing {
    padding: 12px 16px;
    background: var(--cb-glass);
    border-radius: 18px;
    align-self: flex-start;
    display: none;
}

.cb-typing span {
    width: 6px;
    height: 6px;
    background: #888;
    border-radius: 50%;
    display: inline-block;
    animation: cb-bounce 1s infinite ease-in-out;
}

.cb-typing span:nth-child(2) { animation-delay: 0.2s; }
.cb-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cb-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* Input Area */
.cb-input-area {
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.cb-input-wrapper {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 5px 10px 5px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: 0.3s;
}

.cb-input-wrapper:focus-within {
    border-color: var(--cb-primary);
    background: rgba(255, 255, 255, 0.08);
}

#cb-input {
    flex: 1;
    background: none;
    border: none;
    color: white;
    padding: 10px 0;
    font-size: 0.95rem;
    outline: none;
}

#cb-input::placeholder { color: #666; }

.cb-actions {
    display: flex;
    gap: 8px;
}

.cb-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 10px;
    transition: 0.2s;
}

.cb-btn:hover { background: rgba(255, 255, 255, 0.1); }

.cb-btn-send {
    color: var(--cb-primary);
    font-size: 1.2rem;
}

.cb-btn-mic { color: #888; }
.cb-btn-mic.active { color: var(--cb-primary); animation: cb-pulse 1.5s infinite; }

@keyframes cb-pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* Quick Action Cards in Chat */
.cb-quick-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 12px;
    margin-top: 20px;
    width: 100%;
}

.cb-pronunciation-panel {
    flex: 0 0 100%;
    order: 10;
    box-sizing: border-box;
}

/* Hybrid Choice Buttons */
.cb-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    width: 100%;
}

.cb-choice-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #eee;
    padding: 12px 15px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.88rem;
    transition: 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: cb-slide-up 0.3s ease forwards;
}

.cb-choice-btn:hover {
    background: rgba(178, 6, 6, 0.25);
    border-color: var(--cb-primary);
    color: white;
    transform: translateX(5px);
}

@keyframes cb-slide-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.cb-card {
    flex: 1;
    max-width: 160px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 18px 10px;
    border-radius: 16px;
    cursor: pointer;
    transition: 0.3s;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.cb-card:hover {
    background: rgba(178, 6, 6, 0.15);
    border-color: var(--cb-primary);
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.cb-card-icon {
    font-size: 2rem;
}

.cb-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #eee;
    text-align: center;
}

/* Modal Popup */
.cb-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    display: none;
    align-items: center; 
    justify-content: center;
    z-index: 200000;
    padding: 60px 20px 20px; /* Tambahkan 60px dari atas agar tidak terlalu nangkring */
}

.cb-modal.active {
    display: flex;
    animation: cb-fade-in 0.3s ease;
}

.cb-modal-content {
    background: #151515;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    width: 100%;
    max-width: 450px;
    padding: 30px;
    position: relative;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.5);
}

.cb-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
}

.cb-modal-header {
    margin-bottom: 20px;
    text-align: center;
}

.cb-modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
}

.cb-modal-body {
    color: #aaa;
    line-height: 1.6;
    font-size: 1rem;
}

@keyframes cb-fade-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* MOBILE RESPONSIVENESS */
@media (max-width: 768px) {
    .cb-modal {
        align-items: flex-start;
        padding: 68px 12px 12px;
    }

    .cb-modal-content {
        width: 100%;
        max-width: 100% !important;
        height: calc(100dvh - 92px) !important;
        max-height: 680px;
        border-radius: 18px !important;
    }

    .cb-header {
        padding: 14px !important;
    }

    .cb-avatar {
        width: 42px !important;
        height: 42px !important;
    }

    .cb-messages {
        padding: 14px !important;
        gap: 12px !important;
    }

    .cb-message {
        max-width: 90% !important;
        font-size: 0.9rem !important;
        line-height: 1.45 !important;
    }

    .cb-input-area {
        padding: 12px !important;
    }

    .cb-input-wrapper {
        border-radius: 12px !important;
        padding: 4px 10px !important;
    }

    .cb-quick-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        margin-top: 10px;
    }

    .cb-card {
        max-width: none;
        min-width: 0;
        padding: 8px 4px;
        border-radius: 10px;
        gap: 4px;
    }

    .cb-card:hover {
        transform: none;
    }

    .cb-card-icon {
        font-size: 1.25rem;
        line-height: 1;
    }

    .cb-card-title {
        font-size: 0.68rem;
        line-height: 1.15;
    }

    #cb-widget-container {
        right: 15px;
        bottom: 90px;
        width: calc(100% - 30px);
        height: 60vh;
        max-height: 500px;
    }
    
    #cb-widget-toggle {
        width: 55px;
        height: 55px;
        bottom: 20px;
        right: 20px;
    }
}
