/*
 * Shop Assistant widget.
 *
 * Every rule is scoped under .gwcchat and sets what it needs explicitly,
 * because this ships onto themes nobody here has seen. A widget that
 * inherits a theme's button padding looks broken on half the shops that
 * install it.
 */

/*
 * AN AUTHOR `display` BEATS THE `hidden` ATTRIBUTE.
 *
 * [hidden] { display: none } is a USER-AGENT rule, and any author rule that
 * sets display wins over it. `.gwcchat-panel { display: flex }` therefore
 * kept the closed panel laid out at its full 340px, so the widget's root box
 * was 340px wide with the 152px launch button sitting at the left of it —
 * putting the button 223px from the edge it is supposed to hug, while the
 * root itself was positioned perfectly.
 *
 * Scoped to this widget rather than set globally: it is our markup's
 * problem, not the theme's.
 */
.gwcchat [hidden] {
    display: none !important;
}

.gwcchat {
    position: fixed;
    right: 20px;
    bottom: 20px;
    /* Hug the right edge: the box is as wide as whatever is open, so a
       closed widget is launch-button width and an open one is panel width,
       and both end flush. */
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    z-index: 9999;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.45;
}

.gwcchat-launch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    border: 0;
    border-radius: 24px;
    background: #24313f;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
}

.gwcchat-launch:hover { background: #2f4152; }

.gwcchat-launch-icon { color: #f09546; font-size: 11px; }

.gwcchat-panel {
    display: flex;
    flex-direction: column;
    width: 340px;
    max-width: calc(100vw - 32px);
    height: 460px;
    max-height: calc(100vh - 120px);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 10px 34px rgba(0, 0, 0, .26);
}

.gwcchat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: #24313f;
    color: #fff;
    font-weight: 600;
}

.gwcchat-close {
    border: 0;
    background: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}

.gwcchat-log {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f6f8fa;
}

.gwcchat-msg {
    max-width: 85%;
    margin-bottom: 10px;
    padding: 9px 12px;
    border-radius: 12px;
    /* Long product names and URLs must wrap rather than widen the panel. */
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.gwcchat-msg--bot {
    background: #fff;
    border: 1px solid #e3e8ee;
    color: #24313f;
}

.gwcchat-msg--me {
    margin-left: auto;
    background: #24313f;
    color: #fff;
}

.gwcchat-msg--thinking { opacity: .55; letter-spacing: 2px; }

.gwcchat-form {
    display: flex;
    gap: 0;
    border-top: 1px solid #e3e8ee;
    background: #fff;
}

.gwcchat-form input {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 12px;
    border: 0;
    font-size: 14px;
    background: #fff;
    color: #24313f;
}

.gwcchat-form input:focus { outline: none; }

.gwcchat-form button {
    height: 44px;
    padding: 0 16px;
    border: 0;
    background: #f09546;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.gwcchat-form button:disabled { opacity: .55; cursor: default; }

@media (max-width: 420px) {
    .gwcchat { right: 12px; bottom: 12px; left: 12px; }
    .gwcchat-panel { width: 100%; height: 70vh; }
}
