:root {
    --gtc-primary: #c9a646;
    --gtc-primary-dark: #a88a37;
    --gtc-bg: #ffffff;
    --gtc-bg-soft: #f5f5f5;
    --gtc-fg: #1a1a1a;
    --gtc-muted: #6c757d;
    --gtc-border: #e2e2e2;
    --gtc-visitor-bubble: #c9a646;
    --gtc-visitor-text: #ffffff;
    --gtc-agent-bubble: #f0f0f0;
    --gtc-agent-text: #1a1a1a;
    --gtc-system-text: #6c757d;
    --gtc-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    --gtc-radius: 12px;
    --gtc-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.gtc-root {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2147483000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--gtc-fg);
}

.gtc-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--gtc-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: var(--gtc-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--gtc-transition), background var(--gtc-transition);
    position: relative;
}

.gtc-launcher:hover {
    background: var(--gtc-primary-dark);
    transform: scale(1.05);
}

.gtc-launcher svg {
    width: 28px;
    height: 28px;
}

.gtc-launcher-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.gtc-launcher-badge.gtc-visible {
    display: flex;
}

.gtc-panel {
    width: 380px;
    height: 560px;
    background: var(--gtc-bg);
    border-radius: var(--gtc-radius);
    box-shadow: var(--gtc-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 78px;
    right: 0;
    transform: translateY(20px);
    opacity: 0;
    transition: transform var(--gtc-transition), opacity var(--gtc-transition);
}

.gtc-panel.gtc-open {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

.gtc-header {
    background: linear-gradient(135deg, var(--gtc-primary), var(--gtc-primary-dark));
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.gtc-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.gtc-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

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

.gtc-avatar-placeholder {
    font-weight: 700;
    font-size: 16px;
}

.gtc-header-text {
    min-width: 0;
}

.gtc-header-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gtc-header-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.gtc-header-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #43a047;
    display: inline-block;
}

.gtc-header-status.gtc-offline::before {
    background: #9e9e9e;
}

.gtc-close {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    opacity: 0.8;
    transition: opacity var(--gtc-transition);
}

.gtc-close:hover {
    opacity: 1;
}

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

.gtc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--gtc-bg-soft);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gtc-msg-row {
    display: flex;
    max-width: 85%;
}

.gtc-msg-row.gtc-visitor {
    align-self: flex-end;
    justify-content: flex-end;
}

.gtc-msg-row.gtc-agent {
    align-self: flex-start;
    justify-content: flex-start;
}

.gtc-msg-row.gtc-system {
    align-self: center;
    max-width: 95%;
}

.gtc-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    max-width: 100%;
    white-space: pre-wrap;
}

.gtc-msg-row.gtc-visitor .gtc-msg-bubble {
    background: var(--gtc-visitor-bubble);
    color: var(--gtc-visitor-text);
    border-bottom-right-radius: 4px;
}

.gtc-msg-row.gtc-agent .gtc-msg-bubble {
    background: var(--gtc-agent-bubble);
    color: var(--gtc-agent-text);
    border-bottom-left-radius: 4px;
}

.gtc-msg-row.gtc-system .gtc-msg-bubble {
    background: transparent;
    color: var(--gtc-system-text);
    font-size: 12px;
    font-style: italic;
    text-align: center;
    padding: 6px 0;
}

.gtc-msg-time {
    font-size: 10px;
    color: var(--gtc-muted);
    margin-top: 2px;
}

.gtc-msg-row.gtc-visitor .gtc-msg-time {
    text-align: right;
}

.gtc-typing {
    align-self: flex-start;
    background: var(--gtc-agent-bubble);
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 12px;
    color: var(--gtc-muted);
    font-style: italic;
    display: none;
}

.gtc-typing.gtc-visible {
    display: inline-block;
}

.gtc-input-bar {
    border-top: 1px solid var(--gtc-border);
    padding: 12px;
    background: var(--gtc-bg);
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.gtc-input {
    flex: 1;
    border: 1px solid var(--gtc-border);
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    max-height: 120px;
    font-family: inherit;
    background: var(--gtc-bg-soft);
    transition: border-color var(--gtc-transition);
}

.gtc-input:focus {
    border-color: var(--gtc-primary);
}

.gtc-btn {
    background: var(--gtc-primary);
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--gtc-transition);
}

.gtc-btn:hover {
    background: var(--gtc-primary-dark);
}

.gtc-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.gtc-btn svg {
    width: 18px;
    height: 18px;
}

.gtc-footer {
    padding: 6px 12px;
    text-align: center;
    font-size: 10px;
    color: var(--gtc-muted);
    background: var(--gtc-bg);
    border-top: 1px solid var(--gtc-border);
    flex-shrink: 0;
}

.gtc-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
    background: var(--gtc-bg-soft);
}

.gtc-form-intro {
    font-size: 14px;
    color: var(--gtc-muted);
    text-align: center;
    margin-bottom: 8px;
}

.gtc-form-label {
    font-size: 12px;
    color: var(--gtc-muted);
    margin-bottom: -8px;
}

.gtc-form input,
.gtc-form textarea {
    border: 1px solid var(--gtc-border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    background: var(--gtc-bg);
    font-family: inherit;
}

.gtc-form input:focus,
.gtc-form textarea:focus {
    border-color: var(--gtc-primary);
}

.gtc-form textarea {
    min-height: 80px;
    resize: vertical;
}

.gtc-form-submit {
    background: var(--gtc-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--gtc-transition);
}

.gtc-form-submit:hover {
    background: var(--gtc-primary-dark);
}

.gtc-form-error {
    color: #d32f2f;
    font-size: 12px;
    min-height: 16px;
    margin-top: -4px;
}

.gtc-toast {
    position: fixed;
    right: 20px;
    bottom: 100px;
    width: 320px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(27, 66, 153, 0.28);
    border-left: 4px solid var(--gtc-primary);
    padding: 12px 14px 12px 16px;
    z-index: 2147483001;
    cursor: pointer;
    transform: translateX(380px);
    opacity: 0;
    transition: transform 350ms cubic-bezier(0.4, 0, 0.2, 1), opacity 250ms;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.gtc-toast.gtc-toast-visible {
    transform: translateX(0);
    opacity: 1;
}

.gtc-toast-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--gtc-primary);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gtc-toast-body {
    flex: 1;
    min-width: 0;
}

.gtc-toast-title {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.gtc-toast-text {
    font-size: 12px;
    color: #4a4a4a;
    margin-top: 3px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gtc-toast-close {
    background: transparent;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

@media (max-width: 480px) {
    .gtc-toast {
        right: 10px;
        left: 10px;
        width: auto;
        bottom: 90px;
    }
}

@media (max-width: 480px) {
    .gtc-panel {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        max-height: 600px;
        right: 10px;
        bottom: 78px;
    }
    .gtc-root {
        bottom: 15px;
        right: 15px;
    }
}
