/* Enhanced Attachment Menu System - DYNAMIC FIXED POSITIONING */

/* Container only needs to hold the button now */
.attachment-container {
    display: flex;
    align-items: center;
}

/* 
   Using fixed positioning with DYNAMIC JS COORDINATES
   This ensures it's never clipped and always aligned to the button.
*/
.attachment-menu {
    position: fixed;
    /* Left and Bottom are set by JS logic in script.js */
    width: 220px;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 10px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.05);

    /* Animation Initial State */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom left;
    transition:
        opacity 0.2s ease,
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        visibility 0.2s ease;
    z-index: 99999;
    /* Maximum z-index */
    display: block !important;
    pointer-events: none;
}

/* Active State */
.attachment-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Menu Items */
.attachment-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: #e0e0e0;
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 4px;
    cursor: pointer;
}

.attachment-menu a:last-child {
    margin-bottom: 0;
}

/* Hover Effects */
.attachment-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Icons */
.attachment-menu a i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-menu a:hover i {
    transform: scale(1.1);
}

/* Specific colors */
.attachment-menu a i.fa-image {
    color: #f0932b;
    text-shadow: 0 0 10px rgba(240, 147, 43, 0.3);
}

.attachment-menu a i.fa-file-alt {
    color: #4834d4;
    text-shadow: 0 0 10px rgba(72, 52, 212, 0.3);
}

.attachment-menu a i.fa-video {
    color: #eb4d4b;
    text-shadow: 0 0 10px rgba(235, 77, 75, 0.3);
}

/* Main Toggle Button */
.attachment-button {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s ease;
    z-index: 1002;
    cursor: pointer;
    position: relative;
}

.attachment-button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.attachment-button:active {
    transform: scale(0.9) rotate(90deg);
}

/* Mobile Adjustments - Can still use relative/fixed fallback if needed */
@media (max-width: 768px) {
    .attachment-menu {
        width: 180px;
        padding: 8px;
    }

    .attachment-menu a {
        padding: 10px;
        font-size: 0.9rem;
    }
}

/* --- Attachment Preview Area --- */
.attachment-previews {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    padding: 0 12px;
    margin-bottom: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: 0;
    /* Hidden by default */
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.attachment-previews.has-items {
    max-height: 120px;
    /* Expand when items exist */
    padding: 10px 12px;
}

.attachment-preview-item {
    position: relative;
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 12px;
    background: rgba(30, 30, 30, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, border-color 0.2s ease;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.attachment-preview-item:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.3);
}

@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Image Preview */
.attachment-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Document Preview */
.attachment-preview-file {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    width: 100%;
}

.attachment-preview-file i {
    font-size: 24px;
    color: #a29bfe;
}

.attachment-preview-file span {
    font-size: 9px;
    color: #dfe6e9;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
}

/* Remove Button */
.remove-attachment-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    z-index: 10;
}

.attachment-preview-item:hover .remove-attachment-btn {
    opacity: 1;
}

.remove-attachment-btn:hover {
    background: #ff4757;
}