/* ==========================================================================
   Gold Chat — frontend widget
   Uses the theme design system: --accent #da8e90, --gold #c49451,
   --section-bg #fbe9df, fonts Cormorant Garamond / Jost.
   ========================================================================== */

.gchat-widget {
    --gc-accent: var(--accent, #da8e90);
    --gc-accent-dark: var(--accent-dark, #c47a7c);
    --gc-gold: var(--gold, #c49451);
    --gc-cream: var(--section-bg-light, #fdf3ed);
    --gc-cream-dark: var(--section-bg, #fbe9df);
    --gc-black: var(--black, #1a1a1a);
    --gc-font-heading: var(--font-heading, 'Cormorant Garamond', Georgia, serif);
    --gc-font-body: var(--font-body, 'Jost', 'Helvetica Neue', Arial, sans-serif);
    font-family: var(--gc-font-body);
    position: fixed;
    z-index: 99998;
    right: 0;
    bottom: 0;
    width: 0;
    height: 0;
}

.gchat-widget *,
.gchat-widget *::before,
.gchat-widget *::after {
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Launcher (sits above the theme's back-to-top button at bottom:30 right:30)
   -------------------------------------------------------------------------- */

.gchat-launcher {
    position: fixed;
    right: 26px;
    bottom: 92px;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gc-accent) 0%, var(--gc-gold) 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(196, 148, 81, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    z-index: 99998;
}

.gchat-launcher:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 30px rgba(218, 142, 144, 0.55);
}

.gchat-launcher svg {
    width: 26px;
    height: 26px;
    position: absolute;
    transition: opacity 0.2s ease, transform 0.25s ease;
}

.gchat-launcher .gchat-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}

.gchat-widget.gchat-open .gchat-launcher .gchat-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

.gchat-widget.gchat-open .gchat-launcher .gchat-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Teaser bubble */

.gchat-teaser {
    position: fixed;
    right: 94px;
    bottom: 100px;
    background: #fff;
    color: var(--gc-black);
    font-size: 14px;
    padding: 10px 30px 10px 16px;
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 6px 24px rgba(26, 26, 26, 0.14);
    z-index: 99997;
    animation: gchatTeaserIn 0.4s ease both;
    white-space: nowrap;
}

.gchat-teaser-close {
    position: absolute;
    top: 4px;
    right: 8px;
    border: none;
    background: none;
    color: var(--gray-light, #999);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 2px;
}

@keyframes gchatTeaserIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   Panel
   -------------------------------------------------------------------------- */

.gchat-panel {
    position: fixed;
    right: 26px;
    bottom: 162px;
    width: 372px;
    max-width: calc(100vw - 40px);
    height: 540px;
    max-height: calc(100vh - 200px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 14px 50px rgba(26, 26, 26, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.gchat-widget.gchat-open .gchat-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .gchat-panel,
    .gchat-launcher,
    .gchat-launcher svg {
        transition: none;
    }
    .gchat-teaser {
        animation: none;
    }
}

/* Header */

.gchat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(180deg, var(--gc-cream) 0%, #fff 100%);
    border-bottom: 1px solid var(--gc-cream-dark);
    flex-shrink: 0;
}

.gchat-header-brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.gchat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gc-black);
    color: var(--gc-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gchat-avatar svg {
    width: 22px;
    height: 22px;
}

.gchat-header-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.gchat-title {
    font-family: var(--gc-font-heading);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--gc-black);
}

.gchat-subtitle {
    font-size: 12px;
    color: var(--gray, #666);
    display: flex;
    align-items: center;
    gap: 5px;
}

.gchat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #7cbf7c;
    display: inline-block;
}

.gchat-close {
    border: none;
    background: none;
    color: var(--gray, #666);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    transition: background 0.2s ease, color 0.2s ease;
}

.gchat-close:hover {
    background: var(--gc-cream-dark);
    color: var(--gc-black);
}

.gchat-close svg {
    width: 18px;
    height: 18px;
}

/* Messages area */

.gchat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
    scrollbar-width: thin;
    scrollbar-color: var(--gc-cream-dark) transparent;
}

.gchat-msg {
    max-width: 84%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 16px;
    word-wrap: break-word;
    animation: gchatMsgIn 0.25s ease both;
}

@keyframes gchatMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gchat-msg-bot {
    align-self: flex-start;
    background: var(--gc-cream);
    color: var(--gc-black);
    border-bottom-left-radius: 4px;
}

.gchat-msg-bot a {
    color: var(--gc-gold);
    text-decoration: underline;
}

.gchat-msg-bot p {
    margin: 0 0 8px;
}

.gchat-msg-bot p:last-child {
    margin-bottom: 0;
}

.gchat-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--gc-accent) 0%, var(--gc-accent-dark) 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */

.gchat-typing {
    align-self: flex-start;
    background: var(--gc-cream);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 13px 16px;
    display: flex;
    gap: 4px;
}

.gchat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gc-gold);
    animation: gchatTyping 1.2s infinite ease-in-out;
}

.gchat-typing span:nth-child(2) { animation-delay: 0.15s; }
.gchat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes gchatTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Product results */

.gchat-products {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gchat-product {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--gc-cream-dark);
    border-radius: 12px;
    text-decoration: none;
    color: var(--gc-black);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.gchat-product:hover {
    border-color: var(--gc-gold);
    box-shadow: 0 4px 14px rgba(196, 148, 81, 0.18);
    transform: translateY(-1px);
}

.gchat-product img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    background: var(--gc-cream);
    flex-shrink: 0;
}

.gchat-product-info {
    min-width: 0;
}

.gchat-product-title {
    font-size: 13px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gchat-product-price {
    font-size: 13px;
    font-weight: 600;
    color: var(--gc-gold);
    margin-top: 3px;
}

.gchat-product-price del {
    color: var(--gray-light, #999);
    font-weight: 400;
    margin-right: 5px;
}

.gchat-more {
    align-self: flex-start;
    display: inline-block;
    font-size: 13px;
    color: var(--gc-gold);
    text-decoration: underline;
    margin: 2px 4px 0;
}

/* Fallback contact form (inside a bot bubble) */

.gchat-form {
    align-self: stretch;
    background: var(--gc-cream);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gchat-form-title {
    font-family: var(--gc-font-heading);
    font-size: 16px;
    font-weight: 600;
    color: var(--gc-black);
}

.gchat-form input,
.gchat-form textarea {
    width: 100%;
    border: 1px solid var(--gc-cream-dark);
    border-radius: 8px;
    padding: 9px 12px;
    font-family: var(--gc-font-body);
    font-size: 13px;
    color: var(--gc-black);
    background: #fff;
    outline: none;
    transition: border-color 0.2s ease;
}

.gchat-form input:focus,
.gchat-form textarea:focus {
    border-color: var(--gc-gold);
}

.gchat-form textarea {
    resize: vertical;
    min-height: 64px;
}

.gchat-form .gchat-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.gchat-form-error {
    font-size: 12px;
    color: #c0392b;
    display: none;
}

.gchat-form-submit {
    border: none;
    border-radius: 8px;
    background: var(--gc-black);
    color: #fff;
    font-family: var(--gc-font-body);
    font-size: 13px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 11px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.gchat-form-submit:hover {
    background: var(--gc-gold);
}

.gchat-form-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Quick-reply chips */

.gchat-chips {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 14px;
    border-top: 1px solid var(--gc-cream);
    background: #fff;
}

.gchat-chip {
    border: 1px solid var(--gc-gold);
    background: #fff;
    color: var(--gc-black);
    font-family: var(--gc-font-body);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 30px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.gchat-chip:hover {
    background: var(--gc-gold);
    color: #fff;
}

/* Input bar */

.gchat-inputbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--gc-cream-dark);
    background: #fff;
}

.gchat-input {
    flex: 1;
    border: 1px solid var(--gc-cream-dark);
    border-radius: 24px;
    padding: 10px 16px;
    font-family: var(--gc-font-body);
    font-size: 14px;
    color: var(--gc-black);
    outline: none;
    transition: border-color 0.2s ease;
    min-width: 0;
}

.gchat-input:focus {
    border-color: var(--gc-accent);
}

.gchat-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gc-accent) 0%, var(--gc-gold) 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gchat-send:hover {
    transform: scale(1.07);
    box-shadow: 0 4px 14px rgba(218, 142, 144, 0.4);
}

.gchat-send:disabled {
    opacity: 0.5;
    transform: none;
    box-shadow: none;
    cursor: default;
}

.gchat-send svg {
    width: 17px;
    height: 17px;
    margin-left: -2px;
}

/* --------------------------------------------------------------------------
   Mobile: full-height sheet
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
    .gchat-launcher {
        right: 18px;
        bottom: 88px;
        width: 52px;
        height: 52px;
    }

    .gchat-teaser {
        right: 80px;
        bottom: 96px;
        font-size: 13px;
    }

    .gchat-panel {
        right: 0;
        left: 0;
        bottom: 0;
        top: 0;
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .gchat-widget.gchat-open .gchat-launcher {
        display: none;
    }

    .gchat-header {
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .gchat-inputbar {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}
