/* 基础样式 - 保持原样 */
#messages {
    margin: 0px;
    width: 100%;
    height: calc(100% - 51px);
    padding: 5px 0px;
    padding-bottom: 51px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#input-box {
    position: absolute;
    opacity: 1;
    width: 100%;
    height: 51px;
    left: 0px;
    bottom: 0px;
    padding: 0px;
    margin: 0px;
    text-align: center;
    border: 1px solid #E2E2E2;
}

#input-text {
    width: 90%;
    height: 50px;
    padding: 0px;
    margin: 0px;
    float: left;
    font-size: 1em;
    border: none;
    outline: none;
    overflow: auto;
    border-radius: 0px;
}

#send {
    width: 10%;
    height: 50px;
    float: left;
    font-weight: bold;
}

#send-image {
    width: 10%;
    height: 50px;
    float: left;
    font-weight: bold;
}

#leave {
    width: 50px;
    height: 50px;
    float: left;
    font-weight: bold;
}

.time-box {
    text-align: center;
    color: grey;
    margin: 10px auto;
    width: fit-content;
    display: block;
}

/* 有聊天背景时的样式 */
.has-bg .time-box {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 4px 10px;
    border-radius: 12px;
    color: white;
    font-size: 12px;
}

.my {
    width: 100%;
    text-align: right;
    margin-bottom: 20px;
}

.my-info {
    font-size: 1em;
}

.has-bg .my-info span {
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
}

.my-info img {
    border-radius: 5px;
}

.my-message {
    max-width: 90%;
    border: 2px solid #FF5E3A;
    border-radius: 7px;
    position: relative;
    background-color: #FF5E3A;
    padding: 10px;
    color: white;
    width: fit-content;
    width: -webkit-fit-content;
    width: -moz-fit-content;
    min-width: 40px;
    min-height: 40px;
    float: right;
    text-align: left;
    font-size: 15px;
    word-wrap: break-word;
}

.my-message::after {
    content: '';
    width: 0;
    height: 0;
    border: 5px solid;
    position: absolute;
    right: -12px;
    border-color: transparent transparent transparent #FF5E3A;
}

.other {
    width: 100%;
    margin-bottom: 20px;
}

.other-info {
    font-size: 1em;
}

.has-bg .other-info span {
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
}

.other-info img {
    border-radius: 5px;
}

.other-message {
    max-width: 90%;
    border: 2px solid whitesmoke;
    border-radius: 7px;
    position: relative;
    background-color: whitesmoke;
    padding: 10px;
    width: fit-content;
    width: -webkit-fit-content;
    width: -moz-fit-content;
    min-width: 40px;
    min-height: 40px;
    font-size: 15px;
    word-wrap: break-word;
}

.other-message::after {
    content: '';
    width: 0;
    height: 0;
    border: 5px solid;
    position: absolute;
    left: -12px;
    border-color: transparent whitesmoke transparent transparent;
}

/* 移动端 */
@media screen and (min-width: 320px) and (max-width: 480px) {
    /* messages 用绝对定位 + top/bottom 代替 calc */
    #messages {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 51px !important;
        height: auto !important;
        overflow-y: auto !important;
        padding: 5px !important;
        padding-bottom: 10px !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .my-message, .other-message {
        max-width: 90%;
    }

    /* 录音模态框居中 */
    #voice-record-modal .modal-dialog {
        margin: 20px auto !important;
        width: auto !important;
        max-width: 90% !important;
        position: relative;
        top: 50%;
        transform: translateY(-50%);
    }

    #voice-record-modal .modal-content {
        width: 100%;
    }

    #voice-record-modal .modal-body {
        padding: 15px !important;
    }

    #record-timer {
        font-size: 20px !important;
    }

    #preview-controls audio {
        height: 40px !important;
    }
}

/* 电脑端样式 */
@media only screen and (min-width: 1029px) {
    #messages {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 51px !important;
        height: auto !important;
        overflow-y: auto !important;
        padding: 5px !important;
        padding-bottom: 10px !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #input-box {
        border-radius: 0px;
    }

    .my-message, .other-message {
        max-width: 90%;
    }

    /* 录音模态框位置调整 - 靠下显示 */
    #voice-record-modal .modal-dialog {
        margin-top: 20vh !important;
    }
}

