/* ==========================================================================
   마이스코리아 채팅 상담 위젯 (방문자용)
   - 채널톡 레이아웃/인터랙션을 기준으로 제작
   - 사이트 전역 CSS(bootstrap, main.css 등)와 충돌하지 않도록
     모든 규칙을 #mais-chat 하위로 한정하고 .mc- 접두사를 사용한다.
   ========================================================================== */

#mais-chat {
    --mc-brand: #0f51e0;
    --mc-brand-dark: #0b3ca9;
    --mc-brand-soft: #e8efff;
    --mc-text: #1b1c2a;
    --mc-muted: #8b8fa3;
    --mc-line: #e7e9ef;
    --mc-bg: #f5f6f8;
    --mc-radius: 16px;
    --mc-shadow: 0 12px 40px rgba(16, 24, 64, 0.18);

    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2147483000;
    font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Malgun Gothic",
        "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--mc-text);
}

#mais-chat *,
#mais-chat *::before,
#mais-chat *::after {
    box-sizing: border-box;
}

/* --------------------------------------------------------------- 런처 버블 */
#mais-chat .mc-launcher {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--mc-brand);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(15, 81, 224, 0.4);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

#mais-chat .mc-launcher:hover {
    background: var(--mc-brand-dark);
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(15, 81, 224, 0.45);
}

#mais-chat .mc-launcher:focus-visible {
    outline: 3px solid rgba(15, 81, 224, 0.35);
    outline-offset: 3px;
}

#mais-chat .mc-launcher svg {
    width: 28px;
    height: 28px;
    display: block;
}

#mais-chat .mc-launcher .mc-icon-close {
    display: none;
}

#mais-chat.is-open .mc-launcher .mc-icon-chat {
    display: none;
}

#mais-chat.is-open .mc-launcher .mc-icon-close {
    display: block;
}

#mais-chat .mc-launcher-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #e5342a;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
}

#mais-chat .mc-launcher-badge[hidden] {
    display: none;
}

/* ------------------------------------------------------------------- 패널 */
#mais-chat .mc-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    display: none;
    flex-direction: column;
    width: 372px;
    height: 620px;
    max-height: calc(100vh - 120px);
    border-radius: var(--mc-radius);
    background: #fff;
    box-shadow: var(--mc-shadow);
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

#mais-chat.is-open .mc-panel {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* 헤더 */
#mais-chat .mc-header {
    position: relative;
    flex: 0 0 auto;
    padding: 20px 20px 22px;
    background: linear-gradient(135deg, var(--mc-brand) 0%, #2a6bf2 55%, #4f8bff 100%);
    color: #fff;
}

#mais-chat .mc-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

#mais-chat .mc-header-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: #fff;
}

#mais-chat .mc-header-sub {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.85);
}

#mais-chat .mc-header-close {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease;
}

#mais-chat .mc-header-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

#mais-chat .mc-header-close svg {
    width: 16px;
    height: 16px;
}

#mais-chat .mc-header-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    font-size: 12px;
    font-weight: 600;
}

#mais-chat .mc-header-state .mc-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #5ce39a;
}

#mais-chat .mc-header-state.is-waiting .mc-dot {
    background: #ffd15c;
}

#mais-chat .mc-header-state.is-closed .mc-dot {
    background: #c9ccd8;
}

/* 메시지 영역 */
#mais-chat .mc-body {
    flex: 1 1 auto;
    padding: 18px 16px 8px;
    overflow-y: auto;
    background: var(--mc-bg);
    overscroll-behavior: contain;
}

#mais-chat .mc-body::-webkit-scrollbar {
    width: 6px;
}

#mais-chat .mc-body::-webkit-scrollbar-thumb {
    border-radius: 3px;
    background: #d3d6e0;
}

#mais-chat .mc-day {
    margin: 6px 0 14px;
    text-align: center;
    font-size: 11.5px;
    color: var(--mc-muted);
}

#mais-chat .mc-msg {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

#mais-chat .mc-msg-avatar {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff;
    border: 1px solid var(--mc-line);
    color: var(--mc-brand);
    font-size: 12px;
    font-weight: 700;
}

#mais-chat .mc-msg-main {
    min-width: 0;
    max-width: 78%;
}

#mais-chat .mc-msg-name {
    margin: 0 0 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: #5b6079;
}

