/* hugmypc Live Chat Widget — all rules scoped to .chat-widget */

.chat-widget {
    --cw-primary:      #399fe0;
    --cw-primary-dark: #1b78bb;
    --cw-deep-blue:    #26333c;
    --cw-white:        #ffffff;
    --cw-light-bg:     #f1f4f8;
    --cw-text:         #333333;
    --cw-text-muted:   #6c757d;
    --cw-bubble-size:  56px;
    --cw-panel-w:      340px;
    --cw-panel-h:      480px;
    --cw-radius:       14px;
    --cw-shadow:       0 8px 32px rgba(0, 0, 0, 0.18);
    --cw-z-bubble:     1990;
    --cw-z-panel:      2050;
    font-family: "Open Sans", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Bubble ──────────────────────────────────────────────────────────────── */

/* Bubble replaced by site-wide float button group */
.chat-widget__bubble {
    display: none !important;
}

.chat-widget__bubble-hidden {
    position: fixed;
    bottom: 90px;
    right: 20px;
    z-index: var(--cw-z-bubble);
    width: var(--cw-bubble-size);
    height: var(--cw-bubble-size);
    border-radius: 50%;
    background: var(--cw-primary);
    color: var(--cw-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    box-shadow: var(--cw-shadow);
    border: none;
    transition: background 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.chat-widget__bubble:hover {
    background: var(--cw-primary-dark);
    transform: scale(1.06);
}

.chat-widget__bubble:active {
    transform: scale(0.96);
}

.chat-widget__bubble.cw-pulse {
    animation: cw-pulse 1s ease-out 2;
}

@keyframes cw-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(57, 159, 224, 0.55); }
    70%  { box-shadow: 0 0 0 14px rgba(57, 159, 224, 0); }
    100% { box-shadow: 0 0 0 0 rgba(57, 159, 224, 0); }
}

.chat-widget__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e53e3e;
    color: var(--cw-white);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--cw-white);
    display: none;
}

.chat-widget__badge.cw-visible {
    display: flex;
}

/* ── Panel ───────────────────────────────────────────────────────────────── */

