/* リセット & 基本スタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    background: #f8f9fa;
    color: #202124;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

.hidden {
    display: none !important;
}

/* ヘッダー */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: white;
    border-bottom: 1px solid #e8eaed;
    height: 64px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5f6368;
    transition: background 0.2s;
}

.menu-btn:hover {
    background: #f1f3f4;
}

.logo {
    font-size: 22px;
    font-weight: 400;
    color: #202124;
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pro-badge {
    padding: 6px 12px;
    background: #e8f0fe;
    color: #1967d2;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
}

.user-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4285f4 0%, #34a853 25%, #fbbc04 50%, #ea4335 75%, #4285f4 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    transition: opacity 0.2s, transform 0.2s;
    border: 2px solid white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.user-btn:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.user-name {
    font-weight: 600;
    letter-spacing: -0.5px;
}

/* サイドバー */
.sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 280px;
    height: 100vh;
    background: white;
    border-right: 1px solid #e8eaed;
    transition: left 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 500;
}

.close-sidebar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 24px;
    color: #5f6368;
}

.close-sidebar:hover {
    background: #f1f3f4;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
}

/* 画像履歴 */
.image-history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.image-history-item {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.image-history-item:hover {
    background: #e8eaed;
    border-color: #1a73e8;
}

.image-history-item img {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 8px;
}

.image-history-item-info {
    font-size: 12px;
    color: #5f6368;
}

.image-history-item-prompt {
    font-size: 13px;
    color: #202124;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.no-history {
    text-align: center;
    color: #9aa0a6;
    padding: 20px;
    font-size: 14px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: #f1f3f4;
    border-radius: 24px;
    font-size: 14px;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: #e8eaed;
}

/* メインコンテンツ */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 160px;
    scroll-behavior: smooth;
}

/* 初期画面 */
.welcome-screen {
    max-width: 800px;
    margin: 60px auto 0;
}

.welcome-message {
    margin-bottom: 40px;
}

.user-greeting {
    font-size: 32px;
    font-weight: 400;
    margin-bottom: 8px;
    color: #202124;
}

.welcome-text {
    font-size: 32px;
    font-weight: 400;
    color: #5f6368;
}

.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.suggestion-card {
    padding: 16px 20px;
    background: white;
    border: 1px solid #e8eaed;
    border-radius: 12px;
    text-align: left;
    font-size: 14px;
    color: #202124;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.suggestion-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #dadce0;
}

/* チャット画面 */
.chat-screen {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.messages-container {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* ユーザーメッセージ（右側・吹き出し） */
.message.user {
    display: flex;
    justify-content: flex-end;
    animation: fadeIn 0.3s ease;
}

.message.user .message-content {
    max-width: 70%;
    background: #e3f2fd;
    border-radius: 18px 18px 4px 18px;
    padding: 12px 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message.user .message-text {
    color: #1a1a1a;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* アシスタントメッセージ（中央・広く表示） */
.message.assistant {
    display: flex;
    gap: 16px;
    animation: fadeIn 0.5s ease;
    scroll-margin-top: 100px; /* スクロール時の余白 */
}

.message.assistant .message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
}

.message.assistant .message-content {
    flex: 1;
    padding: 0;
}

.message.assistant .message-text {
    color: #202124;
    line-height: 1.7;
    font-size: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* アバターを非表示（ユーザーメッセージ） */
.message.user .message-avatar {
    display: none;
}

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

.message-images {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.message-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid #e8eaed;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.message-image:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.message-image:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 画像モーダル */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    cursor: pointer;
}

.image-modal img {
    max-width: 90%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    color: #202124;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.image-modal-close:hover {
    background: #f1f3f4;
}

.loading-dots {
    display: flex;
    gap: 4px;
    padding: 12px 0;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5f6368;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 入力エリア */
.input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #f8f9fa;
    padding: 16px 20px;
    border-top: 1px solid #e8eaed;
}

.input-container {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    background: white;
    border: 1px solid #e8eaed;
    border-radius: 24px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    color: #202124;
}

.message-input::placeholder {
    color: #9aa0a6;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5f6368;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: #f1f3f4;
}

.model-select {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: 16px;
    font-size: 14px;
    color: #5f6368;
    transition: background 0.2s;
}

.model-select:hover {
    background: #f1f3f4;
}

.model-select:hover {
    background: #f1f3f4;
}

.model-select-wrapper {
    position: relative;
}

.model-dropdown {
    position: absolute;
    bottom: 50px;
    right: 0;
    background: white;
    border: 1px solid #e8eaed;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    z-index: 100;
}

.model-dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f1f3f4;
}

.model-dropdown-item:last-child {
    border-bottom: none;
}

.model-dropdown-item:hover {
    background: #f8f9fa;
}

.model-dropdown-item.active {
    background: #e8f0fe;
    color: #1967d2;
    font-weight: 500;
}

.model-dropdown-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}

.model-dropdown-desc {
    font-size: 12px;
    color: #5f6368;
}

.send-btn {
    color: #1a73e8;
}

.send-btn:hover {
    background: #e8f0fe;
}

.voice-btn {
    color: #1a73e8;
}

.image-preview {
    max-width: 900px;
    margin: 12px auto 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.preview-item {
    position: relative;
    width: 80px;
    height: 80px;
}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e8eaed;
}

.remove-preview {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #202124;
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* モーダル */
.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: 2000;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e8eaed;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 500;
}

.close-modal {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 24px;
    color: #5f6368;
}

.close-modal:hover {
    background: #f1f3f4;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.setting-group {
    margin-bottom: 24px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #202124;
}

.setting-group input[type="text"],
.setting-group input[type="password"],
.setting-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #dadce0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.setting-group input:focus,
.setting-group textarea:focus {
    border-color: #1a73e8;
}

.setting-group small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #5f6368;
}

.setting-group input[type="range"] {
    width: calc(100% - 60px);
    margin-right: 12px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e8eaed;
    display: flex;
    justify-content: flex-end;
}

.btn {
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #1a73e8;
    color: white;
}

.btn-primary:hover {
    background: #1557b0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* レスポンシブ */
@media (max-width: 768px) {
    .suggestion-cards {
        grid-template-columns: 1fr;
    }

    .welcome-message {
        margin-bottom: 24px;
    }

    .user-greeting,
    .welcome-text {
        font-size: 24px;
    }
}

/* 画像拡大モーダル */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    cursor: pointer;
    animation: fadeIn 0.2s ease;
}

.image-modal img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.image-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}
