/* Custom styles for the SMS application */

.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.card-header {
    background-color: var(--bs-gray-900);
    border-bottom: 1px solid var(--bs-border-color);
}

.navbar-brand {
    font-weight: 600;
}

.alert-container {
    max-height: 300px;
    overflow-y: auto;
}

.table {
    font-size: 0.9rem;
}

.progress {
    background-color: var(--bs-gray-800);
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* File input styling */
.form-control[type="file"] {
    padding: 0.5rem;
}

/* Character counter styling */
#charCount {
    font-weight: 500;
}

/* Progress text styling */
#progressText {
    font-weight: 600;
    font-size: 0.875rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .display-4 {
        font-size: 2rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table-responsive {
        font-size: 0.8rem;
    }
}

/* Animation for success states */
.alert-success {
    animation: slideInDown 0.3s ease-in-out;
}

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

/* Error list styling */
#errorList {
    max-height: 200px;
    overflow-y: auto;
}

#errorList li {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

/* ========================================
   MEDIA UPLOAD STYLES
   ======================================== */

/* Media Upload Zone */
.media-upload-zone {
    border: 2px dashed var(--bs-border-color);
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    background: var(--bs-body-bg);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-upload-zone:hover {
    border-color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), 0.05);
}

.media-upload-zone.drag-over {
    border-color: var(--bs-success);
    background: rgba(var(--bs-success-rgb), 0.1);
    border-style: solid;
}

.dropzone-content {
    pointer-events: none;
}

.dropzone-content .btn-link {
    pointer-events: all;
    font-weight: 500;
}

/* Media Preview Area */
.media-preview-area {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    background: var(--bs-gray-50);
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}

/* Preview Items */
.preview-item {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    background: var(--bs-white);
    overflow: hidden;
    transition: all 0.2s ease;
}

.preview-item:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

/* Preview Content */
.preview-content {
    position: relative;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bs-gray-100);
    overflow: hidden;
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.file-preview {
    background: var(--bs-gray-200);
}

.file-preview i {
    color: var(--bs-gray-600);
}

/* Preview Overlay */
.preview-overlay {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.preview-remove {
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 0.875rem;
}

.preview-remove:hover {
    background: var(--bs-danger);
    border-color: var(--bs-danger);
}

/* Preview Info */
.preview-info {
    padding: 0.75rem 0.5rem;
    border-top: 1px solid var(--bs-border-color);
    background: var(--bs-white);
}

.preview-name {
    display: block;
    font-weight: 500;
    color: var(--bs-dark);
    line-height: 1.3;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-info .text-muted {
    font-size: 0.75rem;
    line-height: 1.2;
}

/* File Counter Badge */
#fileCount {
    font-weight: 600;
    color: var(--bs-primary);
}

/* Clear All Button */
.media-preview-area .btn-outline-danger {
    font-size: 0.875rem;
    padding: 0.25rem 0.75rem;
}

/* Media Upload Alerts */
.media-upload-zone + .alert {
    margin-top: 1rem;
    border-radius: 0.375rem;
}

/* Drag and Drop Visual Feedback */
.media-upload-zone::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    pointer-events: none;
    transition: all 0.3s ease;
}

.media-upload-zone.drag-over::after {
    background: linear-gradient(45deg, 
        rgba(var(--bs-success-rgb), 0.1) 25%, 
        transparent 25%, 
        transparent 50%, 
        rgba(var(--bs-success-rgb), 0.1) 50%, 
        rgba(var(--bs-success-rgb), 0.1) 75%, 
        transparent 75%, 
        transparent);
    background-size: 20px 20px;
    animation: move 0.5s linear infinite;
}

@keyframes move {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 20px 20px;
    }
}

/* Media Upload Icon Animation */
.media-upload-zone:hover .fa-cloud-upload-alt {
    transform: translateY(-2px);
    color: var(--bs-primary);
}

.media-upload-zone .fa-cloud-upload-alt {
    transition: all 0.3s ease;
}

/* Enhanced Modal for Media Preview */
.modal-lg .card {
    margin-bottom: 0;
}

.modal-body .card + .card {
    margin-top: 1rem;
}

.modal-body ul {
    max-height: 150px;
    overflow-y: auto;
}

/* Loading States */
.preview-item.loading .preview-content {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .media-upload-zone {
        padding: 1.5rem 1rem;
        min-height: 100px;
    }
    
    .media-upload-zone .fa-cloud-upload-alt {
        font-size: 1.5rem;
    }
    
    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.75rem;
    }
    
    .preview-content {
        height: 80px;
    }
    
    .preview-info {
        padding: 0.5rem 0.4rem;
    }
    
    .preview-name {
        font-size: 0.8rem;
    }
    
    .preview-info .text-muted {
        font-size: 0.7rem;
    }
}

