/* Message Header with Actions */
.msg-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 4px 8px 0 0;
    position: relative;
}

/* Actions menu container */
.msg-actions-menu {
    position: relative;
    display: flex;
    align-items: center;
}

/* Three-dots menu button - Exactly like ChatGPT */
.msg-menu-btn {
    @apply w-6 h-6 flex items-center justify-center rounded text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-700 dark:hover:text-gray-200 transition-colors duration-150;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    font-size: 12px;
}

/* Show menu button on message hover */
.msg-assistant:hover .msg-menu-btn {
    opacity: 1;
}

/* When menu is open, keep button visible */
.msg-actions-menu.menu-open .msg-menu-btn {
    opacity: 1;
    @apply bg-gray-100 dark:bg-gray-700;
}

/* ChatGPT Exact Style Context Menu */
.msg-assistant .msg-context-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1000;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    min-width: 160px;
    padding: 8px 0;
    font-size: 14px;
    /* HIDDEN BY DEFAULT */
    visibility: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.1s ease-out;
    pointer-events: none;
    /* CRITICAL: Proper layout container */
    display: flex;
    flex-direction: column;
}

/* Dark theme for context menu - ChatGPT style */
.dark .msg-assistant .msg-context-menu {
    background: #343541;
    border-color: #565869;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

/* Show context menu */
.msg-assistant .msg-context-menu.show {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ChatGPT Exact Style Menu Items with PROPER HORIZONTAL LAYOUT */
.context-menu-item {
    @apply w-full text-sm font-normal text-gray-700 dark:text-gray-200 cursor-pointer border-0 bg-transparent;
    /* CRITICAL: Proper flexbox layout for horizontal alignment */
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    line-height: 1.4;
    gap: 12px;
    min-height: 40px;
    padding: 12px 16px;
    transition: background-color 0.15s ease-in-out;
    /* CRITICAL: Remove default button styling */
    outline: none;
    box-shadow: none;
    margin: 0;
    /* CRITICAL: Prevent text wrapping */
    white-space: nowrap;
    flex-wrap: nowrap;
}

/* PROPER HOVER EFFECT - ChatGPT Style */
.context-menu-item:hover {
    @apply bg-gray-100 dark:bg-gray-600 text-gray-900 dark:text-gray-100;
    /* CRITICAL: Smooth transition on hover */
    background-color: #f3f4f6 !important;
}

.dark .context-menu-item:hover {
    background-color: #4b5563 !important;
}

/* PROPER FOCUS STATES */
.context-menu-item:focus {
    @apply bg-gray-100 dark:bg-gray-600 outline-none;
    background-color: #f3f4f6 !important;
}

.dark .context-menu-item:focus {
    background-color: #4b5563 !important;
}

/* SVG Icons with proper sizing and flex properties */
.context-menu-item svg {
    @apply w-4 h-4 text-gray-500 dark:text-gray-400;
    flex-shrink: 0;
    flex-grow: 0;
    display: block;
    /* CRITICAL: Ensure icon stays in place */
    min-width: 16px;
    min-height: 16px;
}

.context-menu-item:hover svg {
    @apply text-gray-700 dark:text-gray-200;
}

/* Three-dots button SVG */
.msg-menu-btn svg {
    @apply w-4 h-4;
}

/* REMOVE CONFLICTING STYLES - Keep icons consistent */
.context-menu-item[data-action="copy"] svg,
.context-menu-item[data-action="export-pdf"] svg,
.context-menu-item[data-action="export-docx"] svg {
    @apply text-gray-500 dark:text-gray-400;
}

.context-menu-item:hover[data-action="copy"] svg,
.context-menu-item:hover[data-action="export-pdf"] svg,
.context-menu-item:hover[data-action="export-docx"] svg {
    @apply text-gray-700 dark:text-gray-200;
}

/* PROPER TEXT STYLING - Ensure text stays inline */
.context-menu-item span {
    @apply text-sm font-normal;
    color: inherit;
    line-height: 1.4;
    /* CRITICAL: Text flex properties */
    flex-grow: 1;
    flex-shrink: 1;
    display: inline-block;
    vertical-align: middle;
}

/* ChatGPT-style separator between menu sections */
.context-menu-separator {
    height: 1px;
    background-color: #e5e7eb;
    margin: 8px 0;
    flex-shrink: 0;
}

.dark .context-menu-separator {
    background-color: #4b5563;
}

/* REMOVE BROWSER DEFAULT BUTTON STYLING */
.context-menu-item::-moz-focus-inner {
    border: 0;
    padding: 0;
}

/* ACTIVE STATE */
.context-menu-item:active {
    @apply bg-gray-200 dark:bg-gray-500;
    transform: none;
}

/* ENSURE PROPER SPACING BETWEEN ITEMS */
.context-menu-item + .context-menu-item {
    border-top: none;
    margin-top: 0;
}

/* MENU CONTAINER IMPROVEMENTS */
.msg-context-menu {
    overflow: hidden;
    border-radius: 8px;
}

/* ENSURE PROPER STACKING */
.context-menu-item {
    position: relative;
    z-index: 1;
}

/* SweetAlert2 Toast Customization */
.swal2-toast-container {
    position: fixed !important;
    top: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 10000 !important;
}

.swal2-toast .swal2-title {
    font-size: 14px !important;
    font-weight: 500 !important;
    margin: 0 !important;
}

.swal2-toast .swal2-icon {
    margin: 0 8px 0 0 !important;
    width: 20px !important;
    height: 20px !important;
}

/* Dark mode support for SweetAlert2 */
.dark .swal2-toast {
    background-color: #374151 !important;
    color: #f3f4f6 !important;
    border: 1px solid #4b5563 !important;
}

.dark .swal2-toast .swal2-title {
    color: #f3f4f6 !important;
}

/* Professional Attachment Tags */
.msg-attachments {
    @apply mt-3 space-y-2;
    margin-bottom: 4px;
}

.attachment-tag {
    @apply block text-xs;
}

.attachment-link {
    @apply inline-flex items-center text-xs font-medium border transition-all duration-200 cursor-pointer;
    /* Professional styling with subtle background difference */
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    text-decoration: none;
    min-width: 200px;
    max-width: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    /* Custom padding and border radius */
    padding: 2px 7px;
    gap: 12px;
    border-radius: 4px;
}

.attachment-link:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Dark theme support */
.dark .attachment-link {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.dark .attachment-link:hover {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.attachment-no-link {
    @apply cursor-default opacity-70;
}

.attachment-no-link:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.attachment-icon {
    @apply w-5 h-5 flex-shrink-0;
    color: rgba(255, 255, 255, 0.8);
}

.attachment-name {
    @apply truncate flex-1 font-medium text-xs;
    color: inherit;
    font-size: .75rem;
}

/* Download indicator */
.attachment-link::after {
    content: '↗';
    @apply ml-auto text-xs opacity-60;
    font-weight: bold;
}

/* User Message Copy Button - Theme Aware */
.msg-action-btn-user {
    @apply w-6 h-6 flex items-center justify-center rounded text-white/70 hover:bg-white/10 hover:text-white transition-colors duration-150;
    /* Dark theme support */
    @apply dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-200;
    border: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    font-size: 12px;
}

/* Show copy button on message hover */
.msg-user:hover .msg-action-btn-user {
    opacity: 1;
}