/* ======================
   CHAT WIDGET
====================== */

.site-header,
.site-footer,
.mobile-bottom-nav,
.chat-fab {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.site-header {
    top: 0;
}

.mobile-bottom-nav {
    bottom: 0;
}

.site-footer {
    bottom: 0;
}

.temple-chat-modal,
.temple-chat-box,
.temple-chat-header,
.temple-chat-form {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

.temple-chat-modal {
    position: fixed;
    inset: 0;
    display: block;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.28);
    z-index: 99999;
    overscroll-behavior: none;
    touch-action: none;
    transition: opacity 0.18s ease, visibility 0.18s ease;
    padding-top: calc(74px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    padding-left: 10px;
    padding-right: 10px;
}

.temple-chat-modal.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.temple-chat-box {
    width: 100%;
    max-width: 520px;
    height: 100%;
    margin: 0 auto;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

.temple-chat-header {
    position: relative;
    background: linear-gradient(90deg, #8b0000, #b8860b);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    font-weight: 700;
    flex-shrink: 0;
    min-height: 72px;
    width: 100%;
}

.temple-chat-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
    padding-right: 90px;
}

.temple-chat-title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
}

.temple-chat-subtitle {
    font-size: 12px;
    opacity: 0.9;
    font-weight: 500;
    line-height: 1.3;
}

.temple-chat-close {
    position: absolute;
    top: 12px;
    right: 12px;
    left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 86px;
    height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    border: 2px solid rgba(255,255,255,0.85);
    background: #8b0000;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.temple-chat-close:hover {
    background: #6e0000;
}

.temple-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #faf8f3;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.temple-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.temple-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.18);
    border-radius: 999px;
}

.temple-chat-form {
    display: flex;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}

.temple-chat-form input[type="text"] {
    flex: 1;
    margin-bottom: 0;
    border-radius: 14px;
    padding: 12px 14px;
    min-height: 46px;
    min-width: 0;
}

.temple-chat-form .btn {
    min-width: 82px;
    border-radius: 14px;
    padding: 12px 14px;
    flex-shrink: 0;
}

.chat-bubble {
    max-width: 84%;
    padding: 12px 14px;
    border-radius: 16px;
    margin-bottom: 12px;
    line-height: 1.55;
    word-break: break-word;
    font-size: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.04);
}

.chat-bubble.bot {
    background: #f3efe6;
    color: #333;
    border-top-left-radius: 6px;
    margin-right: auto;
}

.chat-bubble.user {
    background: #b8860b;
    color: #fff;
    border-top-right-radius: 6px;
    margin-left: auto;
}

.chat-bubble.bot ul {
    margin: 8px 0 0 18px;
}

.chat-bubble.bot li {
    margin-bottom: 4px;
}

.temple-chat-empty-tip {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
}

.chat-fab {
    position: fixed;
    right: 18px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #b8860b, #8b0000);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(0,0,0,0.22);
    z-index: 7000;
    padding: 0;
    margin: 0;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    appearance: none;
    -webkit-appearance: none;
}

.chat-fab i,
.chat-fab svg {
    pointer-events: none;
    line-height: 1;
    font-size: 24px;
}

.temple-chat-modal.active ~ .chat-fab,
html.chat-open .chat-fab,
body.chat-open .chat-fab {
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 768px) {
    .temple-chat-modal {
        padding-top: calc(74px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
        padding-left: 10px;
        padding-right: 10px;
    }

    .temple-chat-box {
        max-width: none;
        width: 100%;
        height: 100%;
        border-radius: 16px;
    }

    .chat-fab {
        right: 16px;
        bottom: calc(74px + env(safe-area-inset-bottom, 0px));
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
}
@media (max-width: 768px) {
    .temple-chat-modal {
        display: none !important;
    }
}