/* 语音消息样式 */
.voice-message {
    display: inline-flex;
    align-items: center;
    padding: 10px 15px;
    min-width: 80px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.my .voice-message {
    border: 2px solid #FF5E3A;
    background-color: #FF5E3A;
    border-radius: 7px;
    position: relative;
}

.my .voice-message::after {
    content: '';
    width: 0;
    height: 0;
    border: 5px solid;
    position: absolute;
    right: -12px;
    border-color: transparent transparent transparent #FF5E3A;
}

.other .voice-message {
    border: 2px solid whitesmoke;
    border-radius: 7px;
    position: relative;
    background-color: whitesmoke;
}

.other .voice-message::after {
    content: '';
    width: 0;
    height: 0;
    border: 5px solid;
    position: absolute;
    left: -12px;
    border-color: transparent whitesmoke transparent transparent;
}

.voice-play-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    transition: transform 0.2s;
}

.voice-play-btn:hover {
    transform: scale(1.1);
}

.voice-play-btn:active {
    transform: scale(0.95);
}

.my .voice-play-btn svg {
    color: white;
}

.other .voice-play-btn svg {
    color: #666;
}

.voice-duration {
    font-size: 12px;
    color: white;
    margin-left: 10px;
}

.other .voice-duration {
    color: #666;
}

/* 录音模态框样式 */
#voice-record-modal .modal-body {
    padding: 20px;
}

#record-status {
    margin-bottom: 15px;
    font-size: 14px;
    color: #666;
}

#record-timer {
    font-size: 24px;
    font-weight: bold;
    color: #FF5E3A;
    margin-bottom: 15px;
    text-align: center;
}

#record-controls button,
#stop-record-controls button {
    width: 100%;
    padding: 10px;
    font-size: 16px;
}

#preview-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#preview-controls audio {
    width: 100%;
}

#preview-controls > div {
    display: flex;
    gap: 10px;
}

#preview-controls button {
    flex: 1;
    padding: 10px;
}

#preview-controls button.btn-primary {
    background-color: #FF5E3A;
    border-color: #FF5E3A;
}

#preview-controls button.btn-primary:hover {
    background-color: #e55434;
    border-color: #e55434;
}

#gift-panel {
    display: none;
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 58px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    background: #fffdf7;
    border: 1px solid #f0dca0;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(120, 72, 0, .18);
    padding: 12px;
    text-align: left;
}

.gift-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.gift-panel-title {
    font-weight: bold;
    color: #a66a00;
}

.gift-mall-link {
    color: #b87900;
    font-size: 12px;
}

.gift-balance {
    color: #8a6d3b;
    margin-bottom: 10px;
}

.gift-grid-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
    gap: 10px;
}

.gift-panel-item {
    text-align: center;
    border: 1px solid #f3e0aa;
    border-radius: 12px;
    background: white;
    padding: 10px 6px;
}

.gift-panel-icon {
    font-size: 26px;
    line-height: 1;
}

.gift-panel-name {
    margin-top: 5px;
    font-weight: bold;
    color: #5b3614;
    font-size: 13px;
}

.gift-panel-price {
    color: #b87900;
    font-size: 12px;
    margin: 4px 0 8px;
}

.empty-gifts {
    color: #999;
    padding: 20px;
    text-align: center;
}

