/* ====================================
   MESSAGES PAGE STYLES
   ==================================== */

.messages-page {
    padding-bottom: 0;
}

/* Messages Layout */
.messages-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 0;
    background: var(--white);
    border: 1px solid var(--grey-lighter);
    border-radius: var(--radius-xl);
    overflow: hidden;
    height: calc(100vh - 220px);
    min-height: 600px;
}

/* ====================================
   SIDEBAR - CONVERSATIONS LIST
   ==================================== */

.messages-sidebar {
    background: var(--grey-lightest);
    border-right: 1px solid var(--grey-lighter);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--grey-lighter);
    background: var(--white);
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--grey-dark);
    margin: 0 0 1rem;
}

.btn-compose {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-compose:hover {
    background: var(--primary-blue-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 133, 216, 0.3);
}

/* Sidebar Search */
.sidebar-search {
    padding: 1rem 1.5rem;
    background: var(--white);
    border-bottom: 1px solid var(--grey-lighter);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-search svg {
    color: var(--grey-medium);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    color: var(--grey-dark);
    font-family: 'Inter', sans-serif;
}

.search-input:focus {
    outline: none;
}

.search-input::placeholder {
    color: var(--grey-light);
}

/* Conversation List */
.conversation-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.conversation-list::-webkit-scrollbar {
    width: 6px;
}

.conversation-list::-webkit-scrollbar-thumb {
    background: var(--grey-lighter);
    border-radius: 3px;
}

.conversation-list::-webkit-scrollbar-thumb:hover {
    background: var(--grey-light);
}

/* Conversation Item */
.conversation-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--grey-lighter);
    position: relative;
}

.conversation-item:hover {
    background: var(--white);
}

.conversation-item.active {
    background: var(--white);
    border-left: 3px solid var(--primary-blue);
}

.conversation-item.unread {
    background: rgba(13, 133, 216, 0.03);
}

.conversation-avatar {
    position: relative;
    flex-shrink: 0;
}

.conversation-avatar .avatar-text {
    width: 48px;
    height: 48px;
    background: var(--primary-blue);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.95rem;
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--success-green);
    border: 2px solid var(--white);
    border-radius: 50%;
}

.online-indicator.away {
    background: var(--warning-orange);
}

.online-indicator.offline {
    background: var(--grey-light);
}

.conversation-content {
    flex: 1;
    min-width: 0;
    position: relative;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.conversation-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--grey-dark);
    margin: 0;
}

.conversation-item.unread .conversation-name {
    font-weight: 700;
}

.conversation-time {
    font-size: 0.8rem;
    color: var(--grey-medium);
}

.conversation-preview {
    font-size: 0.9rem;
    color: var(--grey-medium);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-item.unread .conversation-preview {
    color: var(--grey-dark);
    font-weight: 500;
}

.unread-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--primary-blue);
    color: var(--white);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* ====================================
   MAIN CHAT AREA
   ==================================== */

.messages-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--white);
    animation: slideInRight 0.3s ease-out;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--grey-lighter);
    background: var(--white);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-avatar {
    position: relative;
}

.chat-avatar .avatar-text {
    width: 48px;
    height: 48px;
    background: var(--primary-blue);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.95rem;
}

.chat-header-text h2.chat-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--grey-dark);
    margin: 0 0 0.25rem;
}

.chat-status {
    font-size: 0.85rem;
    color: var(--grey-medium);
    margin: 0;
}

.chat-header-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-action-btn {
    background: transparent;
    border: none;
    color: var(--grey-medium);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-action-btn:hover {
    background: var(--grey-lightest);
    color: var(--primary-blue);
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    background: var(--grey-lightest);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--grey-lighter);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--grey-light);
}

/* Date Divider */
.date-divider {
    text-align: center;
    margin: 1rem 0;
}

.date-divider span {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--white);
    color: var(--grey-medium);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 20px;
    border: 1px solid var(--grey-lighter);
}

/* Message */
.message {
    display: flex;
    gap: 0.75rem;
    max-width: 70%;
    animation: messageSlide 0.3s ease-out;
}

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

.message.received {
    align-self: flex-start;
}

.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar .avatar-text {
    width: 36px;
    height: 36px;
    background: var(--primary-blue);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message.sent .message-content {
    align-items: flex-end;
}

.message-bubble {
    background: var(--white);
    padding: 0.875rem 1.125rem;
    border-radius: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.message.sent .message-bubble {
    background: var(--primary-blue);
    color: var(--white);
}

.message-bubble p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--grey-dark);
}

.message.sent .message-bubble p {
    color: var(--white);
}

