/* ============================================
   MEDIA & FILE SHARING STYLES
   ============================================ */

/* Media Gallery */
.media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 12px;
    margin-bottom: 12px;
    padding: 12px;
    background: rgba(52, 152, 219, 0.05);
    border-radius: 8px;
    border: 2px dashed rgba(52, 152, 219, 0.2);
}

/* Gallery Item */
.gallery-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    aspect-ratio: 1;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
}

.file-placeholder {
    width: 100%;
    height: 80%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    font-size: 40px;
}

.file-name {
    padding: 8px;
    font-size: 11px;
    color: #2c3e50;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* Gallery Overlay */
.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.gallery-overlay button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.gallery-overlay button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    background: #ecf0f1;
}

/* Media Preview */
.media-preview {
    position: relative;
    display: inline-block;
    width: 150px;
    height: 150px;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid #ecf0f1;
    margin: 8px;
}

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

.media-thumbnail {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
}

.media-icon {
    font-size: 40px;
}

.preview-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.8) 100%);
    color: white;
    padding: 12px 8px;
    text-align: center;
}

.preview-name {
    font-size: 12px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 4px;
}

.preview-size {
    font-size: 10px;
    opacity: 0.8;
}

.preview-info {
    padding: 12px;
}

/* Paste Preview */
.paste-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px;
    background: rgba(46, 204, 113, 0.1);
    border-radius: 8px;
    border: 1px dashed #2ecc71;
}

.paste-preview .media-preview {
    margin: 0;
}

/* Upload Area */
.upload-area {
    position: relative;
    border: 3px dashed #3498db;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.05) 0%, rgba(155, 89, 182, 0.05) 100%);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #3498db;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.1) 0%, rgba(155, 89, 182, 0.1) 100%);
}

.upload-area.drag-over {
    border-color: #2ecc71;
    background: rgba(46, 204, 113, 0.1);
    transform: scale(1.02);
}

.upload-area-content {
    pointer-events: none;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.upload-text {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 8px;
}

.upload-hint {
    color: #7f8c8d;
    font-size: 13px;
}

/* Audio Recorder */
.audio-recorder {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 12px;
}

.recorder-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.recorder-button.record {
    background: #e74c3c;
    color: white;
}

.recorder-button.record:hover {
    background: #c0392b;
    transform: scale(1.05);
}

.recorder-button.stop {
    background: #2ecc71;
    color: white;
}

.recorder-button.stop:hover {
    background: #27ae60;
    transform: scale(1.05);
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.recording-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e74c3c;
    animation: recording-pulse 1s infinite;
}

@keyframes recording-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

.recording-time {
    font-weight: 600;
    color: #2c3e50;
    font-family: 'Courier New', monospace;
    min-width: 40px;
}

/* Voice Message */
.voice-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
    margin: 8px 0;
}

.voice-play-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid white;
    color: white;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.voice-play-button:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.voice-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.voice-duration {
    font-size: 13px;
    font-weight: 600;
}

.voice-waveform {
    display: flex;
    align-items: center;
    gap: 3px;
    margin: 0 12px;
    flex: 1;
}

.waveform-bar {
    width: 2px;
    background: white;
    border-radius: 1px;
    animation: waveform 0.5s ease-in-out infinite;
}

.waveform-bar:nth-child(1) { height: 4px; animation-delay: 0.1s; }
.waveform-bar:nth-child(2) { height: 8px; animation-delay: 0.2s; }
.waveform-bar:nth-child(3) { height: 12px; animation-delay: 0.3s; }
.waveform-bar:nth-child(4) { height: 8px; animation-delay: 0.4s; }
.waveform-bar:nth-child(5) { height: 10px; animation-delay: 0.5s; }

@keyframes waveform {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 1;
    }
}

/* File Input Styling */
input[type="file"] {
    display: none;
}

/* Media Loading */
.media-loading {
    position: relative;
    width: 150px;
    height: 150px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Dark Mode Support */
body.dark-mode .media-gallery {
    background: rgba(52, 152, 219, 0.1);
    border-color: rgba(52, 152, 219, 0.3);
}

body.dark-mode .gallery-item {
    background: #34495e;
}

body.dark-mode .media-preview {
    background: #34495e;
    border-color: #52687a;
}

body.dark-mode .audio-recorder {
    background: #34495e;
}

body.dark-mode .file-name {
    color: #ecf0f1;
}

body.dark-mode .upload-area {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.1) 0%, rgba(155, 89, 182, 0.1) 100%);
    border-color: rgba(52, 152, 219, 0.3);
}

body.dark-mode .upload-area:hover {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.15) 0%, rgba(155, 89, 182, 0.15) 100%);
}

body.dark-mode .upload-text {
    color: #ecf0f1;
}

body.dark-mode .upload-hint {
    color: #95a5a6;
}

body.dark-mode .paste-preview {
    background: rgba(46, 204, 113, 0.15);
    border-color: rgba(46, 204, 113, 0.3);
}

body.dark-mode .recording-time {
    color: #ecf0f1;
}

body.dark-mode .media-loading {
    background: linear-gradient(90deg, #34495e 25%, #52687a 50%, #34495e 75%);
}

/* Responsive Design */
@media (max-width: 768px) {
    .media-gallery {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
        padding: 8px;
    }

    .media-preview {
        width: 120px;
        height: 120px;
    }

    .audio-recorder {
        flex-direction: column;
    }

    .recording-indicator {
        width: 100%;
        justify-content: space-between;
    }

    .voice-message {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .media-gallery {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 6px;
    }

    .media-preview {
        width: 90px;
        height: 90px;
        margin: 0;
    }

    .gallery-overlay button {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .voice-message {
        padding: 8px;
        gap: 8px;
    }

    .voice-play-button {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .waveform-bar {
        width: 1px;
    }
}
