:root {
    --cgem-green-dark: #0b5d1e;
    --cgem-green: #1f8a3b;
    --cgem-leaf: #88d66c;
    --cgem-sky: #eef8f3;
}

.cgem-ai-helper-dock {
    position: relative;
    width: 0;
    height: 0;
}

.cgem-ai-helper {
    position: fixed;
    bottom: 4.5rem;
    right: 1.5rem;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    color: #0b2a1a;
    max-width: min(360px, calc(100vw - 2rem));
}

.cgem-ai-helper__toggle {
    border: none;
    border-radius: 999px;
    padding: 0.65rem 1.25rem;
    color: #fff;
    /*    background: linear-gradient(135deg, var(--cgem-green-dark), var(--cgem-green));*/
    background-color: lightyellow;
    box-shadow: 0 8px 20px rgba(10, 76, 22, 0.35);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cgem-ai-helper__logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
}

.cgem-ai-helper__toggle .dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    background: var(--cgem-leaf);
}

.cgem-ai-helper__toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(10, 76, 22, 0.45);
}

.cgem-ai-helper__panel {
    margin-top: 0.75rem;
    width: min(340px, 90vw);
    height: 430px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(11, 53, 23, 0.3);
    border: 1px solid rgba(12, 93, 30, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(4px);
}

.cgem-ai-helper.open .cgem-ai-helper__panel {
    display: flex;
}

.cgem-ai-helper__panel header {
    padding: 1rem 1.15rem;
    background: linear-gradient(135deg, rgba(20, 123, 51, 0.9), rgba(4, 66, 23, 0.95));
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cgem-ai-helper__panel h4 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0.02em;
}

.cgem-ai-helper__close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.35rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

    .cgem-ai-helper__close:hover {
        opacity: 1;
    }

.cgem-ai-helper__messages {
    flex: 1;
    padding: 1rem 1.15rem;
    overflow-y: auto;
    background: var(--cgem-sky);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.cgem-ai-helper__message {
    padding: 0.65rem 0.8rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.35;
    box-shadow: 0 4px 12px rgba(13, 42, 24, 0.08);
}

    .cgem-ai-helper__message.user {
        background: #fff;
        align-self: flex-end;
        border-bottom-right-radius: 4px;
    }

    .cgem-ai-helper__message.assistant {
        background: rgba(34, 139, 65, 0.1);
        border-left: 3px solid var(--cgem-green);
        align-self: flex-start;
    }

    .cgem-ai-helper__message small {
        display: block;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: rgba(8, 32, 20, 0.65);
        margin-bottom: 0.15rem;
    }

.cgem-ai-helper__structured {
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

    .cgem-ai-helper__structured > div {
        background: rgba(255, 255, 255, 0.7);
        border-radius: 8px;
        padding: 0.3rem 0.45rem;
        border: 1px solid rgba(12, 93, 30, 0.12);
    }

    .cgem-ai-helper__structured small {
        font-size: 0.65rem;
        margin-bottom: 0.2rem;
        color: rgba(8, 32, 20, 0.7);
    }

    .cgem-ai-helper__structured ul {
        margin: 0.15rem 0 0 1rem;
        padding: 0;
    }

    .cgem-ai-helper__structured li {
        font-size: 0.8rem;
        line-height: 1.25;
        margin: 0.1rem 0;
    }

.cgem-ai-helper__form {
    padding: 0.9rem 1rem 1rem;
    border-top: 1px solid rgba(12, 93, 30, 0.12);
    background: #fff;
}

    .cgem-ai-helper__form textarea {
        width: 100%;
        border: 1px solid rgba(10, 73, 24, 0.2);
        border-radius: 10px;
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
        resize: none;
        min-height: 60px;
        font-family: inherit;
    }

        .cgem-ai-helper__form textarea:focus {
            outline: 2px solid rgba(22, 128, 52, 0.35);
        }

.cgem-ai-helper__actions {
    margin-top: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: rgba(8, 32, 20, 0.7);
}

.cgem-ai-helper__send {
    border: none;
    border-radius: 999px;
    padding: 0.45rem 1.3rem;
    color: #fff;
    background: linear-gradient(135deg, var(--cgem-green), #2ccc78);
    box-shadow: 0 8px 18px rgba(15, 80, 34, 0.35);
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

    .cgem-ai-helper__send[disabled] {
        opacity: 0.6;
        cursor: not-allowed;
    }

.cgem-ai-helper__note {
    margin: 0.4rem 0.75rem 0.75rem;
    font-size: 0.72rem;
    text-align: right;
    color: rgba(5, 30, 16, 0.6);
}

.cgem-ai-helper__ticket-actions {
    margin-top: 0.55rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.cgem-ai-helper__attachment {
    margin-top: 0.55rem;
    display: grid;
    gap: 0.3rem;
}

.cgem-ai-helper__attachment label {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    cursor: pointer;
    border: 1px solid rgba(12, 93, 30, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: #0b2a1a;
    padding: 0.38rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 700;
}

.cgem-ai-helper__attachment input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.cgem-ai-helper__attachment small {
    color: rgba(5, 30, 16, 0.62);
    font-size: 0.72rem;
}

.cgem-ai-helper__ticket-actions button,
.cgem-ai-helper__email-form button {
    border: none;
    border-radius: 999px;
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.cgem-ai-helper__ticket-confirm,
.cgem-ai-helper__email-form button {
    color: #fff;
    background: var(--cgem-green);
}

.cgem-ai-helper__ticket-cancel {
    color: #0b2a1a;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(12, 93, 30, 0.18) !important;
}

.cgem-ai-helper__ticket-actions button[disabled],
.cgem-ai-helper__email-form button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.cgem-ai-helper__email-form {
    margin-top: 0.6rem;
    display: grid;
    gap: 0.4rem;
}

.cgem-ai-helper__email-form input {
    width: 100%;
    border: 1px solid rgba(10, 73, 24, 0.2);
    border-radius: 8px;
    padding: 0.45rem 0.55rem;
    font-size: 0.85rem;
    font-family: inherit;
}

@media (max-width: 640px) {
    .cgem-ai-helper {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 1rem;
        align-items: center;
        max-width: none;
    }

    .cgem-ai-helper__panel {
        width: 100%;
        height: 60vh;
    }
}