.gift-message {
    min-width: 150px;
    text-align: center;
    cursor: pointer;
    background: linear-gradient(135deg, #fff8dc 0%, #ffe8a3 100%) !important;
    border-color: #e4b13a !important;
    color: #6a4100 !important;
}

.gift-message::after {
    display: none;
}

.gift-message-icon {
    font-size: 34px;
    line-height: 1;
    margin-bottom: 6px;
}

.red-flower-svg {
    width: 34px;
    height: 34px;
    display: inline-block;
    vertical-align: middle;
}

.gift-panel-icon .red-flower-svg {
    width: 26px;
    height: 26px;
}

.gift-icon .red-flower-svg {
    width: 38px;
    height: 38px;
}

.gift-message-text {
    font-weight: bold;
}

.gift-message-tip {
    margin-top: 4px;
    color: #9b6b16;
    font-size: 12px;
}

.chat-decoration-gold,
.chat-decoration-rose,
.chat-decoration-star,
.chat-decoration-cat,
.chat-decoration-bunny,
.chat-decoration-cloud,
.chat-decoration-sparkle {
    overflow: hidden;
    border-width: 1px !important;
}

.chat-decoration-gold::before,
.chat-decoration-rose::before,
.chat-decoration-star::before,
.chat-decoration-cat::before,
.chat-decoration-bunny::before,
.chat-decoration-cloud::before,
.chat-decoration-sparkle::before,
.chat-decoration-gold::after,
.chat-decoration-rose::after,
.chat-decoration-star::after,
.chat-decoration-cat::after,
.chat-decoration-bunny::after,
.chat-decoration-cloud::after,
.chat-decoration-sparkle::after {
    display: block !important;
    width: auto !important;
    height: auto !important;
    line-height: 1 !important;
    background: transparent !important;
    pointer-events: none;
    border: none !important;
}

.chat-decoration-gold {
    border-color: #f4c542 !important;
    background: linear-gradient(135deg, #fff8d7, #ffe8a3) !important;
    color: #7a4b00 !important;
}

.chat-decoration-rose {
    border-color: #ff86a7 !important;
    background: linear-gradient(135deg, #fff0f5, #ffd6e3) !important;
    color: #9b2f55 !important;
}

.chat-decoration-star {
    border-color: #6e8cff !important;
    background: linear-gradient(135deg, #eef3ff, #dfe7ff) !important;
    color: #263d99 !important;
}

.chat-decoration-cat {
    border-color: #ffb36b !important;
    background: linear-gradient(135deg, #fff4e5, #ffe1bd) !important;
    color: #8a4a08 !important;
}

.chat-decoration-bunny {
    border-color: #ff9fd2 !important;
    background: linear-gradient(135deg, #fff2fb, #ffd9ef) !important;
    color: #9c3170 !important;
}

.chat-decoration-cloud {
    border-color: #8ed8ff !important;
    background: linear-gradient(135deg, #effaff, #d8f2ff) !important;
    color: #23647f !important;
}

.chat-decoration-sparkle {
    border-color: #f7d56b !important;
    background: linear-gradient(135deg, #fffdf0, #fff3bc) !important;
    color: #735400 !important;
}

.chat-decoration-gold::after { content: '👑'; }
.chat-decoration-rose::after { content: '🌸'; }
.chat-decoration-star::after { content: '🌙'; }
.chat-decoration-cat::after { content: '🐾'; }
.chat-decoration-bunny::after { content: '🐰'; }
.chat-decoration-cloud::after { content: '☁️'; }

.my-message.chat-decoration-gold,
.my-message.chat-decoration-rose,
.my-message.chat-decoration-star,
.my-message.chat-decoration-cat,
.my-message.chat-decoration-bunny,
.my-message.chat-decoration-cloud {
    padding-left: 24px;
}

.other-message.chat-decoration-gold,
.other-message.chat-decoration-rose,
.other-message.chat-decoration-star,
.other-message.chat-decoration-cat,
.other-message.chat-decoration-bunny,
.other-message.chat-decoration-cloud {
    padding-right: 24px;
}

.my-message.chat-decoration-gold::after,
.my-message.chat-decoration-rose::after,
.my-message.chat-decoration-star::after,
.my-message.chat-decoration-cat::after,
.my-message.chat-decoration-bunny::after,
.my-message.chat-decoration-cloud::after {
    position: absolute;
    left: 7px;
    right: auto;
    bottom: 7px;
    top: auto;
    font-size: 13px;
    opacity: .78;
    transform: none;
}

.other-message.chat-decoration-gold::after,
.other-message.chat-decoration-rose::after,
.other-message.chat-decoration-star::after,
.other-message.chat-decoration-cat::after,
.other-message.chat-decoration-bunny::after,
.other-message.chat-decoration-cloud::after {
    position: absolute;
    right: 7px;
    left: auto;
    bottom: 7px;
    top: auto;
    font-size: 13px;
    opacity: .78;
    transform: none;
}

.chat-decoration-sparkle::before {
    content: none !important;
    display: none !important;
}

.chat-decoration-sparkle::after { content: '✨'; }

.my-message.chat-decoration-sparkle {
    padding-left: 24px;
}

.other-message.chat-decoration-sparkle {
    padding-right: 24px;
}

.my-message.chat-decoration-sparkle::after {
    position: absolute;
    left: 7px;
    right: auto;
    bottom: 7px;
    top: auto;
    font-size: 13px;
    opacity: .78;
    transform: none;
}

.other-message.chat-decoration-sparkle::after {
    position: absolute;
    right: 7px;
    left: auto;
    bottom: 7px;
    top: auto;
    font-size: 13px;
    opacity: .78;
    transform: none;
}

@keyframes giftFlowerFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 0; }
    12% { opacity: 1; }
    100% { transform: translateY(110vh) rotate(260deg); opacity: 0; }
}

@keyframes giftBalloonRise {
    0% { transform: translateY(0) translateX(0); opacity: 0; }
    12% { opacity: 1; }
    100% { transform: translateY(-115vh) translateX(35px); opacity: 0; }
}

@keyframes giftFireworkBurst {
    0% { transform: translate(0, 0) scale(.5); opacity: 1; }
    78% { opacity: 1; }
    100% { transform: translate(var(--gift-x), var(--gift-y)) scale(.1); opacity: 0; }
}

@keyframes giftStarSkyFade {
    0% { opacity: 0; }
    18% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes giftStarTwinkle {
    0%, 100% { transform: scale(.7); opacity: .35; }
    50% { transform: scale(1.7); opacity: 1; }
}
