/**
 * StifLi Flex MCP — AI Copilot Widget Styles
 *
 * @package StifliFlexMcp
 * @since 2.3.0
 */

/* -------------------------------------------------------
 * Widget container
 * ------------------------------------------------------- */
.sflmcp-copilot-widget {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 13px;
    line-height: 1.5;
}

/* -------------------------------------------------------
 * Toggle bubble
 * ------------------------------------------------------- */
.sflmcp-copilot-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: absolute;
    bottom: 0;
    right: 0;
}

.sflmcp-copilot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.sflmcp-copilot-toggle--active {
    transform: scale(0.9);
    opacity: 0.7;
}

.sflmcp-copilot-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sflmcp-copilot-icon svg {
    width: 24px;
    height: 24px;
}

/* -------------------------------------------------------
 * Panel
 * ------------------------------------------------------- */
.sflmcp-copilot-panel {
    display: none;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 130px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    position: absolute;
    bottom: 64px;
    right: 0;
    animation: sflmcpCopilotSlideUp 0.25s ease-out;
}

.sflmcp-copilot-panel--open {
    display: flex;
}

@keyframes sflmcpCopilotSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* -------------------------------------------------------
 * Header
 * ------------------------------------------------------- */
.sflmcp-copilot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    color: #fff;
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
}

.sflmcp-copilot-header.sflmcp-dragging {
    cursor: grabbing;
}

.sflmcp-copilot-title {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* -------------------------------------------------------
 * Utility: hidden by default, shown by JS
 * ------------------------------------------------------- */
.sflmcp-hidden {
    display: none;
}

/* -------------------------------------------------------
 * WebMCP dot on toggle bubble
 * ------------------------------------------------------- */
.sflmcp-copilot-webmcp-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #2ea043;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    animation: sflmcpWebmcpPulse 2s ease-in-out infinite;
}

@keyframes sflmcpWebmcpPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46,160,67,0.5); }
    50%      { box-shadow: 0 0 0 4px rgba(46,160,67,0); }
}

/* -------------------------------------------------------
 * Source badges (API / WebMCP)
 * ------------------------------------------------------- */
.sflmcp-copilot-badges {
    display: flex;
    gap: 5px;
    align-items: center;
}

.sflmcp-copilot-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 2px 7px;
    border-radius: 9px;
    line-height: 1;
    white-space: nowrap;
    cursor: default;
}

.sflmcp-copilot-badge svg {
    flex-shrink: 0;
}

.sflmcp-copilot-badge--api {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.sflmcp-copilot-badge--webmcp {
    background: #2ea043;
    color: #fff;
}

.sflmcp-copilot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.sflmcp-copilot-close:hover {
    opacity: 1;
}

/* -------------------------------------------------------
 * Quick action chips
 * ------------------------------------------------------- */
.sflmcp-copilot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    max-height: 120px;
    overflow-y: auto;
}

.sflmcp-copilot-actions:empty {
    display: none;
}

.sflmcp-copilot-chip {
    display: inline-block;
    padding: 5px 10px;
    font-size: 12px;
    line-height: 1.3;
    border: 1px solid #dcdcde;
    border-radius: 16px;
    background: #f6f7f7;
    color: #1d2327;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.sflmcp-copilot-chip:hover {
    background: #e8f0fe;
    border-color: #2271b1;
    color: #2271b1;
}

/* -------------------------------------------------------
 * Messages area
 * ------------------------------------------------------- */
.sflmcp-copilot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sflmcp-copilot-msg {
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 90%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.sflmcp-copilot-msg code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

.sflmcp-copilot-msg-user {
    background: #2271b1;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.sflmcp-copilot-msg-assistant {
    background: #f0f0f1;
    color: #1d2327;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.sflmcp-copilot-msg-assistant em {
    color: #757575;
}

.sflmcp-copilot-msg-tool {
    background: #fef9e7;
    color: #8a6d3b;
    align-self: flex-start;
    font-size: 12px;
    border-bottom-left-radius: 4px;
}

.sflmcp-copilot-error {
    color: #d63638;
}

/* -------------------------------------------------------
 * Input area
 * ------------------------------------------------------- */
.sflmcp-copilot-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    background: #fafafa;
    flex-shrink: 0;
}

.sflmcp-copilot-input {
    flex: 1;
    resize: none;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
    min-height: 36px;
    max-height: 96px;
    outline: none;
    transition: border-color 0.15s;
}

.sflmcp-copilot-input:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.sflmcp-copilot-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #2271b1;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

.sflmcp-copilot-send:hover {
    background: #135e96;
}

.sflmcp-copilot-send:disabled {
    background: #a7aaad;
    cursor: not-allowed;
}

.sflmcp-copilot-send svg {
    width: 16px;
    height: 16px;
}

/* -------------------------------------------------------
 * Responsive (small screens)
 * ------------------------------------------------------- */
@media screen and (max-width: 600px) {
    .sflmcp-copilot-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        bottom: 60px;
        right: -8px;
    }
    .sflmcp-copilot-toggle {
        width: 44px;
        height: 44px;
    }
}