#mais-chat .mc-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

#mais-chat .mc-bubble {
    padding: 6px 13px;
    border-radius: 4px 14px 14px 14px;
    background: #fff;
    color: var(--mc-text);
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(16, 24, 64, 0.06);
}

#mais-chat .mc-msg-time {
    flex: 0 0 auto;
    font-size: 10.5px;
    color: var(--mc-muted);
    white-space: nowrap;
}

/* 방문자 메시지 (오른쪽 정렬) */
#mais-chat .mc-msg.is-mine {
    flex-direction: row-reverse;
}

#mais-chat .mc-msg.is-mine .mc-msg-avatar {
    display: none;
}

#mais-chat .mc-msg.is-mine .mc-msg-main {
    margin-left: auto;
}

#mais-chat .mc-msg.is-mine .mc-msg-row {
    flex-direction: row-reverse;
}

#mais-chat .mc-msg.is-mine .mc-bubble {
    border-radius: 8px 2px 8px 8px;
    background: var(--mc-brand);
    color: #fff;
    box-shadow: none;
}

#mais-chat .mc-msg.is-pending .mc-bubble {
    opacity: 0.6;
}

#mais-chat .mc-msg.is-failed .mc-bubble {
    background: #e5342a;
}

/* 시스템 안내 */
#mais-chat .mc-system {
    margin: 10px 0 14px;
    padding: 9px 12px;
    border-radius: 10px;
    background: #eceef3;
    color: #5b6079;
    font-size: 12px;
    text-align: center;
}

/* 상담원 입력중 */
#mais-chat .mc-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 11px 14px;
    width: 54px;
    border-radius: 4px 14px 14px 14px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 64, 0.06);
}

#mais-chat .mc-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #b9bdcc;
    animation: mc-bounce 1.2s infinite ease-in-out;
}

#mais-chat .mc-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

#mais-chat .mc-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes mc-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ----------------------------------------------------------------- 입력부 */
#mais-chat .mc-footer {
    flex: 0 0 auto;
    border-top: 1px solid var(--mc-line);
    background: #fff;
}

#mais-chat .mc-guest-fields {
    display: flex;
    gap: 8px;
    padding: 12px 14px 0;
}

#mais-chat .mc-guest-fields[hidden] {
    display: none;
}

#mais-chat .mc-guest-fields input {
    flex: 1 1 0;
    min-width: 0;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--mc-line);
    border-radius: 8px;
    background: #fbfbfd;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--mc-text);
}

#mais-chat .mc-guest-fields input:focus {
    outline: none;
    border-color: var(--mc-brand);
    background: #fff;
}

#mais-chat .mc-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
}

#mais-chat .mc-input {
    flex: 1 1 auto;
    min-height: 38px;
    max-height: 110px;
    padding: 9px 12px;
    border: 1px solid var(--mc-line);
    border-radius: 10px;
    background: #fbfbfd;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--mc-text);
    resize: none;
    overflow-y: auto;
}

#mais-chat .mc-input:focus {
    outline: none;
    border-color: var(--mc-brand);
    background: #fff;
}

#mais-chat .mc-send {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: var(--mc-brand);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

#mais-chat .mc-send:disabled {
    background: #c9ccd8;
    cursor: default;
}

#mais-chat .mc-send svg {
    width: 18px;
    height: 18px;
}

#mais-chat .mc-alt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 14px 12px;
    font-size: 11.5px;
    color: var(--mc-muted);
}

#mais-chat .mc-alt a {
    color: #5b6079;
    text-decoration: none;
    font-weight: 600;
}

#mais-chat .mc-alt a:hover {
    color: var(--mc-brand);
    text-decoration: underline;
}

#mais-chat .mc-alt .mc-alt-sep {
    color: var(--mc-line);
}

#mais-chat .mc-error {
    margin: 0 14px 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fdecea;
    color: #c0271c;
    font-size: 12px;
}

#mais-chat .mc-error[hidden] {
    display: none;
}

/* ---------------------------------------------------------------- 모바일 */
@media (max-width: 520px) {
    #mais-chat {
        right: 14px;
        bottom: 14px;
    }

    #mais-chat .mc-panel {
        position: fixed;
        right: 0;
        left: 0;
        top: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }
}
