/* Unified Messaging System Styles */

:root {
    --primary-color: #00636e;
    --secondary-color: #f8f9fa;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
    --text-color: #333;
    --text-muted: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
}

/* Main Layout */
.unified-messages {
    display: flex;
    height: calc(100vh - 120px);
    background: white;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Sidebar */
.messages-sidebar {
    width: 350px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--light-bg);
}

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

.sidebar-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
}

.tab-btn:hover:not(.active) {
    background: var(--border-color);
}

.search-box {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.compose-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.compose-btn:hover {
    background: #004d57;
}

/* Conversation List */
.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-bottom: 0.25rem;
    border: 1px solid transparent;
}

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

.conversation-item.active {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 99, 110, 0.1);
}

.conversation-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
    position: relative;
}

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

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-preview {
    font-size: 0.875rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.conversation-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.unread-badge {
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Conversation Detail */
.conversation-detail {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.conversation-detail-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.conversation-detail-info {
    display: flex;
    align-items: center;
}

.conversation-detail-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 0.75rem;
}

.conversation-detail-name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.conversation-detail-status {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.conversation-detail-actions {
    display: flex;
    gap: 0.5rem;
}

.detail-action-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-action-btn:hover {
    background: var(--light-bg);
    color: var(--primary-color);
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--light-bg);
}

.message {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding: 0 1rem;
}

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

.message.received {
    flex-direction: row;
}

.message.reply {
    margin-left: 2rem;
    border-left: 2px solid var(--border-color);
    padding-left: 1rem;
    background: rgba(0, 99, 110, 0.02);
    border-radius: 0.5rem;
}

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

.message-avatar.reply-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
    margin: 0 0.5rem;
}

.message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 70%;
}

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

.message.received .message-content {
    align-items: flex-start;
}

.message-bubble {
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-bubble.reply-bubble {
    background: white;
    border-radius: 0.75rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.message.sent .message-bubble {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.received .message-bubble {
    background: white;
    color: var(--text-color);
    border-bottom-left-radius: 0.25rem;
}

.thread-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0.5rem;
    background: rgba(0, 99, 110, 0.1);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    color: var(--primary-color);
}

.reply-info {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.message-text {
    line-height: 1.5;
    margin-bottom: 0.25rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Reply Area */
.message-reply-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: white;
}

.reply-form {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.reply-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    resize: none;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    max-height: 120px;
    min-height: 44px;
    transition: border-color 0.2s ease;
}

.reply-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.reply-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    background: var(--light-bg);
    color: var(--primary-color);
}

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

.send-btn:hover:not(:disabled) {
    background: #004d57;
}

.send-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

/* Empty States */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.empty-state p {
    font-size: 0.875rem;
}

/* Compose Modal */
.compose-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.compose-modal-content {
    background: white;
    border-radius: 0.5rem;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.compose-modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.compose-modal-body {
    padding: 1.5rem;
}

.compose-form-group {
    margin-bottom: 1rem;
}

.compose-form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.compose-form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

.compose-form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.compose-form-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
    line-height: 1.5;
}

.compose-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #004d57;
}

.btn-secondary {
    background: var(--light-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .unified-messages {
        height: calc(100vh - 60px);
    }

    .messages-sidebar {
        width: 100%;
        position: absolute;
        z-index: 10;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .messages-sidebar.show {
        transform: translateX(0);
    }

    .conversation-detail {
        width: 100%;
    }

    .message-content {
        max-width: 85%;
    }

    .compose-modal-content {
        width: 95%;
        margin: 1rem;
    }
}

@media (max-width: 480px) {
    .conversation-item {
        padding: 0.5rem;
    }

    .conversation-avatar {
        width: 40px;
        height: 40px;
        font-size: 0.875rem;
    }

    .message {
        padding: 0 0.5rem;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
        margin: 0 0.5rem;
    }

    .message-content {
        max-width: 90%;
    }

    .message-bubble {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: slideIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.conversation-item {
    animation: fadeIn 0.2s ease;
}

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    color: white;
    font-weight: 500;
    z-index: 1001;
    animation: slideInRight 0.3s ease;
    max-width: 300px;
}

.notification.success {
    background: var(--success-color);
}

.notification.error {
    background: var(--danger-color);
}

.notification.info {
    background: var(--info-color);
}

.notification.warning {
    background: var(--warning-color);
}

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