/* ============================================================================
   UNIFIED CHAT DESIGN
   Single consistent chat style for ALL chat interfaces:
   - CEO Panel Chat
   - Mother Chat
   - Telegram
   - Chat Service

   Updated: December 12, 2025
   ============================================================================ */

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-darker, #1a1d23);
    border-radius: 8px;
}

/* Chat Header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color, #4b5563);
}

.chat-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #e8eaed);
}

.chat-status {
    font-size: 0.85rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-weight: 500;
}

.chat-status.connected {
    color: #10b981;
    background: #10b98120;
}

.chat-status.disconnected {
    color: #ef4444;
    background: #ef444420;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Message Bubble */
.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: messageSlideIn 0.2s ease-out;
}

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

/* User Messages - Right Aligned */
.chat-message.user {
    align-self: flex-end;
}

/* System/Mother Messages - Left Aligned */
.chat-message.system,
.chat-message.assistant {
    align-self: flex-start;
}

/* Message Header (Name + Time) */
.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
    padding: 0 0.5rem;
}

.message-sender {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary, #9aa0a6);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
}

/* Message Content Bubble */
.message-content {
    background: var(--message-bg, #2d3748);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    color: var(--text-primary, #e8eaed);
    line-height: 1.5;
    word-wrap: break-word;
}

/* User Message Styling */
.chat-message.user .message-content {
    background: var(--message-user-bg, #3b82f6);
    color: white;
}

.chat-message.user .message-header {
    flex-direction: row-reverse;
}

/* Code Blocks in Messages */
.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

/* Links in Messages */
.message-content a {
    color: #60a5fa;
    text-decoration: underline;
}

.message-content a:hover {
    color: #93c5fd;
}

/* Message Attachments */
.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0 0.5rem;
}

.message-attachment {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text-secondary, #9aa0a6);
}

/* Approval Request Styling */
.chat-message.approval-request .message-content {
    background: rgba(245, 158, 11, 0.15);
    border-left: 3px solid #f59e0b;
}

.approval-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #f59e0b;
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Approval Buttons */
.approval-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0 0.5rem;
}

.approval-buttons button {
    flex: 1;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.approval-buttons .btn-success {
    background: #10b981;
    color: white;
}

.approval-buttons .btn-success:hover {
    background: #059669;
    transform: scale(1.02);
}

.approval-buttons .btn-danger {
    background: #ef4444;
    color: white;
}

.approval-buttons .btn-danger:hover {
    background: #dc2626;
    transform: scale(1.02);
}

/* Badge Status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #10b98130;
    color: #10b981;
}

.badge-danger {
    background: #ef444430;
    color: #ef4444;
}

.badge-warning {
    background: #f59e0b30;
    color: #f59e0b;
}

/* Chat Input Area */
.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border-color, #4b5563);
}

.chat-input-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-input {
    width: 100%;
    padding: 0.75rem;
    background: var(--input-bg, #374151);
    border: 1px solid var(--border-color, #4b5563);
    border-radius: 8px;
    color: var(--text-primary, #e8eaed);
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    font-family: inherit;
    min-height: 60px;
}

.chat-input::placeholder {
    color: var(--text-muted, #6b7280);
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent-primary, #7c3aed);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.chat-input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-input-buttons {
    display: flex;
    gap: 0.5rem;
}

.chat-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-btn-primary {
    background: var(--accent-primary, #7c3aed);
    color: white;
}

.chat-btn-primary:hover {
    background: #9333ea;
    transform: scale(1.02);
}

.chat-btn-secondary {
    background: var(--btn-secondary-bg, #4b5563);
    color: var(--text-primary, #e8eaed);
}

.chat-btn-secondary:hover {
    background: #6b7280;
}

.chat-btn-icon {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-secondary, #9aa0a6);
    transition: all 0.2s ease;
}

.chat-btn-icon:hover {
    color: var(--text-primary, #e8eaed);
    transform: scale(1.1);
}

/* Empty State */
.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary, #9aa0a6);
    padding: 2rem;
}

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

.chat-empty-text {
    font-size: 1rem;
    line-height: 1.6;
}

/* Loading State */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    color: var(--text-secondary, #9aa0a6);
}

.chat-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color, #4b5563);
    border-top-color: var(--accent-primary, #7c3aed);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--message-bg, #2d3748);
    border-radius: 12px;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-secondary, #9aa0a6);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

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

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color, #4b5563);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary, #9aa0a6);
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-message {
        max-width: 95%;
    }

    .chat-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

