/* --- Global Variables from PHP --- */
:root {
    --asb-btn-bg-color: #FFFFFF;
    --asb-btn-text-color: #333333;
    --asb-offset-desktop: 20px;
    --asb-fontsize-desktop: 16px;
    --asb-offset-mobile: 15px;
    --asb-fontsize-mobile: 14px;
}

/* --- Main Container --- */
#ai-summary-container {
    position: fixed;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --- Main Trigger Button --- */
#ai-summary-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--asb-btn-bg-color);
    color: var(--asb-btn-text-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 999px;
    padding: 10px 16px;
    font-size: var(--asb-fontsize-desktop);
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s cubic-bezier(0.25, 0.1, 0.25, 1), box-shadow 0.2s ease;
}
#ai-summary-trigger:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}
.ai-summary-icon {
    font-size: 1.2em;
    display: flex;
    align-items: center;
}

/* --- Panel --- */
#ai-summary-panel {
    width: 90px;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    /* Visibility & Animation */
    position: absolute;
    bottom: calc(100% + 10px); /* Panel always appears above the button */
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
    visibility: hidden;
    pointer-events: none;
}


/* Desktop Positioning */
#ai-summary-container {
    bottom: var(--asb-offset-desktop);
}
#ai-summary-container[data-position="right"] {
    right: var(--asb-offset-desktop);
    left: auto;
}
#ai-summary-container[data-position="left"] {
    left: var(--asb-offset-desktop);
    right: auto;
}

/* Align panel with the button based on position */
#ai-summary-container[data-position="right"] #ai-summary-panel {
    right: 0;
    left: auto;
}
#ai-summary-container[data-position="left"] #ai-summary-panel {
    left: 0;
    right: auto;
}
/* --- END: Simplified Positioning Logic --- */


/* Active State */
#ai-summary-container.active #ai-summary-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
    pointer-events: auto;
}

/* --- Panel Internals --- */
.ai-summary-panel-header {
    font-size: 10px;
    font-weight: 600;
    color: #666;
    padding-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    overflow-wrap: break-word; /* Fallback */
    word-wrap: break-word; /* Legacy fallback */
    -webkit-hyphens: auto; /* For Safari/Chrome */
    -ms-hyphens: auto; /* For IE/Edge */
    hyphens: auto; /* Standard */
}
.ai-summary-panel-header.asb-mobile-header {
    display: none;
}

.ai-summary-bot-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 5px;
    border-radius: 8px;
    text-decoration: none;
    color: #222;
    transition: background-color 0.15s ease;
}
.ai-summary-bot-button:hover { background-color: rgba(0, 0, 0, 0.05); }

.asb-bot-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}
.asb-bot-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 5px;
}
.asb-bot-name {
    font-size: 12px;
    text-align: center;
    line-height: 1.2;
    overflow-wrap: break-word; /* Fallback */
    word-wrap: break-word; /* Legacy fallback */
    -webkit-hyphens: auto; /* For Safari/Chrome */
    -ms-hyphens: auto; /* For IE/Edge */
    hyphens: auto; /* Standard */
}


/* --- Mobile Styles --- */
@media (max-width: 768px) {
    /* Apply mobile offsets */
    #ai-summary-container {
        bottom: var(--asb-offset-mobile);
    }
    #ai-summary-container[data-position="right"] {
        right: var(--asb-offset-mobile);
    }
    #ai-summary-container[data-position="left"] {
        left: var(--asb-offset-mobile);
    }

    /* Apply mobile font size and padding */
    #ai-summary-trigger {
        font-size: var(--asb-fontsize-mobile);
        padding: 8px 14px;
    }
    
    /* Hide button text on mobile */
    .ai-summary-text { 
        display: none; 
    }

    /* Swap panel headers on mobile */
    .ai-summary-panel-header.asb-desktop-header {
        display: none;
    }
    .ai-summary-panel-header.asb-mobile-header {
        display: block;
    }
}