/* Container for the whole widget */
.custom-calendly-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Clickable block: image + tagline share one hit area and group-hover */
.calendly-avatar-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    cursor: pointer;
    border-radius: 0.4rem;
    outline: none;
}

.calendly-avatar-group:focus-visible {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #00afd0;
}

.avatar-title-wrap {
    width: 100%;
    display: flex;
    justify-content: flex-end;
}

/* The Avatar Circle */
.avatar-badge {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    border: 3px solid #fff;
    overflow: hidden;
    transition: transform 0.4s ease, width 0.3s ease, height 0.3s ease, box-shadow 0.4s ease;
    position: relative;
    background: #eee;
}

.avatar-badge img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* No image in settings: hide broken img, show brand tint */
.avatar-badge--no-image {
    background: linear-gradient(150deg, #4dd4ef 0%, #00afd0 45%, #008ba7 100%);
}

/* The Mini Title under the avatar (click handled by .calendly-avatar-group) */
.avatar-title {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-top: -5px;
    background-color: #00afd0;
    color: #fff;
    padding: 8px 16px;
    display: block;
    cursor: pointer;
    user-select: none;
}

/* Speech Bubble — contains absolutely positioned close; text flows from top with normal padding */
.speech-bubble {
    position: absolute;
    bottom: 138px;
    right: 20px;
    width: 300px;
    background: white;
    /* top/left: align copy with the top; right: reserve space for the absolutely positioned close */
    padding: 1rem 2.4rem 1.25rem 1.1rem;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    font-size: 17px;
    font-weight: 500;
    color: #9b4500;
    z-index: 10;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none; /* prevent clicking through to nothing */
    transition: opacity 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
        transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.speech-bubble__message {
    display: block;
    line-height: 1.45;
    text-align: left;
    /* Backend textarea newlines stay as \n in JSON; textContent + pre-line = real line breaks */
    white-space: pre-line;
}

.speech-bubble__signoff {
    display: block;
    margin-top: 0.6em;
    text-align: right;
    font-size: 0.86em;
    line-height: 1.3;
    font-weight: 500;
    color: #9b4500;
    opacity: 0.9;
}

.speech-bubble__close {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    z-index: 2;
    width: 1.9rem;
    height: 1.9rem;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #a48063;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.speech-bubble__close:hover {
    background-color: rgba(155, 69, 0, 0.1);
    color: #9b4500;
    transform: scale(1.05);
}

.speech-bubble__close:focus {
    outline: 2px solid #00afd0;
    outline-offset: 1px;
}

.speech-bubble__close:focus:not(:focus-visible) {
    outline: none;
}

.speech-bubble__close:focus-visible {
    outline: 2px solid #00afd0;
    outline-offset: 1px;
}

/* The little triangle on the bubble */
.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    right: 20px;
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: white transparent transparent;
}

/* Visible / interactive bubble (no looping motion — only transition is .speech-bubble) */
.speech-bubble.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Collapsed State (When user clicks to minimize) */
.custom-calendly-container.minimized .avatar-title-wrap,
.custom-calendly-container.minimized .speech-bubble {
    display: none;
}

.custom-calendly-container.minimized .avatar-badge {
    width: 60px;
    height: 60px;
}

/* Avatar lift on hover (transition only) */
.calendly-avatar-group:hover .avatar-badge {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}
