#media-attachments-bar {
    position: fixed;
    bottom: 16px;
    right: 16px;
    display: grid;
    gap: 8px;
    z-index: 9999;
    width: min(360px, calc(100vw - 24px));
    pointer-events: none;
}

#attach-media-fab {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    display: none;
    border-radius: 50%;
    border: none;
    background: #1976d2;
    color: #fff;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
    cursor: pointer;
}

#attach-media-fab:hover {
    background: #145ca8;
}

@media (max-width: 768px) {
    #media-attachments-bar {
        bottom: 72px;
        right: 12px;
    }
    #attach-media-fab {
        bottom: 16px;
        right: 12px;
    }
}

.media-attachment-thumb {
    width: 100%;
    min-height: 82px;
    border-radius: 14px;
    position: relative;
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr) 28px;
    gap: 10px;
    align-items: center;
    padding: 10px;
    box-sizing: border-box;
    background: rgba(15,23,42,0.96);
    color: #fff;
    box-shadow: 0 16px 38px rgba(15,23,42,0.3);
    backdrop-filter: blur(12px);
    pointer-events: auto;
    animation: mediaTaskIn 0.2s ease-out;
}

.media-attachment-preview {
    width: 54px;
    height: 54px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #1e293b;
    color: #93c5fd;
}

.media-attachment-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-attachment-info {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.media-attachment-info strong,
.media-attachment-status,
.media-attachment-detail {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-attachment-info strong { font-size: 13px; }
.media-attachment-status { font-size: 12px; color: #bfdbfe; }
.media-attachment-detail { font-size: 10px; color: #94a3b8; }

.media-attachment-progress {
    height: 3px;
    margin-top: 3px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,0.14);
}

.media-attachment-progress i {
    display: block;
    width: 2%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg,#38bdf8,#d946ef);
    transition: width 0.18s ease;
}

.media-attachment-thumb .spinner {
    display: none;
}

.media-attachment-thumb .spinner::after {
    content: "";
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0,0,0,0.2);
    border-top-color: #4285f4;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.media-attachment-thumb .close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #cbd5e1;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.media-attachment-thumb.ready .close-btn {
    background: rgba(34,197,94,0.18);
}

.media-attachment-thumb .ready-check {
    display: none;
}

@keyframes mediaTaskIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Image preview modal overlay */
#media-preview-modal {
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Chat media attachments */
.chat-media-attachment {
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-media-attachment:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15) !important;
}

.chat-media-attachment img,
.chat-media-attachment video {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.chat-media-attachment img:hover,
.chat-media-attachment video:hover {
    opacity: 0.95;
}

/* Loading indicator for media upload */
#media-loading-indicator {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, -40%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

/* Modal close button hover effect */
#media-preview-close:hover {
    background: #ff6666 !important;
    transform: scale(1.1);
    transition: all 0.2s ease;
}

/* Caption textarea focus effect */
#media-caption-input:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.1);
}

/* Attach button pulse animation when new */
#attach-media {
    position: relative;
}

#attach-media.has-new-feature::after {
    content: '';
    position: absolute;
    top: -5px;
    right: -5px;
    width: 10px;
    height: 10px;
    background: #ff4444;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0);
    }
}

/* Image in chat log styling */
.chat-log .chat-media-attachment {
    max-width: 100%;
    margin: 10px 0;
}

.chat-log__item--own .chat-media-attachment {
    margin-left: auto;
    margin-right: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #media-preview-modal > div {
        max-width: 95% !important;
        margin: 20px auto !important;
        padding: 15px !important;
    }
    
    .chat-media-attachment img,
    .chat-media-attachment video {
        max-width: 200px !important;
        max-height: 150px !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    #media-preview-modal > div {
        background: #2a2a2a;
        color: #fff;
    }
    
    #media-caption-input {
        background: #1a1a1a;
        border-color: #444;
        color: #fff;
    }
    
    .chat-media-attachment {
        background: #333 !important;
    }
    
    .chat-media-attachment > div {
        background: #444 !important;
        color: #ccc !important;
    }
}

/* Drag and drop overlay */
.media-drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(66, 133, 244, 0.1);
    border: 3px dashed #4285f4;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: none;
}

.media-drop-overlay.active {
    display: flex;
}

.media-drop-overlay-text {
    font-size: 24px;
    color: #4285f4;
    font-weight: bold;
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
