/**
 * Sphinx AI Assistant Styles
 *
 * Styles for the AI assistant dropdown and UI elements.
 * Designed to work well with Furo theme and be theme-agnostic where possible.
 */

/* Container */
.ai-assistant-container {
    position: relative;
    /* padding-left: var(--toc-spacing-horizontal); */
    z-index: 10;
    margin-top: 0.7rem;
}

.ai-assistant-container img {
    margin-top: 5px;
    margin-bottom: 5px;
}

/* Button container */
.ai-assistant-button {
    position: relative;
    display: inline-flex;
    align-items: stretch;
    height: 35px;
    background-color: transparent;
    border: 1px solid var(--color-foreground-border, rgba(0, 0, 0, 0.2));
    border-radius: 4px;
    overflow: hidden;
}

.ai-assistant-button-main,
.ai-assistant-button-dropdown {
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    color: var(--color-foreground-primary, #1a1a1a);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.ai-assistant-button-main {
    gap: 0.5rem;
    padding: 0 0.75rem;
}

.ai-assistant-button-dropdown {
    padding: 0 0.5rem;
}

.ai-assistant-button-divider {
    width: 1px;
    background-color: var(--color-foreground-border, rgba(0, 0, 0, 0.2));
    align-self: stretch;
}

.ai-assistant-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    flex-shrink: 0;
}

.ai-assistant-dropdown-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    flex-shrink: 0;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.ai-assistant-button-main:hover,
.ai-assistant-button-dropdown:hover {
    background-color: var(--color-background-hover, rgba(0, 0, 0, 0.05));
}

.ai-assistant-button-main:active,
.ai-assistant-button-dropdown:active {
    background-color: var(--color-background-active, rgba(0, 0, 0, 0.1));
}

/* Success state for inline confirmation */
.ai-assistant-button-main.ai-assistant-button-success {
    background-color: rgba(76, 175, 80, 0.1);
}

/* Only show focus outline when using keyboard navigation */
.ai-assistant-button-main:focus,
.ai-assistant-button-dropdown:focus {
    outline: none;
}

.ai-assistant-button-main:focus-visible,
.ai-assistant-button-dropdown:focus-visible {
    outline: 2px solid var(--color-brand-primary, #2980b9);
    outline-offset: -2px;
}

.ai-assistant-button-dropdown[aria-expanded="true"] .ai-assistant-dropdown-icon {
    transform: rotate(180deg);
}

/* Dropdown */
.ai-assistant-dropdown {
    position: absolute;
    top: calc(100% + 0.2rem);
    left: auto;
    right: auto;
    width: 215px;
    background-color: var(--color-background-primary, #fff);
    border: 1px solid var(--color-foreground-border, #e1e4e5);
    border-radius: 4px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 0.25rem;
    z-index: 10000;
    /* Ensure visibility */
    pointer-events: auto;
}

.ai-assistant-dropdown[style*="display: block"] {
    display: block !important;
}

/* Menu items */
.ai-assistant-menu-item {
    display: block;
    width: 100%;
    min-height: 55px;
    /* padding: 0.75rem 1rem; */
    text-align: left;
    background: none;
    border: none;
    border-radius: 4px;
    color: var(--color-foreground-primary, #1a1a1a);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.ai-assistant-menu-item-content {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.ai-assistant-menu-item-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.ai-assistant-menu-item-title .ai-assistant-menu-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    flex-shrink: 0;
}

.ai-assistant-menu-item-description {
    font-size: 11px;
    color: var(--color-foreground-secondary, #666);
    line-height: 1.3;
    padding-left: 0; /* Start directly below icon, not indented */
    margin-top: -5px;
}

.ai-assistant-menu-item:hover {
    background-color: var(--color-background-hover, #f5f5f5);
}

.ai-assistant-menu-item:focus {
    outline: none;
}

.ai-assistant-menu-item:focus-visible {
    outline: 2px solid var(--color-brand-primary, #2980b9);
    outline-offset: -2px;
}

.ai-assistant-menu-item:active {
    background-color: var(--color-background-active, #e8e8e8);
}

/* Menu separator */
.ai-assistant-menu-separator {
    height: 1px;
    margin: 0.25rem 0;
    background-color: var(--color-foreground-border, #e1e4e5);
}

/* Notification */
.ai-assistant-notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 0.75rem 1.25rem;
    background-color: var(--color-brand-primary, #2980b9);
    color: white;
    border-radius: 4px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transform: translateY(-1rem);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.ai-assistant-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.ai-assistant-notification.error {
    background-color: #e74c3c;
}

/* SVG icon styling */
.svg-icon path {
    stroke: var(--color-foreground-border, rgba(0, 0, 0, 0.2));
}

.svg-icon.filter-icon {
    position: absolute;
    left: 10px;
    z-index: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ai-assistant-container {
        margin-bottom: 0.75rem;
    }

    .ai-assistant-button {
        font-size: 0.8125rem;
    }

    .ai-assistant-button-text {
        display: none;
    }

    .ai-assistant-dropdown {
        right: 0;
        left: auto;
        min-width: 215px;
    }

    .ai-assistant-notification {
        left: 1rem;
        right: 1rem;
        text-align: center;
    }
}

/* Theme-specific adjustments for Furo */
.theme-furo .ai-assistant-container {
    margin-top: 0;
    padding: 0 1rem 1rem;
}

/* When in sidebar, left-align and fit to content */
.toc-drawer .ai-assistant-container,
.toc-sidebar .ai-assistant-container,
.sidebar-secondary .ai-assistant-container {
    display: block;
    position: relative;
    z-index: 100;
    padding-top: 1rem;  /* Add top padding for spacing */
}

.toc-drawer .ai-assistant-button,
.toc-sidebar .ai-assistant-button,
.sidebar-secondary .ai-assistant-button {
    width: fit-content; /* Fit to content instead of full width */
    margin: 0; /* Left-aligned */
}

.toc-drawer .ai-assistant-button-dropdown,
.toc-sidebar .ai-assistant-button-dropdown,
.sidebar-secondary .ai-assistant-button-dropdown {
    padding: 0 0.75rem; /* More padding on right to balance left */
}

.toc-drawer .ai-assistant-dropdown,
.toc-sidebar .ai-assistant-dropdown,
.sidebar-secondary .ai-assistant-dropdown {
    left: 0;
    right: auto;
    min-width: 215px;
}

/* Also fix focus outline for menu items */
.ai-assistant-menu-item:focus {
    outline: none;
}

.ai-assistant-menu-item:focus-visible {
    outline: 2px solid var(--color-brand-primary, #2980b9);
    outline-offset: -2px;
}