.asistan-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.asistan-widget[data-expanded="true"] .asistan-panel {
    position: fixed;
    right: 50%;
    bottom: 50%;
    transform: translate(50%, 50%) scale(1);
    width: min(640px, 90vw);
    height: min(80vh, 720px);
    max-height: none;
}

.asistan-widget[data-expanded="true"] .asistan-panel__body {
    height: calc(100% - 60px);
}

.asistan-widget[data-expanded="true"] .asistan-message__bubble {
    max-width: 100%;
}

@media (min-width: 641px) {
    .asistan-widget[data-expanded="true"]::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.25);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        pointer-events: none;
    }
}

.asistan-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 999px;
    background: var(--primary);
    color: var(--text-dark);
    border: none;
    box-shadow: 0 10px 30px var(--primary-shadow-dark);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.asistan-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 35px var(--primary-shadow-dark-hover);
    background: var(--primary-hover);
}

.asistan-toggle__icon {
    font-size: 20px;
    line-height: 1;
}

.asistan-panel {
    position: absolute;
    right: 0;
    bottom: 70px;
    width: 360px;
    max-height: 540px;
    background: var(--section-bg);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.95);
    transform-origin: bottom right;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.asistan-panel[data-open="true"] {
    display: flex;
    animation: asistan-fade-in 0.2s ease;
    opacity: 1;
    transform: scale(1);
}

@keyframes asistan-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.asistan-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--background-dark);
    color: var(--text-dark);
}

.asistan-panel__title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.asistan-panel__subtitle {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--text-muted-dark-alpha);
}

.asistan-panel__actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.asistan-panel__expand,
.asistan-panel__close {
    background: transparent;
    border: none;
    color: var(--text-dark);
    font-size: 18px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.asistan-panel__expand:hover,
.asistan-panel__close:hover {
    background: var(--primary-bg-hover-light);
}

.asistan-panel__body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    background: var(--section-bg-light);
    overflow: hidden;
}

.asistan-step {
    display: none;
}

.asistan-step--active {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.asistan-step__info {
    margin-bottom: 16px;
    color: var(--text-gray);
    font-size: 14px;
}

.asistan-form__group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.asistan-form__group label {
    font-size: 13px;
    color: var(--text-dark-blue);
    font-weight: 500;
}

.asistan-form__group input,
.asistan-input textarea {
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    width: 100%;
    resize: none;
    background: var(--section-bg);
    min-height: 60px;
    max-height: 180px;
    line-height: 1.5;
}

.asistan-form__group input:focus,
.asistan-input textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg-hover-light);
}

.asistan-btn {
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
}

.asistan-btn--primary {
    background: var(--primary);
    color: var(--text-dark);
    font-weight: 600;
    width: 100%;
}

.asistan-btn--ghost {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-dark-blue);
    font-weight: 500;
}

.asistan-btn--ghost:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg-hover-light);
}

.asistan-chat {
    background: var(--section-bg);
    border-radius: 12px;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.04);
    flex: 1;
    min-height: 220px;
}

.asistan-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 14px;
    line-height: 1.5;
}

.asistan-message__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-bg-hover-light);
}

.asistan-message--visitor .asistan-message__avatar {
    background: var(--primary);
    color: var(--text-dark);
}

.asistan-message__bubble {
    background: var(--section-bg-light);
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 280px;
    color: var(--text-dark-blue);
}

.asistan-message--visitor .asistan-message__bubble {
    background: var(--primary);
    color: var(--text-dark);
}

.asistan-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.asistan-input textarea {
    flex: 1;
    min-height: 60px;
}

.asistan-input__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.asistan-input__actions .asistan-btn {
    width: auto;
}

.asistan-input__actions .asistan-btn--primary {
    width: auto;
}

.asistan-handoff {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.asistan-handoff__btn {
    width: auto;
    text-decoration: none;
}

.asistan-suggestions {
    margin-bottom: 8px;
}

.asistan-suggestions__title {
    font-size: 13px;
    color: #1f2937;
    margin-bottom: 6px;
}

.asistan-suggestions__items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.asistan-suggestions__item {
    background: var(--primary-bg-hover-light);
    color: var(--primary);
    border: none;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
}

.asistan-model-info {
    font-size: 12px;
    color: var(--text-muted-light);
    margin-bottom: 8px;
}

@keyframes asistan-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.7);
        transform: scale(1);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(var(--primary-rgb), 0);
        transform: scale(1.05);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0);
        transform: scale(1);
    }
}

/* Primary color RGB definition if not already present, fallback */
:root {
    --primary-rgb: 37, 99, 235;
    /* Example blue */
}

.asistan-toggle {
    animation: asistan-pulse 2s infinite;
}

.asistan-toggle:hover {
    animation: none;
}

/* Enhancing Bubble Styles (Global) */
.asistan-message__avatar {
    background: #e2e8f0;
    /* Lighter gray for bot */
    color: #64748b;
}

.asistan-message--visitor .asistan-message__avatar {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 10px var(--primary-shadow-light);
}

.asistan-message__bubble {
    border-radius: 18px;
    padding: 12px 16px;
    font-size: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    border-bottom-left-radius: 4px;
    /* Bot style */
}

.asistan-message--visitor .asistan-message__bubble {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
    /* User style */
    box-shadow: 0 4px 12px var(--primary-shadow-light);
}

@media (max-width: 640px) {
    .asistan-panel {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        right: 0;
        bottom: 0;
        border-radius: 0;
        max-height: none;
        top: 0;
        left: 0;
        position: fixed;
    }

    .asistan-panel__body {
        height: 100%;
        /* Fill panel height */
        position: relative;
        padding-bottom: 0;
    }

    .asistan-widget {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        z-index: 99999;
    }

    .asistan-toggle {
        width: 100%;
        border-radius: 0;
        justify-content: center;
        padding: 16px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        margin: 0;
        animation: none;
    }

    @keyframes asistan-wiggle {

        0%,
        100% {
            transform: rotate(0deg);
        }

        25% {
            transform: rotate(-15deg);
        }

        75% {
            transform: rotate(15deg);
        }
    }

    .asistan-toggle__icon {
        animation: asistan-wiggle 2s infinite ease-in-out;
        display: inline-block;
    }

    .asistan-chat {
        padding-bottom: 80px;
        /* Space for fixed input */
        height: 100%;
        min-height: 0;
        box-shadow: none;
    }

    .asistan-input {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--section-bg);
        padding: 12px 16px;
        border-top: 1px solid var(--border-light);
        z-index: 10;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    }

    .asistan-input__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .asistan-input__actions .asistan-btn {
        width: 100%;
    }

    .asistan-handoff {
        justify-content: center;
    }

    .asistan-handoff__btn {
        width: 100%;
        text-align: center;
    }

    .asistan-panel__expand {
        display: none;
    }

    .asistan-message__avatar i {
        font-size: 14px;
    }
}