/* サポートチャットウィジェット（impl-support-chatbot.md §11.1・モバイル幅対応） */
#rv-supportchat {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10500;
    font-size: 14px;
}

#rv-supportchat-toggle {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: #f16101;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(241, 97, 1, 0.35);
    transition: background .15s ease;
}

#rv-supportchat-toggle:hover {
    background: #e8740c;
}

/* 未読バッジ（便7 §16・担当者からの返信があるとき） */
#rv-supportchat-toggle {
    position: relative;
}

.rv-sc-badge-unread {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    border: 2px solid #fff;
    background: #d32f2f;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    line-height: 16px;
    text-align: center;
}

/* 有人対応中の帯 */
.rv-sc-operator-banner {
    padding: 6px 12px;
    background: #e8f4fd;
    border-bottom: 1px solid #c7e2f7;
    color: #17527a;
    font-size: 12px;
}

/* 引き継ぎ依頼済み・担当者待ちの帯（裁定A2） */
.rv-sc-pending-banner {
    padding: 6px 12px;
    background: #fff5e6;
    border-bottom: 1px solid #f5dcb3;
    color: #7a5417;
    font-size: 12px;
}

#rv-supportchat-panel {
    position: fixed;
    right: 20px;
    bottom: 88px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 480px;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

#rv-supportchat-panel.rv-sc-hidden,
#rv-supportchat .rv-sc-hidden {
    display: none;
}

.rv-sc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #f16101;
    color: #fff;
}

.rv-sc-title {
    font-weight: bold;
}

#rv-supportchat-close {
    border: none;
    background: transparent;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.rv-sc-notice {
    padding: 8px 12px;
    background: #fff7ed;
    border-bottom: 1px solid #fdba74;
    font-size: 12px;
    line-height: 1.5;
}

.rv-sc-notice-main {
    display: block;
    color: #7c4a12;
}

.rv-sc-notice-sub {
    display: block;
    margin-top: 2px;
    color: #b45309;
    font-weight: bold;
}

.rv-sc-badge {
    display: inline-block;
    margin-right: 6px;
    padding: 1px 6px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.25);
    font-size: 11px;
    font-weight: bold;
    letter-spacing: .04em;
    vertical-align: 1px;
}

.rv-sc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    background: #f7f8fa;
}

.rv-sc-msg {
    display: flex;
    margin-bottom: 8px;
}

.rv-sc-msg-user {
    justify-content: flex-end;
}

.rv-sc-msg-assistant {
    /* 吹き出しの下に評価ボタンを置くため縦積みにする */
    flex-direction: column;
    align-items: flex-start;
}

.rv-sc-bubble {
    max-width: 85%;
    padding: 8px 10px;
    border-radius: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

.rv-sc-msg-user .rv-sc-bubble {
    background: #f16101;
    color: #fff;
}

.rv-sc-msg-assistant .rv-sc-bubble {
    background: #fff;
    color: #222;
    border: 1px solid #e0e0e0;
}

.rv-sc-waiting .rv-sc-bubble {
    color: #888;
    font-style: italic;
}

/* 担当者（運営）の返信。ボットと見分けがつくよう色を変える（便7 §16） */
.rv-sc-msg-operator {
    flex-direction: column;
    align-items: flex-start;
}

.rv-sc-msg-operator .rv-sc-bubble {
    background: #e8f4fd;
    color: #14405f;
    border: 1px solid #c7e2f7;
}

.rv-sc-msg-operator .rv-sc-bubble::before {
    content: attr(data-operator-label);
    display: block;
    font-size: 11px;
    color: #4a7fa5;
    margin-bottom: 2px;
}

/* 経過の案内（担当者が入った/終えた等）。会話の発言ではないので中央の細字にする */
.rv-sc-msg-notice {
    justify-content: center;
}

.rv-sc-msg-notice .rv-sc-bubble {
    max-width: 95%;
    padding: 4px 8px;
    background: none;
    color: #888;
    font-size: 11px;
    text-align: center;
}

/* 回答への評価（👍👎・§13.1） */
.rv-sc-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 2px 0 0 2px;
    max-width: 85%;
}

.rv-sc-rating-label {
    font-size: 11px;
    color: #888;
    margin-right: 2px;
}

.rv-sc-rating-btn {
    padding: 1px 6px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background: #fff;
    font-size: 12px;
    line-height: 1.5;
    cursor: pointer;
}

.rv-sc-rating-btn:hover {
    background: #fff7ed;
    border-color: #f16101;
}

.rv-sc-rating-btn.rv-sc-rating-on {
    background: #fff0e2;
    border-color: #f16101;
}

/* 会話上限時の「新しい会話を始める」（15巡目） */
.rv-sc-newchat-btn {
    border: 1px solid #f16101;
    background: #fff;
    color: #f16101;
    border-radius: 14px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
}

.rv-sc-newchat-btn:hover {
    background: #fff0e2;
}

.rv-sc-escalate {
    padding: 6px 12px;
    border-top: 1px solid #eee;
    background: #fff;
    text-align: center;
}

#rv-supportchat-escalate-btn {
    width: 100%;
    padding: 8px;
    border: 1px solid #f16101;
    border-radius: 6px;
    background: #fff;
    color: #d3560a;
    font-weight: bold;
    cursor: pointer;
}

#rv-supportchat-escalate-btn:hover {
    background: #fff7ed;
}

.rv-sc-input {
    display: flex;
    gap: 6px;
    padding: 8px;
    border-top: 1px solid #eee;
    background: #fff;
}

#rv-supportchat-text {
    flex: 1;
    resize: none;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 14px;
}

#rv-supportchat-send {
    border: none;
    border-radius: 6px;
    background: #f16101;
    color: #fff;
    padding: 0 16px;
    cursor: pointer;
}

#rv-supportchat-send:disabled {
    background: #f6b98d;
    cursor: default;
}

@media (max-width: 480px) {
    #rv-supportchat-panel {
        right: 10px;
        left: 10px;
        width: auto;
        bottom: 84px;
        height: 70vh;
    }

    #rv-supportchat {
        right: 12px;
        bottom: 12px;
    }
}

/* Public choices and navigation share the widget; the main task remains reachable on small screens. */
.rv-sc-controls { display: flex; flex-wrap: wrap; gap: .35rem; padding: .5rem .75rem; align-items: center; }
.rv-sc-controls label { font-size: .75rem; margin: 0; }
.rv-sc-controls select { max-width: 100%; flex: 1 1 35%; min-width: 0; font-size: .8rem; }
.rv-sc-actions { display: flex; flex-wrap: wrap; gap: .4rem; padding: .5rem .75rem; font-size: .8rem; }
.rv-sc-actions a { color: var(--app-primary, #17609c); text-decoration: underline; }
#rv-supportchat-panel { max-height: calc(100dvh - 6rem); }
@media (max-width: 575px) { #rv-supportchat { bottom: max(1rem, env(safe-area-inset-bottom)); } }
