/* =============================================
   チャット画面用スタイル（LINE風）
   ============================================= */

.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    background: #f0e8eb;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px 8px;
    -webkit-overflow-scrolling: touch;
}

.chat-date-sep {
    text-align: center;
    margin: 12px 0;
    font-size: 11px;
    color: var(--text-muted);
}

.chat-date-sep span {
    background: rgba(180, 160, 168, 0.3);
    padding: 3px 12px;
    border-radius: 10px;
}

/* メッセージ行 */
.msg-row {
    display: flex;
    margin-bottom: 8px;
    align-items: flex-end;
    gap: 6px;
}

.msg-row.user {
    flex-direction: row-reverse;
}

.msg-row.system {
    justify-content: center;
}

/* アバター */
.msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-bg);
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--primary);
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 吹き出し */
.msg-bubble {
    max-width: 72%;
    padding: 9px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    position: relative;
}

.msg-row.teller .msg-bubble {
    background: var(--bg-card);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.msg-row.user .msg-bubble {
    background: var(--primary);
    color: var(--text-white);
    border-bottom-right-radius: 4px;
}

.msg-row.system .msg-bubble {
    background: rgba(180, 160, 168, 0.3);
    color: var(--text-light);
    font-size: 12px;
    border-radius: 10px;
    max-width: 85%;
    text-align: center;
}

.msg-time {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    align-self: flex-end;
    flex-shrink: 0;
}

.msg-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
}

.msg-row.user .msg-meta {
    align-items: flex-start;
}

.msg-read {
    font-size: 9px;
    color: var(--primary-light);
}

.msg-pts {
    font-size: 9px;
    color: var(--text-muted);
}

/* 入力欄 */
.chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0));
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.chat-input {
    flex: 1;
    min-height: 38px;
    max-height: 120px;
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
    resize: none;
    color: var(--text);
    background: var(--bg-input);
    line-height: 1.5;
    outline: none;
}

.chat-input:focus {
    border-color: var(--primary-light);
}

.chat-send-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-white);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.chat-send-btn:disabled {
    background: var(--border);
}

/* チャット情報バー */
.chat-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    background: var(--accent-light);
    font-size: 12px;
    color: var(--text-light);
}

.chat-info-bar .balance {
    font-weight: 600;
    color: var(--primary-dark);
}

/* チャット終了時のオーバーレイ */
.chat-ended-notice {
    text-align: center;
    padding: 20px;
    background: var(--bg-card-alt);
    margin: 12px;
    border-radius: var(--radius);
}

.chat-ended-notice p {
    color: var(--text-light);
    margin-bottom: 12px;
}

/* 画像ボタン */
.chat-img-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--accent-light);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.chat-img-btn:active {
    background: var(--border);
}

/* 画像プレビュー */
.chat-img-preview {
    position: relative;
    padding: 8px 12px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
}

.chat-img-preview.hidden {
    display: none;
}

.chat-img-preview img {
    max-height: 80px;
    max-width: 120px;
    border-radius: 8px;
    object-fit: cover;
}

.chat-img-preview-cancel {
    position: absolute;
    top: 4px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* チャット内画像メッセージ */
.msg-bubble-img {
    padding: 4px;
    background: transparent !important;
    max-width: 60%;
}

.chat-msg-img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 12px;
    object-fit: cover;
    cursor: pointer;
    display: block;
}
