/* static/css/style.css */
body {
    background-color: #f0f2f5;
    font-family: 'Noto Sans TC', sans-serif;
    padding-top: 56px; /* 為 fixed-top navbar 預留空間 */

    /* --- ★★★ 核心修改：為 fixed-top navbar 和 iOS 安全區域預留空間 ★★★ --- */
    padding-top: calc(56px + env(safe-area-inset-top));
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
}

.main-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 112px); /* 減去 navbar 和 footer 的高度 */
    width: 100%;
}

.flash-messages-container {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    width: 90%;
    max-width: 800px;
}

.main-content-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 設定畫面樣式 */
#setup-container {
    width: 100%;
    max-width: 450px;
    margin: 1rem auto;
    padding: 2.5rem;
    border: 1px solid #ddd;
    border-radius: 20px;
    background-color: #ffffff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    text-align: center;
}

#setup-container .setup-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
}

#setup-container .selector-group {
    width: 100%;
    max-width: 300px;
    text-align: left;
}

#setup-container .selector-group label {
    font-weight: 500;
    margin-bottom: 0.3rem;
    color: #333;
}

#setup-container .avatar-container {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    margin-bottom: 1rem;
}

#setupCharacterAvatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 聊天主畫面佈局 */
#chatbot-container {
    width: 100%;
    max-width: 420px;
    height: 85vh;
    max-height: 800px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.character-area {
    display: none;
}

#chat-log {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px; /* 增加對話之間的間距 */
}

/* --- ★★★ 核心修改：新的對話訊息結構樣式 ★★★ --- */
.message-wrapper {
    display: flex;
    align-items: flex-end; /* 頭像與對話框底部對齊 */
    gap: 10px;
    max-width: 90%;
}

.user-wrapper {
    margin-left: auto; /* 使用者訊息靠右 */
    flex-direction: row-reverse; /* 讓氣泡在右邊 */
}

.ai-wrapper {
    margin-right: auto; /* AI 訊息靠左 */
}

.chat-avatar-container {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #f1f1f1;
    align-self: flex-start; /* 頭像從頂部對齊 */
}

.chat-avatar-container .chat-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-bubble {
    padding: 10px 15px;
    border-radius: 18px;
    position: relative;
    line-height: 1.5;
}

.user-bubble {
    background-color: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-bubble {
    background-color: #f1f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}
/* 移除了舊的 .ai-bubble::before 規則 */


.bubble-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-suggestion {
    background: rgba(255,255,255,0.7);
    border: 1px solid #007bff;
    color: #007bff;
    padding: 2px 8px;
    font-size: 0.8rem;
    border-radius: 12px;
}

#input-area {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    border-top: 1px solid #dee2e6;
    flex-shrink: 0;
}

.btn-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #f1f0f0;
    color: #555;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-record {
    flex-grow: 1;
    height: 50px;
    border-radius: 25px;
    border: none;
    background: linear-gradient(90deg, #3498db, #8e44ad);
    color: white;
    font-size: 1.1rem;
    margin: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-record.recording {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.btn-record i {
    margin-right: 8px;
}

.btn-icon {
    background-color: #e9ecef;
    color: #495057;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: #ced4da;
}

.translation-text {
    margin-top: 8px;
    padding: 8px 12px;
    background-color: #fff3cd;
    color: #664d03;
    border-radius: 8px;
    font-size: 0.9rem;
    border: 1px solid #ffecb5;
}

footer.footer {
    position: static;
}

.keywords-list {
    list-style-type: none;
    padding-left: 0;
}

.keywords-list li {
    font-size: 1.1rem;
    padding: 8px 0;
    display: flex;
    align-items: center;
}

.btn-pronounce {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem; /* 讓喇叭圖示大一點 */
    margin: 0 8px;
    padding: 0 5px;
    line-height: 1;
    color: #007bff;
    transition: transform 0.2s;
}

.btn-pronounce:hover {
    transform: scale(1.2);
}

.btn-pronounce:disabled {
    cursor: default;
    color: #6c757d;
}

.btn-pronounce .fa-spinner {
    font-size: 1rem;
    color: #6c757d;
}


.login-buttons-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.login-buttons-container .btn {
    width: 250px; /* 固定寬度讓按鈕對齊 */
    justify-content: center;
}


/* --- ★★★ 新增：Header 純圖示登入按鈕樣式 ★★★ --- */
.btn-icon-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.1rem;
    transition: background-color 0.2s, border-color 0.2s;
}

.btn-icon-circle.btn-line {
    background-color: #06C755;
    border: 1px solid #06C755;
    color: white;
}

.btn-icon-circle.btn-line:hover {
    background-color: #05a044;
    border-color: #05a044;
    color: white;
}

.btn-icon-circle.btn-google {
    background-color: #fff;
    border: 1px solid #ddd;
}

.btn-icon-circle.btn-google:hover {
    background-color: #f7f7f7;
}