/* Custom styles for SMS Manager - Performance Optimized */

:root {
    --sms-inbound-color: #0d6efd;
    --sms-outbound-color: #198754;
    --delivery-sent-color: #6c757d;
    --delivery-delivered-color: #198754;
    --delivery-failed-color: #dc3545;
}

/* Dark theme optimization - simplified selectors */
body.bg-dark {
    background-color: #212529;
    color: #ffffff;
}

body.bg-dark .card {
    background-color: #2c3e50;
    border-color: #495057;
    color: #ffffff;
}

body.bg-dark .form-control {
    background-color: #343a40;
    border-color: #495057;
    color: #ffffff;
}

body.bg-dark .form-control:focus {
    background-color: #343a40;
    border-color: #0d6efd;
    color: #ffffff;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Message interface - consolidated */
.conversation-item {
    cursor: pointer;
    border-left: 4px solid transparent;
    padding: 12px 16px;
    transition: background-color 0.2s ease;
}

.conversation-item:hover {
    background-color: rgba(13, 110, 253, 0.1);
}

.conversation-item.active {
    background-color: rgba(13, 110, 253, 0.15);
    border-left-color: var(--sms-inbound-color);
}

/* Message bubbles - iOS style optimized */
.message-bubble {
    border-radius: 20px;
    padding: 10px 14px;
    margin: 2px 0;
    display: inline-block;
    max-width: 70%;
    word-wrap: break-word;
    font-size: 15px;
    line-height: 1.35;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
}

.message-bubble.outbound {
    background-color: #007AFF;
    color: white;
    margin-left: auto;
}

.message-bubble.inbound {
    background-color: #E9ECEF;
    color: #000000;
}

/* User initials for outbound messages */
.message-bubble.outbound .user-initials {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Quick reply form */
#quickReplyForm .form-control {
    border-radius: 20px;
    padding: 12px 16px;
}

#quickReplyForm .btn {
    border-radius: 50%;
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Delivery status indicators */
.delivery-status {
    font-size: 11px;
    margin-top: 2px;
    font-weight: 500;
    text-align: right;
    opacity: 0.8;
    user-select: none;
}

.delivery-status.sent { color: var(--delivery-sent-color); }
.delivery-status.delivered { color: var(--delivery-delivered-color); }
.delivery-status.failed { color: var(--delivery-failed-color); }

/* Image preview */
#imagePreview {
    animation: fadeIn 0.2s ease-in-out;
}

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

/* Container layout */
#messagesContainer {
    min-height: 400px;
    background: var(--bs-body-bg);
}

/* Desktop viewport height constraints - safe approach without breaking layout */
@media (min-width: 769px) {
    /* Message container should have reasonable max height to prevent infinite scroll */
    #messageContainer {
        max-height: 60vh; /* Use viewport height instead of fixed pixels */
        overflow-y: auto;
    }
    
    /* Conversation list should also have reasonable height */
    .col-lg-4 .card-body {
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .message-bubble {
        max-width: 85%;
        font-size: 14px;
    }
    
    .conversation-item {
        padding: 10px 12px;
    }
    
    #messagesContainer {
        min-height: 300px;
    }
}

@media (max-width: 992px) {
    .card.h-100 {
        height: auto;
        min-height: 400px;
    }
}

/* Utility classes - minimal set */
.preview-text {
    font-size: 0.85rem;
    line-height: 1.2;
}

.message-text {
    line-height: 1.35;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Badge colors */
.badge.bg-success {
    background-color: var(--sms-outbound-color);
}

.badge.bg-info {
    background-color: var(--sms-inbound-color);
}

/* Scrollbar styling */
.card-body::-webkit-scrollbar {
    width: 6px;
}

.card-body::-webkit-scrollbar-track {
    background: var(--bs-secondary-bg);
}

.card-body::-webkit-scrollbar-thumb {
    background: var(--bs-border-color);
    border-radius: 3px;
}
/* Active users styling */
#activeUsersContainer {
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

#activeUsersContainer:hover {
    opacity: 1;
}

#activeUsers .badge {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

#activeUsers .badge:hover {
    transform: scale(1.1);
}