.chat-widget__panel {
    position: fixed;
    bottom: 158px;
    right: 20px;
    z-index: var(--cw-z-panel);
    width: var(--cw-panel-w);
    height: var(--cw-panel-h);
    background: var(--cw-white);
    border-radius: var(--cw-radius);
    box-shadow: var(--cw-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.chat-widget__panel.cw-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Panel Header ─────────────────────────────────────────────────────────── */

.chat-widget__header {
    background: var(--cw-primary);
    color: var(--cw-white);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.chat-widget__header-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-widget__header-logo {
    font-family: "Baloo 2", sans-serif;
    font-weight: 700;
    font-size: 21px;
    letter-spacing: -0.3px;
    line-height: 1.1;
    white-space: nowrap;
    flex-shrink: 0;
}

.chat-widget__header-sub {
    font-size: 13px;
    color: #fff;
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chat-widget__status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
    margin-right: 5px;
    vertical-align: middle;
}

.chat-widget__status-dot.cw-online {
    background: #00e676;
    box-shadow: 0 0 0 2px rgba(0, 230, 118, 0.4);
}

.chat-widget__status-dot.cw-ai {
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.chat-widget__close {
    background: none;
    border: none;
    color: var(--cw-white);
    opacity: 0.8;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.chat-widget__close:hover {
    opacity: 1;
}

/* ── Messages Area ─────────────────────────────────────────────────────────── */

.chat-widget__messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

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

.chat-widget__messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-widget__messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 4px;
}

/* ── Message Bubbles ─────────────────────────────────────────────────────── */

.cw-msg {
    max-width: 88%;
    word-wrap: break-word;
    display: flex;
    align-items: flex-start;
    gap: 7px;
}

.cw-msg--visitor {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cw-msg__content {
    flex: 1;
    min-width: 0;
}

.cw-msg__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 18px;
    object-fit: cover;
}

.cw-msg__avatar--user {
    background: #dde3ea;
    color: #9aa5b4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.cw-msg--visitor .cw-msg__bubble {
    background: var(--cw-primary);
    color: var(--cw-white);
    border-radius: 14px 14px 4px 14px;
}

.cw-msg--ai .cw-msg__bubble,
.cw-msg--operator .cw-msg__bubble {
    background: var(--cw-light-bg);
    color: var(--cw-text);
    border-radius: 14px 14px 14px 4px;
}

.cw-msg__bubble {
    padding: 8px 12px;
    font-size: 13.5px;
    line-height: 1.45;
}

.cw-msg__label {
    font-size: 10.5px;
    color: var(--cw-text-muted);
    margin-bottom: 2px;
    padding-left: 2px;
}

.cw-msg--visitor .cw-msg__label {
    text-align: right;
    padding-right: 2px;
    padding-left: 0;
}

/* ── Typing Indicator ─────────────────────────────────────────────────────── */

.cw-typing {
    align-self: flex-start;
    display: none;
}

.cw-typing.cw-visible {
    display: flex;
    flex-direction: column;
}

.cw-typing__bubble {
    background: var(--cw-light-bg);
    border-radius: 14px 14px 14px 4px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cw-typing__dot {
    width: 7px;
    height: 7px;
    background: var(--cw-text-muted);
    border-radius: 50%;
    animation: cw-bounce 1.2s infinite;
}

.cw-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.cw-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes cw-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-5px); }
}

/* ── Message Meta (timestamp + tick) ──────────────────────────────────────── */

.cw-msg__meta {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
    font-size: 10px;
    color: var(--cw-text-muted);
}

.cw-msg--visitor .cw-msg__meta {
    justify-content: flex-end;
}

.cw-tick {
    color: var(--cw-primary);
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Escalation Notice ─────────────────────────────────────────────────────── */

.cw-notice {
    background: #fffbeb;
    border: 1px solid #f6e05e;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    color: #744210;
    text-align: center;
}

/* ── Intro Form ─────────────────────────────────────────────────────────── */

.chat-widget__intro {
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
    gap: 14px;
}

.cw-form-top {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cw-form-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cw-email-note {
    font-size: 11px;
    color: var(--cw-text-muted);
    margin: 0;
    line-height: 1.45;
}

.cw-ai-note {
    font-size: 11px;
    color: var(--cw-text-muted);
    background: var(--cw-light-bg);
    border-radius: 8px;
    padding: 8px 10px;
    margin: 0;
    line-height: 1.5;
}

.chat-widget__intro-title {
    font-family: "Baloo 2", sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--cw-deep-blue);
    margin: 0;
}

.chat-widget__intro-sub {
    font-size: 13px;
    color: var(--cw-text-muted);
    margin: 0;
    margin-top: -6px;
}

.cw-input {
    width: 100%;
    padding: 9px 12px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
    color: var(--cw-text);
    box-sizing: border-box;
}

.cw-input:focus {
    border-color: var(--cw-primary);
    box-shadow: 0 0 0 3px rgba(57, 159, 224, 0.15);
}

.cw-input.cw-error {
    border-color: #e53e3e;
}

.cw-input-error {
    font-size: 11.5px;
    color: #e53e3e;
    margin-top: -8px;
    display: none;
}

.cw-input-error.cw-visible {
    display: block;
}

.cw-btn-start {
    background: var(--cw-primary);
    color: var(--cw-white);
    border: none;
    border-radius: 8px;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cw-btn-start:hover {
    background: var(--cw-primary-dark);
}

.cw-btn-start:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* ── Input Bar ─────────────────────────────────────────────────────────── */

.chat-widget__input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
    background: var(--cw-white);
}

.cw-msg-input {
    flex: 1;
    font-size: 16px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-family: inherit;
    color: var(--cw-text);
    transition: border-color 0.15s;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
}

.cw-msg-input:focus {
    border-color: var(--cw-primary);
}

.cw-btn-send {
    background: var(--cw-primary);
    color: var(--cw-white);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    flex-shrink: 0;
    transition: background 0.2s;
}

.cw-btn-send:hover {
    background: var(--cw-primary-dark);
}

.cw-btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .chat-widget__panel {
        right: 10px;
        left: 10px;
        width: auto;
        bottom: 158px;
    }
}
