/* --- Chat Widget Styling (Premium Overhaul) --- */
:root {
    --chat-bg: #0f0f0f;
    --chat-accent: #ffffff;
    --chat-bot-bubble: #1e1e1e;
    --chat-user-bubble: #ffffff;
    --chat-text-dark: #000000;
    --chat-text-light: #ffffff;
    --chat-glass: rgba(255, 255, 255, 0.03);
    --chat-border: rgba(255, 255, 255, 0.08);
}

.chat-widget-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10000;
}

/* Trigger Button */
.chat-trigger {
    padding: 0 28px;
    height: 64px;
    background: #ffffff;
    border-radius: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
    position: relative;
    user-select: none;
}

.chat-trigger:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.chat-trigger img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.chat-trigger span {
    font-size: 1rem;
    font-weight: 700;
    color: #000;
    letter-spacing: -0.01em;
}

/* Notification Badge */
.chat-trigger::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #ff3b30;
    border: 2px solid #fff;
    border-radius: 50%;
    display: var(--unread, block);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        opacity: 0.9;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(0.95);
        opacity: 0.9;
    }
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 400px;
    height: min(650px, calc(100vh - 160px));
    background: var(--chat-bg);
    border-radius: 32px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(30px) scale(0.98);
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    border: 1px solid var(--chat-border);
    backdrop-filter: blur(20px);
}

.chat-widget-container.active .chat-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.chat-bg-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
    z-index: 0;
    pointer-events: none;
}

/* Footer (Bottom Input) */
.chat-footer {
    background: #1a1a1a;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--chat-border);
}

.chat-input-field {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 0.95rem;
    padding: 10px 0;
}

.chat-footer-icons {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.2rem;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chat-footer-icons:hover {
    color: #ffffff;
    transform: scale(1.15) rotate(-10deg);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Quick Question Buttons */
.chat-quick-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 5px;
}

.quick-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s;
}

.quick-btn:hover {
    background: #fff;
    color: #000;
}

/* Header */
.chat-header {
    background: rgba(0, 0, 0, 0.4);
    padding: 24px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--chat-border);
    position: relative;
    z-index: 10;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-profile-img {
    width: 48px;
    height: 48px;
    background: #fff;
    border-radius: 50%;
    padding: 2px;
    /* 패딩을 줄여서 로고가 꽉 차게 함 */
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    /* 로고가 원을 벗어나지 않게 처리 */
}

.chat-profile-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-header-text h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}

.chat-header-text p {
    margin: 4px 0 0 0;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
}

.chat-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 50%;
}

.chat-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Body (Critical Fix: Using Flex for auto-stacking) */
.chat-body {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    z-index: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.chat-body::-webkit-scrollbar {
    width: 4px;
}

.chat-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Message Bubbles */
.chat-msg-bubble {
    padding: 16px 22px;
    border-radius: 20px;
    max-width: 85%;
    line-height: 1.6;
    font-size: 0.92rem;
    position: relative;
    animation: bubbleSlide 0.5s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes bubbleSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg-bubble.bot {
    background: var(--chat-bot-bubble);
    color: #fff;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-msg-bubble.user {
    background: var(--chat-user-bubble);
    color: #000;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

.chat-msg-bubble p {
    margin: 0;
    word-break: keep-all;
}

/* Lead Form (Premium Styling) */
.chat-lead-form {
    background: var(--chat-glass);
    padding: 28px 24px;
    border-radius: 24px;
    border: 1px solid var(--chat-border);
    margin-top: 10px;
    transition: border-color 0.3s;
}

.chat-lead-form:focus-within {
    border-color: rgba(255, 255, 255, 0.2);
}

.chat-form-group {
    margin-bottom: 24px;
}

.chat-form-group:last-child {
    margin-bottom: 0;
}

.chat-form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 10px;
}

.chat-form-group input,
.chat-form-group textarea {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 8px 0;
    font-size: 1rem;
    transition: all 0.3s;
    border-radius: 0;
}

.chat-form-group input:focus,
.chat-form-group textarea:focus {
    outline: none;
    border-bottom-color: #fff;
}

.chat-submit-btn {
    width: 100%;
    background: #ffffff;
    color: #000;
    border: none;
    padding: 16px;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

.chat-submit-btn:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(255, 255, 255, 0.1);
}

.chat-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Adjustments */
@media (max-width: 480px) {
    .chat-widget-container {
        bottom: 20px;
        right: 20px;
    }

    .chat-window {
        bottom: 75px;
        width: calc(100vw - 40px);
        height: min(580px, calc(100vh - 110px));
        border-radius: 24px;
    }

    .chat-trigger {
        height: 56px;
        padding: 0 20px;
    }
}