.message-time {
    font-size: 0.8rem;
    color: var(--grey-medium);
    padding: 0 0.5rem;
}

/* Message Attachment */
.message-attachment {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--grey-lightest);
    border-radius: var(--radius-md);
    margin-top: 0.75rem;
}

.message.sent .message-attachment {
    background: rgba(255, 255, 255, 0.15);
}

.message-attachment svg {
    color: var(--primary-blue);
    flex-shrink: 0;
}

.message.sent .message-attachment svg {
    color: var(--white);
}

.attachment-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.attachment-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--grey-dark);
}

.message.sent .attachment-name {
    color: var(--white);
}

.attachment-size {
    font-size: 0.8rem;
    color: var(--grey-medium);
}

.message.sent .attachment-size {
    color: rgba(255, 255, 255, 0.8);
}

.attachment-download {
    background: var(--white);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--primary-blue);
}

.attachment-download:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    max-width: 70%;
}

.typing-avatar .avatar-text {
    width: 36px;
    height: 36px;
    background: var(--primary-blue);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.typing-dots {
    background: var(--white);
    padding: 1rem 1.25rem;
    border-radius: 16px;
    display: flex;
    gap: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--grey-light);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* ====================================
   MESSAGE INPUT
   ==================================== */

.message-input-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--grey-lighter);
    background: var(--white);
}

.input-action-btn {
    background: transparent;
    border: none;
    color: var(--grey-medium);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-action-btn:hover {
    background: var(--grey-lightest);
    color: var(--primary-blue);
}

.message-input {
    flex: 1;
    border: 2px solid var(--grey-lighter);
    background: var(--grey-lightest);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--grey-dark);
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
}

.message-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    background: var(--white);
}

.message-input::placeholder {
    color: var(--grey-light);
}

.btn-send {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-send:hover {
    background: var(--primary-blue-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 133, 216, 0.3);
}

.btn-send:active {
    transform: translateY(0);
}

/* ====================================
   RESPONSIVE DESIGN
   ==================================== */

@media (max-width: 1200px) {
    .messages-layout {
        grid-template-columns: 320px 1fr;
    }
    
    .message {
        max-width: 80%;
    }
}

@media (max-width: 968px) {
    .messages-layout {
        grid-template-columns: 280px 1fr;
        height: calc(100vh - 200px);
    }
    
    .sidebar-header {
        padding: 1.25rem;
    }
    
    .conversation-item {
        padding: 1rem;
    }
    
    .message {
        max-width: 85%;
    }
}

@media (max-width: 768px) {
    .messages-layout {
        grid-template-columns: 1fr;
        position: relative;
    }
    
    .messages-sidebar {
        display: flex;
    }
    
    .messages-main {
        display: none;
    }
    
    /* When conversation is active, hide sidebar and show main */
    .messages-layout.conversation-open .messages-sidebar {
        display: none;
    }
    
    .messages-layout.conversation-open .messages-main {
        display: flex;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-header-actions .chat-action-btn:first-child {
        display: none;
    }
    
    .message-input-container {
        padding: 1rem;
    }
    
    .btn-send {
        padding: 0.75rem 1.25rem;
    }
}

@media (max-width: 480px) {
    .messages-layout {
        height: calc(100vh - 180px);
        min-height: 500px;
    }
    
    .sidebar-header h2 {
        font-size: 1.25rem;
    }
    
    .btn-compose {
        font-size: 0.9rem;
        padding: 0.65rem 1.25rem;
    }
    
    .conversation-item {
        padding: 0.875rem 1rem;
    }
    
    .conversation-avatar .avatar-text {
        width: 42px;
        height: 42px;
        font-size: 0.9rem;
    }
    
    .chat-header {
        padding: 1rem;
    }
    
    .chat-header-text h2.chat-name {
        font-size: 1rem;
    }
    
    .chat-status {
        font-size: 0.8rem;
    }
    
    .messages-container {
        padding: 1rem;
    }
    
    .message-bubble {
        padding: 0.75rem 1rem;
    }
    
    .message-bubble p {
        font-size: 0.9rem;
    }
    
    .message-input-container {
        gap: 0.5rem;
    }
    
    .input-action-btn {
        padding: 0.375rem;
    }
    
    .message-input {
        font-size: 0.9rem;
        padding: 0.65rem 0.875rem;
    }
    
    .btn-send {
        padding: 0.65rem 1rem;
        font-size: 0.9rem;
    }
    
    .btn-send svg {
        display: none;
    }
}

/* ====================================
   ANIMATIONS
   ==================================== */

/* Messages main animation - combined with main definition */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

