/* ==========================================================================
   Chat Widget — HD Contracting Solutions
   Relies on the CSS variables + fonts already defined in core.css:
   --primary, --secondary, --headerColor, --bodyTextColor,
   --bodyTextColorWhite, --bg04, --borderColor, --subFont, --titleFont, --bodyFont
   Load core.css BEFORE this file.
   ========================================================================== */

#cw-widget {
    position: fixed;
    z-index: 99999;
    right: clamp(1rem, 3vw, 1.5rem);
    bottom: clamp(1rem, 3vw, 1.5rem);
    font-family: var(--bodyFont);
}

/* -------------------- Launcher Button -------------------- */
#cw-widget .cw-launcher {
    width: 4rem;
    height: 4rem;
    border: none;
    display: flex;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    box-shadow: rgba(0, 0, 0, 0.25) 0px 8px 24px;
    border-radius: 50% 50% 0.25rem 50%;
    transition: transform 0.3s, background-color 0.3s;
    position: relative;
}

#cw-widget .cw-launcher:hover {
    background: #FD9749;
    transform: scale(1.06);
}

#cw-widget .cw-launcher svg {
    width: 1.75rem;
    height: 1.75rem;
    display: block;
}

#cw-widget .cw-launcher .cw-icon-close {
    display: none;
}

#cw-widget.cw-open .cw-launcher .cw-icon-chat {
    display: none;
}

#cw-widget.cw-open .cw-launcher .cw-icon-close {
    display: block;
}

#cw-widget .cw-badge {
    top: -0.25rem;
    right: -0.25rem;
    width: 1.375rem;
    height: 1.375rem;
    display: flex;
    font-size: 0.75rem;
    font-weight: 700;
    position: absolute;
    align-items: center;
    border-radius: 50%;
    justify-content: center;
    color: var(--headerColor);
    background: var(--secondary);
    font-family: var(--subFont);
    border: 2px solid var(--bg01, #FFF);
}

#cw-widget.cw-open .cw-badge {
    display: none;
}

/* -------------------- Panel -------------------- */
#cw-widget .cw-panel {
    right: 0;
    bottom: calc(4rem + 1rem);
    width: 23rem;
    opacity: 0;
    position: absolute;
    max-height: 34rem;
    overflow: hidden;
    background: #FFF;
    max-width: 90vw;
    visibility: hidden;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    transform: translateY(0.9375rem) scale(0.97);
    transform-origin: bottom right;
    box-shadow: rgba(0, 0, 0, 0.25) 0px 16px 48px;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

#cw-widget.cw-open .cw-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* -------------------- Panel Header -------------------- */
#cw-widget .cw-header {
    gap: 0.75rem;
    display: flex;
    flex: none;
    padding: 1.125rem 1.25rem;
    align-items: center;
    background: #1A1A1A;
}

#cw-widget .cw-avatar {
    width: 2.75rem;
    height: 2.75rem;
    flex: none;
    display: flex;
    font-weight: 700;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    font-family: var(--subFont);
    color: var(--headerColor);
    font-size: 1.0625rem;
}

#cw-widget .cw-header-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#cw-widget .cw-header-name {
    margin: 0;
    line-height: 1.3em;
    font-size: 1rem;
    font-weight: 700;
    color: var(--bodyTextColorWhite);
    font-family: var(--subFont);
}

#cw-widget .cw-header-status {
    gap: 0.375rem;
    display: flex;
    font-size: 0.8125rem;
    align-items: center;
    color: var(--bodyTextColorWhite);
    opacity: 0.75;
}

#cw-widget .cw-header-status:before {
    content: '';
    width: 0.5rem;
    height: 0.5rem;
    flex: none;
    display: block;
    border-radius: 50%;
    background: #4CD964;
}

#cw-widget .cw-close {
    border: none;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    flex: none;
    display: flex;
    margin-left: auto;
    align-items: center;
    background: transparent;
    justify-content: center;
    transition: opacity 0.3s;
    opacity: 0.7;
}

#cw-widget .cw-close:hover {
    opacity: 1;
}

#cw-widget .cw-close svg {
    width: 1.125rem;
    height: 1.125rem;
}

/* -------------------- Scrollable Body -------------------- */
#cw-widget .cw-body {
    padding: 1.25rem;
    overflow-y: auto;
    background: #F2F2F2;
}

/* Chat bubble intro message */
#cw-widget .cw-bubble-row {
    gap: 0.625rem;
    display: flex;
    margin-bottom: 1.125rem;
    align-items: flex-end;
}

#cw-widget .cw-bubble-avatar {
    width: 1.875rem;
    height: 1.875rem;
    flex: none;
    display: flex;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    font-family: var(--subFont);
    color: var(--headerColor);
}

#cw-widget .cw-bubble {
    padding: 0.75rem 1rem;
    line-height: 1.45em;
    background: #FFF;
    max-width: 82%;
    font-size: 0.875rem;
        color: #1A1A1A;
    border-radius: 0.25rem 1rem 1rem 1rem;
    box-shadow: rgba(149, 157, 165, 0.15) 0px 4px 12px;
}

