/**
 * Message Notification Styles
 * Styles for message dropdown and floating thread popups
 */

/* Message dropdown styling */
.message-dropdown {
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 12px;
    overflow: hidden;
    z-index: 1110;
}

.notification-dropdown {
    z-index: 1110;
}

.message-dropdown .dropdown-header {
    padding: 12px 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.message-item {
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.message-item:hover {
    background-color: rgba(26, 71, 42, 0.05) !important;
}

.message-item.bg-light {
    background-color: rgba(26, 71, 42, 0.08) !important;
    border-left: 3px solid #1a472a;
}

/* Message badge pulse animation */
#message-count {
    animation: pulse 2s infinite;
}

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

/* Message Thread Popup Container */
#message-threads-container {
    position: fixed;
    bottom: 0;
    right: 20px;
    display: flex;
    flex-direction: row-reverse;
    gap: 10px;
    z-index: 1050;
    pointer-events: none;
}

/* Message Thread Popup */
.message-thread-popup {
    width: 340px;
    height: 420px;
    background: #fff;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 25px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    pointer-events: all;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0,0,0,0.1);
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Thread popup header */
.thread-header {
    background: linear-gradient(135deg, #1a472a 0%, #2d5a3f 100%);
    color: white;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.thread-header:hover {
    background: linear-gradient(135deg, #1d5230 0%, #347047 100%);
}

.thread-header .btn {
    opacity: 0.8;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.thread-header .btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Thread messages container */
.thread-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: linear-gradient(180deg, #f8f9fa 0%, #fff 100%);
}

/* Custom scrollbar for thread messages */
.thread-messages::-webkit-scrollbar {
    width: 6px;
}

.thread-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.thread-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.thread-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Message bubbles */
.message-bubble {
    max-width: 80%;
    margin-bottom: 12px;
}

.message-bubble.sent {
    margin-left: auto;
}

.message-bubble > div:first-child {
    word-wrap: break-word;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.message-bubble.sent > div:first-child {
    border-radius: 18px 18px 4px 18px;
    background: linear-gradient(135deg, #1a472a 0%, #2d5a3f 100%);
    color: #fff;
}

.message-bubble.received > div:first-child {
    border-radius: 18px 18px 18px 4px;
    background: #fff;
    color: #333;
    border: 1px solid rgba(0,0,0,0.05);
}

/* Thread input area */
.thread-input {
    padding: 12px;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.thread-input .form-control {
    border-radius: 20px;
    padding-left: 15px;
    padding-right: 15px;
    border: 1px solid rgba(0,0,0,0.1);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.thread-input .form-control:focus {
    border-color: #1a472a;
    box-shadow: 0 0 0 3px rgba(26, 71, 42, 0.1);
}

.thread-input .btn-primary {
    border-radius: 20px;
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a472a 0%, #2d5a3f 100%);
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.thread-input .btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(26, 71, 42, 0.3);
}

/* Notification animation */
.message-bell-btn.has-new {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% {
        transform: translateX(-1px);
    }
    20%, 80% {
        transform: translateX(2px);
    }
    30%, 50%, 70% {
        transform: translateX(-3px);
    }
    40%, 60% {
        transform: translateX(3px);
    }
}

/* Responsive adjustments */
@media (max-width: 576px) {
    #message-threads-container {
        right: 10px;
        left: 10px;
        flex-direction: column;
    }
    
    .message-thread-popup {
        width: 100%;
    }
}

/* Minimized thread popup */
.message-thread-popup.minimized {
    height: 44px !important;
}

.message-thread-popup.minimized .thread-messages,
.message-thread-popup.minimized .thread-input {
    display: none !important;
}

/* Loading spinner in dropdowns */
.message-dropdown .fa-spinner,
.notification-dropdown .fa-spinner {
    color: #1a472a;
}

/* Empty state styling */
.message-dropdown .text-center.py-4 i,
.notification-dropdown .text-center.py-4 i {
    color: #adb5bd;
}
