/* リセットとベース設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    height: 100vh;
    overflow: hidden;
}

/* アプリケーションコンテナ */
#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ヘッダー */
.app-header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #ecf0f1;
    font-size: 0.9rem;
}

.btn-logout {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-logout:hover {
    background-color: #c0392b;
}

/* メインコンテナ */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* サイドバー（会話リスト） */
.sidebar {
    width: 300px;
    background-color: #ecf0f1;
    border-right: 1px solid #bdc3c7;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1rem;
    background-color: #34495e;
    color: white;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.btn-new {
    width: 100%;
    padding: 0.75rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.btn-new:hover {
    background-color: #2980b9;
}

/* 会話リスト */
.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.conversation-item {
    background-color: white;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.conversation-item:hover {
    background-color: #f8f9fa;
}

.conversation-item.active {
    background-color: #e3f2fd;
    border-color: #3498db;
}

.conversation-item h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-item p {
    font-size: 0.85rem;
    color: #7f8c8d;
}

/* チャットエリア */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: white;
}

.chat-header {
    padding: 1rem 2rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h2 {
    font-size: 1.25rem;
    color: #2c3e50;
}

.btn-delete {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.btn-delete:hover {
    background-color: #c0392b;
}

/* メッセージコンテナ */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.welcome-message {
    text-align: center;
    padding: 3rem;
    color: #7f8c8d;
}

.welcome-message h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

/* メッセージ */
.message {
    display: flex;
    gap: 1rem;
    animation: fadeIn 0.3s ease-in;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background-color: #3498db;
}

.message.assistant .message-avatar {
    background-color: #2ecc71;
}

.message-body {
    flex: 1;
}

.message-content {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    line-height: 1.6;
}

.message.user .message-content {
    background-color: #e3f2fd;
}

.message-time {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-top: 0.5rem;
}

/* 入力エリア */
.input-area {
    padding: 1rem 2rem;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.input-wrapper {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
}

.message-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
}

.send-button {
    padding: 0.75rem 1.5rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.send-button:hover:not(:disabled) {
    background-color: #2980b9;
}

.send-button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

.input-info {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #7f8c8d;
    text-align: right;
}

/* ローディング */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: #e74c3c;
}

.modal-content button {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .sidebar {
        width: 250px;
    }
    
    .chat-header {
        padding: 1rem;
    }
    
    .messages-container {
        padding: 1rem;
    }
    
    .input-area {
        padding: 1rem;
    }
}

/* スクロールバーのスタイル */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* タイピングインジケーター */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 1rem;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: #95a5a6;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

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

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