/* -------------------- Form -------------------- */
#cw-widget .cw-form {
    gap: 0.875rem;
    display: flex;
    flex-direction: column;
}

#cw-widget .cw-topper {
    display: block;
    font-weight: 700;
    line-height: 1.2em;
    letter-spacing: .08em;
    color: var(--secondary);
    margin-bottom: 0.125rem;
    text-transform: uppercase;
    font-family: var(--subFont);
    font-size: 0.75rem;
}

#cw-widget .cw-form-title {
    margin: 0 0 0.875rem 0;
    font-weight: 900;
    line-height: 1.25em;
    color: var(--headerColor);
    font-family: var(--titleFont);
    font-size: 1.1875rem;
    text-transform: uppercase;
}

#cw-widget .cw-flex {
    gap: 0.875rem;
    display: flex;
}

#cw-widget .cw-label {
    gap: 0.25rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    color: #1A1A1A;
    font-family: var(--bodyFont);
    font-size: 0.8125rem;
}

#cw-widget .cw-input {
    padding: 0;
    width: 100%;
    border: 1px solid var(--borderColor);
    height: 2.875rem;
    font-size: 0.9375rem;
    color: #1A1A1A;
    background: #FFF;
    padding-left: 1rem;
    border-radius: 0.5rem;
    box-sizing: border-box;
    font-family: var(--bodyFont);
    transition: border-color 0.3s;
}

#cw-widget .cw-input:focus {
    outline: none;
    border-color: var(--primary);
}

#cw-widget .cw-input::placeholder {
    opacity: 0.6;
    color: #767676;
}

#cw-widget .cw-textarea {
    min-height: 5rem;
    resize: vertical;
    padding-top: 0.75rem;
    font-family: inherit;
}

#cw-widget .cw-consent {
    gap: 0.5rem;
    display: flex;
    line-height: 1.45em;
    align-items: flex-start;
    font-size: 0.75rem;
    color: var(--bodyTextColor);
    font-family: var(--bodyFont);
}

#cw-widget .cw-checkbox {
    width: 1rem;
    height: 1rem;
    flex: none;
    margin-top: 0.125rem;
    accent-color: var(--primary);
}

#cw-widget .cw-submit {
    border: none;
    width: 100%;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 700;
    padding: 0 1.5rem;
    text-align: center;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    background: var(--primary);
    font-family: var(--subFont);
    border-radius: 0 0.75rem 0 0.75rem;
    color: var(--bodyTextColorWhite);
    line-height: 3rem;
    transition: background-color 0.3s;
    margin-top: 0.25rem;
}

#cw-widget .cw-submit:hover {
    background: #FD9749;
}

#cw-widget .cw-footer-links {
    margin: 0.5rem 0 0 0;
    text-align: center;
    font-size: 0.6875rem;
    color: var(--bodyTextColor);
    font-family: var(--bodyFont);
}

#cw-widget .cw-footer-links a {
    color: var(--bodyTextColor);
    text-decoration: underline;
}

/* Success state */
#cw-widget .cw-success {
    display: none;
    padding: 1.5rem 0.5rem;
    text-align: center;
}

#cw-widget .cw-success.cw-active {
    display: block;
}

#cw-widget .cw-form.cw-hidden {
    display: none;
}

#cw-widget .cw-success svg {
    width: 2.75rem;
    height: 2.75rem;
    margin-bottom: 0.75rem;
}

#cw-widget .cw-success h3 {
    margin: 0 0 0.375rem 0;
    font-family: var(--subFont);
    color: var(--headerColor);
    font-size: 1.0625rem;
}

#cw-widget .cw-success p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--bodyTextColor);
    font-family: var(--bodyFont);
}

/* -------------------- Scrollbar -------------------- */
#cw-widget .cw-body::-webkit-scrollbar {
    width: 0.375rem;
}

#cw-widget .cw-body::-webkit-scrollbar-thumb {
    background: var(--borderColor);
    border-radius: 1rem;
}

/* -------------------- Dark Mode -------------------- */
/* body.dark-mode #cw-widget .cw-panel {
    background: var(--medium, #2A2A2A);
}

body.dark-mode #cw-widget .cw-body {
    background: var(--dark, #1A1A1A);
}

body.dark-mode #cw-widget .cw-bubble {
    background: var(--medium, #2A2A2A);
    color: var(--bodyTextColorWhite);
}

body.dark-mode #cw-widget .cw-label,
body.dark-mode #cw-widget .cw-form-title {
    color: var(--bodyTextColorWhite);
}

body.dark-mode #cw-widget .cw-input {
    background: var(--dark, #1A1A1A);
    border-color: #444;
    color: var(--bodyTextColorWhite);
} */

/* -------------------- Mobile -------------------- */
@media only screen and (max-width: 30rem) {
    #cw-widget .cw-panel {
        right: 0;
        bottom: calc(4rem + 0.75rem);
        width: 92vw;
        max-height: 75vh;
    }
}
