/* 실시간 채팅 플로팅 (사용자 페이지) */
.chat-fab {
    position: fixed;
    right: 16px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    z-index: 10160;
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c5ce7, #00cec9);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    box-shadow: 0 8px 28px rgba(0, 206, 201, 0.45), 0 4px 16px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.chat-fab:hover {
    transform: scale(1.06);
}

.chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #ff4757;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

.chat-panel {
    position: fixed;
    right: 16px;
    bottom: calc(142px + env(safe-area-inset-bottom, 0px));
    z-index: 10165;
    width: min(360px, calc(100vw - 32px));
    height: min(480px, calc(100vh - 200px));
    max-height: calc(100vh - 180px);
    background: #141820;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-panel.hidden {
    display: none !important;
}

.chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px 10px 14px;
    background: linear-gradient(90deg, #2d3436, #0984e3);
    color: #fff;
    font-weight: 600;
    flex-shrink: 0;
}

.chat-panel-header-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
}

.chat-panel-title {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 14px;
}

.chat-telegram-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    padding: 8px 14px 8px 8px;
    min-height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2eb6ff 0%, #0088cc 55%, #0077b5 100%);
    border: 2px solid rgba(255, 255, 255, 0.55);
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 6px 20px rgba(0, 136, 204, 0.6), 0 0 0 3px rgba(0, 136, 204, 0.22);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    animation: chatTelegramPulse 2.4s ease-in-out infinite;
}

@keyframes chatTelegramPulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(0, 136, 204, 0.6), 0 0 0 3px rgba(0, 136, 204, 0.22); }
    50% { box-shadow: 0 8px 24px rgba(0, 136, 204, 0.75), 0 0 0 5px rgba(46, 182, 255, 0.28); }
}

.chat-telegram-btn:hover,
.chat-telegram-btn:focus {
    color: #fff;
    filter: brightness(1.08);
    transform: translateY(-1px) scale(1.02);
    animation: none;
    box-shadow: 0 8px 26px rgba(0, 136, 204, 0.75), 0 0 0 4px rgba(255, 255, 255, 0.25);
}

.chat-telegram-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #fff;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
}

.chat-telegram-logo {
    width: 34px;
    height: 34px;
    display: block;
}

.chat-telegram-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
    min-width: 0;
}

.chat-telegram-label-main {
    display: block;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -0.03em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

.chat-telegram-label-sub {
    display: block;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    opacity: 0.96;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

@media (max-width: 420px) {
    .chat-panel-header {
        padding: 8px 8px 8px 10px;
        gap: 6px;
    }

    .chat-panel-title {
        font-size: 11px;
        max-width: 58px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .chat-panel-title .fa-headset {
        display: none;
    }

    .chat-telegram-btn {
        padding: 6px 10px 6px 6px;
        gap: 8px;
        min-height: 46px;
        border-radius: 12px;
    }

    .chat-telegram-icon-wrap {
        width: 40px;
        height: 40px;
    }

    .chat-telegram-logo {
        width: 30px;
        height: 30px;
    }

    .chat-telegram-label-main {
        font-size: 11px;
    }

    .chat-telegram-label-sub {
        font-size: 10px;
    }
}

.chat-panel-close {
    border: none;
    background: transparent;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.chat-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-panel-footer {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: #0f1218;
}

.chat-panel-footer textarea {
    flex: 1;
    min-width: 0;
    resize: none;
    border-radius: 10px;
    border: 1px solid #333;
    background: #1e2430;
    color: #e8eaed;
    padding: 8px 10px;
    font-size: 14px;
}

.chat-send-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: #6c5ce7;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
}

.chat-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.admin {
    align-self: flex-start;
    background: #2d3436;
    color: #dfe6e9;
    border-bottom-left-radius: 4px;
}

.chat-msg-time {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    opacity: 0.75;
}

.chat-msg.system {
    align-self: center;
    background: transparent;
    color: #95a5a6;
    font-size: 12px;
    text-align: center;
}

.chat-hours-bar {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 11px;
    line-height: 1.4;
    color: #b2bec3;
    background: #1a2030;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-hours-bar.off-hours {
    color: #ffeaa7;
    background: #2d1f3d;
}

.chat-faq-bar {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-faq-btn {
    border: 1px solid #6c5ce7;
    background: transparent;
    color: #dfe6e9;
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
}

.chat-faq-btn:hover {
    background: rgba(108, 92, 231, 0.25);
}

.chat-panel-footer {
    align-items: flex-end;
}

.chat-attach-btn {
    flex-shrink: 0;
    width: 40px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b2bec3;
    cursor: pointer;
    border-radius: 8px;
}

.chat-attach-btn:hover {
    color: #00cec9;
}

.chat-att img {
    max-width: 100%;
    max-height: 160px;
    border-radius: 8px;
    margin-top: 6px;
}

.chat-att a {
    color: #74b9ff;
    font-size: 12px;
}

.chat-csat-panel {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: #1a2030;
}

.chat-csat-panel.hidden {
    display: none !important;
}

.chat-panel-body.csat-mode {
    max-height: 40%;
}

.chat-csat-title {
    font-size: 13px;
    margin: 0 0 8px;
    color: #dfe6e9;
}

.chat-csat-stars {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.chat-csat-stars button {
    flex: 1;
    border: 1px solid #636e72;
    background: #2d3436;
    color: #fff;
    border-radius: 6px;
    padding: 6px 0;
    cursor: pointer;
}

.chat-csat-stars button.active {
    background: #fdcb6e;
    border-color: #f39c12;
    color: #2d3436;
}

.chat-csat-panel textarea {
    width: 100%;
    margin-bottom: 8px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #1e2430;
    color: #e8eaed;
    font-size: 13px;
    padding: 6px 8px;
}

.chat-csat-submit {
    width: 100%;
    border: none;
    border-radius: 8px;
    padding: 8px;
    background: #00cec9;
    color: #1a1a1a;
    font-weight: 600;
    cursor: pointer;
}

@media (max-width: 480px) {
    .chat-fab {
        right: 12px;
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        width: 52px;
        height: 52px;
        min-width: 52px;
        min-height: 52px;
    }
    .chat-panel {
        right: 10px;
        left: 10px;
        width: auto;
        bottom: calc(132px + env(safe-area-inset-bottom, 0px));
    }
}
