/* Text Selection Context Styles */

/* Selection Popup - styled like "Ask ChatGPT" with original white appearance */
.text-selection-popup {
    position: fixed;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.95); /* White background like original */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 25px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 4px;
    transition: all 0.2s ease;
    pointer-events: auto;
    user-select: none;
}

.text-selection-popup.hidden {
    display: none;
}

/* Remove the blue gradient effect */
.text-selection-popup::before {
    display: none;
}

.selection-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a; /* Dark text on white background */
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.selection-action-btn:hover {
    background: rgba(0, 0, 0, 0.05); /* Light grey on hover */
    color: #1a1a1a;
}

.selection-action-btn:active {
    background: rgba(0, 0, 0, 0.1);
    transform: translateY(1px);
}

.selection-action-btn i {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

/* Context Container - Simple and clean */
.context-container {
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    margin-bottom: 20px;
    padding: 16px 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.context-container.hidden {
    display: none;
}

.context-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.context-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.clear-all-context-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-all-context-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.7);
}

.clear-all-context-btn i {
    width: 12px;
    height: 12px;
    stroke: currentColor;
}

.context-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.context-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.context-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.context-item-content {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
    color: rgba(0, 0, 0, 0.6); /* Light grey for context text */
    font-style: normal; /* Remove italic styling */
    font-weight: 400; /* Normal weight */
    margin-right: 8px;
}

.remove-context-btn {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 0, 0, 0.4); /* Light grey X button */
    transition: all 0.2s ease;
    opacity: 0.7;
}

.remove-context-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.7); /* Darker grey on hover */
    opacity: 1;
}

.remove-context-btn i {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2;
}

/* Expandable functionality */
.context-container.collapsed .context-items {
    display: none;
}

.context-container.collapsed .context-header {
    margin-bottom: 0;
}

.context-toggle {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(0, 0, 0, 0.6);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.context-toggle:hover {
    color: rgba(0, 0, 0, 0.8);
}

.context-toggle i {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    transition: transform 0.2s ease;
}

.context-container.collapsed .context-toggle i {
    transform: rotate(-90deg);
}

/* Ensure no background containers interfere */
.context-container * {
    background: transparent !important;
}

.context-container .context-item {
    background: rgba(255, 255, 255, 0.05) !important;
}

.context-container .context-item:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

/* Animation for context container appearance */
.context-container {
    animation: contextSlideIn 0.3s ease-out;
}

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

/* Ensure popup doesn't interfere with text selection */
.text-selection-popup {
    pointer-events: auto;
}

.text-selection-popup * {
    pointer-events: auto;
}

/* Prevent popup from being selected */
.text-selection-popup {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .text-selection-popup {
        border-radius: 20px;
        padding: 2px;
    }
    
    .selection-action-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .context-container {
        margin: 0 16px 16px 16px;
        padding: 12px;
    }
    
    .context-item {
        padding: 8px;
    }
}

/* Ensure proper z-index layering */
.text-selection-popup {
    z-index: 10000;
}

.context-container {
    z-index: 100;
}

/* Make sure the popup appears above chat messages */
.message-content {
    position: relative;
    z-index: 1;
}

/* Highlight selected text while popup is visible */
.text-selection-highlight {
    background: rgba(0, 120, 255, 0.2);
    border-radius: 2px;
}

/* Ensure context container appears in chat mode without background interference */
.chat-popup .context-container {
    position: relative;
    margin: 0 auto 20px auto;
    max-width: 800px;
    width: 100%;
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    z-index: 10;
}

/* Position context container properly in chat layout - no background containers */
.chat-container .context-container {
    order: -1; /* Place before chat log */
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
}

/* Remove any potential background containers */
.context-container::before,
.context-container::after {
    display: none !important;
}

/* Ensure no parent containers add background */
.chat-container,
.chat-popup {
    background: none !important;
}

.chat-container > *:not(.context-container):not(.chat-log) {
    background: none !important;
}

/* Make sure context container doesn't inherit unwanted backgrounds */
.context-container {
    isolation: isolate;
    z-index: 100;
}

/* Alternative Design 1: Chip-based minimal approach */
.context-container.chip-style {
    background: transparent;
    border: none;
    padding: 8px 0;
    margin-bottom: 16px;
    box-shadow: none;
    border-left: none;
}

.context-container.chip-style .context-header {
    margin-bottom: 8px;
}

.context-container.chip-style .context-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-direction: row;
}

.context-container.chip-style .context-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 20px;
    border-left: none;
    transform: none;
    transition: all 0.2s ease;
    flex: none;
    width: auto;
}

.context-container.chip-style .context-item:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

.context-container.chip-style .context-text {
    font-style: normal;
    font-size: 13px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.context-container.chip-style .remove-context-btn {
    width: 16px;
    height: 16px;
    opacity: 0.7;
    margin-left: 4px;
}

/* Alternative Design 2: Inline tag style */
.context-container.inline-style {
    background: rgba(249, 250, 251, 0.8);
    border: 1px solid rgba(229, 231, 235, 0.8);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-left: none;
    box-shadow: none;
}

.context-container.inline-style .context-header {
    display: inline-flex;
    align-items: center;
    margin-bottom: 0;
    margin-right: 12px;
}

.context-container.inline-style .context-title {
    font-size: 12px;
    margin-right: 8px;
}

.context-container.inline-style .context-items {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.context-container.inline-style .context-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(229, 231, 235, 1);
    border-radius: 6px;
    border-left: none;
    transform: none;
    margin: 0;
}

.context-container.inline-style .context-text {
    font-style: normal;
    font-size: 12px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #4b5563;
}

/* Alternative Design 3: Notion-style clean blocks */
.context-container.notion-style {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(229, 231, 235, 0.6);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    border-left: 2px solid #f59e0b;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.context-container.notion-style .context-title {
    color: #f59e0b;
    font-size: 12px;
    font-weight: 600;
}

.context-container.notion-style .context-item {
    background: transparent;
    border: none;
    border-left: 1px solid rgba(229, 231, 235, 0.5);
    border-radius: 0;
    padding: 8px 12px;
    margin-left: 8px;
    transform: none;
}

.context-container.notion-style .context-item:hover {
    background: rgba(249, 250, 251, 0.8);
    border-left-color: #f59e0b;
    transform: none;
}

.context-container.notion-style .context-text {
    font-style: normal;
    color: #374151;
    font-size: 13px;
}

/* Alternative Design 4: Slack-style message attachment */
.context-container.slack-style {
    background: rgba(248, 250, 252, 0.9);
    border: none;
    border-left: 4px solid #10b981;
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
    margin-bottom: 16px;
    box-shadow: none;
}

.context-container.slack-style .context-header {
    margin-bottom: 8px;
}

.context-container.slack-style .context-title {
    color: #10b981;
    font-size: 12px;
    font-weight: 700;
}

.context-container.slack-style .context-item {
    background: transparent;
    border: none;
    border-left: none;
    padding: 4px 0;
    border-radius: 0;
    transform: none;
}

.context-container.slack-style .context-item:hover {
    background: rgba(16, 185, 129, 0.05);
    border-left: none;
    transform: none;
}

.context-container.slack-style .context-text {
    font-style: normal;
    color: #374151;
    font-size: 13px;
    line-height: 1.4;
} 