/* Red Mail Writer - Chat Interface Styles (with Conversation History) */

#red-mail-chat-container {
    max-width: 1400px;
    width: calc(100vw - 40px);
    margin: 20px auto;
    padding: 0;
    box-sizing: border-box;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    height: 700px;
}

/* サイドバー（会話履歴） */
#red-conversation-sidebar {
    width: 280px;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
}

#red-conversation-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

#red-new-conversation {
    width: 100%;
    padding: 10px 16px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#red-new-conversation:hover {
    background: #b91c1c;
}

#red-conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.red-conversation-item {
    padding: 12px;
    margin-bottom: 8px;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.red-conversation-item:hover {
    background: #f3f4f6;
}

.red-conversation-item.active {
    background: #fef2f2;
    border-color: #dc2626;
}

.red-conversation-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.red-conversation-preview {
    font-size: 12px;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.red-conversation-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
}

.red-no-conversations {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 14px;
}

/* チャットエリア */
#red-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#red-chat-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.red-header-icon {
    font-size: 24px;
}

.red-header-text {
    font-size: 18px;
    font-weight: 600;
}

#red-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #ffffff;
}

.red-message {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
}

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

.red-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: #f3f4f6;
}

.red-message-content {
    flex: 1;
}

.red-message-role {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 4px;
}

.red-message-text {
    background: #f9fafb;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    color: #111827;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.red-message.assistant .red-message-text {
    background: #fef2f2;
    border-left: 3px solid #dc2626;
}

.red-message.user .red-message-text {
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
}

.red-thinking {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 14px;
    padding: 12px;
}

.red-thinking-dots {
    display: flex;
    gap: 4px;
}

.red-thinking-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: thinking 1.4s infinite;
}

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

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

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

#red-chat-input-area {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    display: flex;
    gap: 12px;
}

#red-user-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.2s;
}

#red-user-input:focus {
    outline: none;
    border-color: #0d9488;
}

#red-send-button {
    padding: 12px 24px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

#red-send-button:hover {
    background: #b91c1c;
}

#red-send-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* スクロールバー */
#red-chat-messages::-webkit-scrollbar,
#red-conversation-list::-webkit-scrollbar {
    width: 6px;
}

#red-chat-messages::-webkit-scrollbar-track,
#red-conversation-list::-webkit-scrollbar-track {
    background: #f3f4f6;
}

#red-chat-messages::-webkit-scrollbar-thumb,
#red-conversation-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

#red-chat-messages::-webkit-scrollbar-thumb:hover,
#red-conversation-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* レスポンシブ */
@media (max-width: 768px) {
    #red-mail-chat-container {
        flex-direction: column;
        height: auto;
        min-height: 600px;
    }
    
    #red-conversation-sidebar {
        width: 100%;
        max-height: 200px;
    }
    
    #red-chat-area {
        min-height: 400px;
    }
}