@media (max-width: 576px) {
    .media-upload-zone {
        padding: 1rem;
    }
    
    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.5rem;
    }
    
    .preview-content {
        height: 70px;
    }
    
    .media-preview-area {
        padding: 0.75rem;
    }
    
    .media-preview-area h6 {
        font-size: 0.9rem;
    }
}

/* Dark mode specific adjustments */
@media (prefers-color-scheme: dark) {
    .media-preview-area {
        background: var(--bs-gray-800);
    }
    
    .preview-item {
        background: var(--bs-gray-700);
        border-color: var(--bs-gray-600);
    }
    
    .preview-content {
        background: var(--bs-gray-600);
    }
    
    .file-preview {
        background: var(--bs-gray-650);
    }
    
    .preview-info {
        background: var(--bs-gray-700);
        border-color: var(--bs-gray-600);
    }
    
    .preview-name {
        color: var(--bs-light);
    }
}

/* Animation for successful file upload */
.preview-item.upload-success {
    animation: successPulse 0.6s ease-in-out;
}

@keyframes successPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(var(--bs-success-rgb), 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(var(--bs-success-rgb), 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(var(--bs-success-rgb), 0);
    }
}

/* ========================================
   MMS CONVERSATION MEDIA DISPLAY STYLES
   ======================================== */

/* Message media container */
.message-media {
    max-width: 100%;
    margin-bottom: 0.5rem;
}

/* Image display styles */
.media-image-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.media-image {
    max-width: 100%;
    height: auto;
    max-height: 300px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: block;
}

.media-image:hover {
    transform: scale(1.02);
}

.media-overlay {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.media-image-container:hover .media-overlay {
    opacity: 1;
}

/* Video display styles */
.media-video-container {
    max-width: 100%;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.media-video {
    width: 100%;
    max-height: 300px;
    display: block;
}

/* Audio display styles */
.media-audio-container {
    background: rgba(var(--bs-gray-200-rgb), 0.1);
    border: 1px solid rgba(var(--bs-border-color-rgb), 0.3);
    border-radius: 0.5rem;
    padding: 0.75rem;
    min-width: 250px;
}

.media-audio-player audio {
    height: 32px;
}

/* File display styles */
.media-file-container {
    border-radius: 0.5rem;
    overflow: hidden;
}

.media-file-container .border {
    border-color: rgba(var(--bs-border-color-rgb), 0.3) !important;
    background: rgba(var(--bs-gray-200-rgb), 0.1);
}

/* Media filename styles */
.media-filename {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--bs-body-color);
}

/* Media error display */
.media-error {
    background: rgba(var(--bs-danger-rgb), 0.1);
    border-color: rgba(var(--bs-danger-rgb), 0.3);
    color: var(--bs-danger);
}

/* Conversation list media indicators */
.last-message-preview {
    display: block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0.25rem;
}

/* Media badges in conversation list */
.badge.bg-info {
    background-color: rgba(var(--bs-info-rgb), 0.8) !important;
    font-size: 0.7rem;
    padding: 0.25em 0.5em;
}

/* Image modal enhancements */
#imageModal .modal-body {
    background: var(--bs-dark);
    padding: 0;
}

#imageModal .modal-body img {
    max-height: 80vh;
    width: auto;
    max-width: 100%;
}

/* Dark theme adjustments for conversation media */
@media (prefers-color-scheme: dark) {
    .media-audio-container {
        background: rgba(var(--bs-gray-700-rgb), 0.3);
        border-color: rgba(var(--bs-gray-600-rgb), 0.5);
    }
    
    .media-file-container .border {
        background: rgba(var(--bs-gray-700-rgb), 0.3);
        border-color: rgba(var(--bs-gray-600-rgb), 0.5);
    }
}

/* Mobile responsiveness for conversation media */
@media (max-width: 768px) {
    .media-image {
        max-height: 200px;
    }
    
    .media-video {
        max-height: 200px;
    }
    
    .media-audio-container {
        min-width: 200px;
        padding: 0.5rem;
    }
    
    .last-message-preview {
        max-width: 150px;
    }
    
    .message-bubble {
        max-width: 85% !important;
    }
}

@media (max-width: 576px) {
    .media-image {
        max-height: 150px;
    }
    
    .media-video {
        max-height: 150px;
    }
    
    .media-audio-container {
        min-width: 180px;
        font-size: 0.8rem;
    }
    
    .last-message-preview {
        max-width: 120px;
        font-size: 0.75rem;
    }
    
    .message-bubble {
        max-width: 95% !important;
    }
}
