/* Messages Page Layout */
.message-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Message Thread List */
.message-thread {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.message-thread-item {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message-thread-item:last-child {
    border-bottom: none;
}

.message-thread-item:hover {
    background-color: #f9f9f9;
}

.message-thread-item.unread {
    background-color: #f0f7ff;
    border-left: 3px solid #0066cc;
}

.message-thread-item .message-preview {
    flex: 1;
    margin-right: 15px;
    overflow: hidden;
}

.message-thread-item .message-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 100px;
}

/* Message View */
.message-view {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-bottom: 20px;
}

.message-header {
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.message-content {
    line-height: 1.6;
    white-space: pre-line;
}

.message-reply {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* New Message Form */
.new-message-form {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

/* Sidebar (scoped to messages pages) */
.message-sidebar .card {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}

.message-sidebar .bg-gradient-primary {
    background: linear-gradient(135deg, #ff0000 0%, #cc0000 100%) !important;
}

.message-sidebar .list-group-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.message-sidebar .list-group-item i {
    color: #ff0000;
    min-width: 18px;
}

.message-sidebar .list-group-item:hover {
    background: #f8f9fc;
    border-left-color: #ff0000;
}

.message-sidebar .list-group-item.active {
    background: #fff0f0;
    font-weight: 600;
    border-left-color: #ff0000;
}

.message-sidebar .badge {
    margin-left: auto;
}

@media (max-width: 768px) {
    .message-sidebar { margin-bottom: 1rem; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .message-container {
        padding: 10px;
    }
    
    .message-thread-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .message-thread-item .message-meta {
        margin-top: 10px;
        align-items: flex-start;
        width: 100%;
    }
    
    .nav-icons {
        gap: 1rem !important;
    }
    
    .user-menu {
        margin-left: auto;
    }
}

/* Badge Styles */
.badge {
    display: inline-block;
    padding: 0.25em 0.6em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.25rem;
}

.badge-danger {
    color: #fff;
    background-color: #dc3545;
}

/* Animation for new messages */
@keyframes highlight {
    from { background-color: #e3f2fd; }
    to { background-color: transparent; }
}

.new-message {
    animation: highlight 2s ease-out;
}

/* Mobile optimization for very small screens (≈360x740) */
@media (max-width: 400px) {
  .message-container { padding: 8px; }

  .message-thread-item { padding: 12px 14px; }
  .message-thread-item .message-meta { min-width: unset; }

  .message-view { padding: 12px; }
  .message-content { overflow-wrap: anywhere; }

  .message-reply {
    margin-top: 20px;
    padding-top: 16px;
  }

  .message-reply textarea,
  .message-reply input,
  .message-reply .btn {
    width: 100%;
  }
}
