/* RG Chat Widget */
:root {
    --rg-primary: #7AC142;
    --rg-primary-dark: #5a9a32;
    --rg-secondary: #2C3E50;
    --rg-white: #ffffff;
    --rg-gray-light: #f8f9fa;
    --rg-gray: #6c757d;
    --rg-gray-dark: #343a40;
    --rg-shadow: 0 10px 40px rgba(0,0,0,0.15);
    --rg-radius: 16px;
}

/* Toggle Button */
.rg-chat-toggle {
    position: fixed;
    top: 20px;
    right: 24px;
    background: linear-gradient(135deg, var(--rg-primary) 0%, var(--rg-primary-dark) 100%);
    color: var(--rg-white);
    border: none;
    border-radius: 50px;
    padding: 14px 24px;
    cursor: pointer;
    box-shadow: var(--rg-shadow), 0 0 20px rgba(122, 193, 66, 0.3);
    z-index: 2147483646;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.rg-chat-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--rg-shadow), 0 0 30px rgba(122, 193, 66, 0.5);
}

.rg-toggle-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rg-ai-sparkle {
    font-size: 16px;
    animation: rg-sparkle 2s ease-in-out infinite;
}

.rg-chat-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.rg-toggle-label {
    font-size: 14px;
    font-weight: 600;
}

.rg-online-badge {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.rg-online-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #90EE90;
    border-radius: 50%;
    animation: rg-pulse-dot 2s ease-in-out infinite;
}

@keyframes rg-sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

@keyframes rg-pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.3); }
}

/* Chat Window */
.rg-chat-window {
    position: fixed;
    top: 20px;
    right: 24px;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 40px);
    background: var(--rg-white);
    border-radius: var(--rg-radius);
    box-shadow: var(--rg-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 2147483647 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.rg-chat-window.active {
    display: flex;
    animation: rg-window-appear 0.3s ease-out;
}

@keyframes rg-window-appear {
    from {
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Header - Clean single row */
.rg-chat-header {
    background: linear-gradient(135deg, var(--rg-primary) 0%, var(--rg-primary-dark) 100%);
    color: var(--rg-white);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

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

.rg-chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.rg-header-text {
    flex: 1;
    min-width: 0;
}

.rg-header-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rg-ai-badge {
    background: rgba(255,255,255,0.25);
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.rg-header-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 2px 0 0 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.rg-status-dot {
    width: 6px;
    height: 6px;
    background: #90EE90;
    border-radius: 50%;
    display: inline-block;
    animation: rg-pulse-dot 2s ease-in-out infinite;
}

.rg-header-actions {
    flex-shrink: 0;
}

/* Hide minimize button, only show close */
#rg-chat-minimize {
    display: none !important;
}

#rg-chat-close,
.rg-header-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: var(--rg-white);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#rg-chat-close:hover,
.rg-header-btn:hover {
    background: rgba(255,255,255,0.35);
    transform: scale(1.1);
}

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

/* Body */
.rg-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(180deg, var(--rg-gray-light) 0%, var(--rg-white) 100%);
}

.rg-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Messages */
.rg-message {
    display: flex;
    max-width: 85%;
    animation: rg-message-appear 0.3s ease-out;
}

@keyframes rg-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rg-message-user {
    align-self: flex-end;
    margin-left: auto;
}

.rg-message-assistant {
    align-self: flex-start;
}

.rg-message-bubble {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.rg-message-user .rg-message-bubble {
    background: linear-gradient(135deg, var(--rg-primary) 0%, var(--rg-primary-dark) 100%);
    color: var(--rg-white);
    border-bottom-right-radius: 6px;
}

.rg-message-assistant .rg-message-bubble {
    background: var(--rg-white);
    color: var(--rg-gray-dark);
    border-bottom-left-radius: 6px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    border: 1px solid rgba(0,0,0,0.05);
}

/* Typing Indicator */
.rg-typing-indicator .rg-message-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 16px 22px;
}

.rg-typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--rg-primary);
    border-radius: 50%;
    animation: rg-typing-bounce 1.4s ease-in-out infinite;
}

.rg-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.rg-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes rg-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* Footer */
.rg-chat-footer {
    padding: 16px 20px;
    background: var(--rg-white);
    border-top: 1px solid rgba(0,0,0,0.08);
}

.rg-chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--rg-gray-light);
    border-radius: 25px;
    padding: 8px 8px 8px 20px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.rg-chat-input-wrapper:focus-within {
    border-color: var(--rg-primary);
    background: var(--rg-white);
    box-shadow: 0 0 0 4px rgba(122, 193, 66, 0.1);
}

.rg-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    max-height: 100px;
    padding: 8px 0;
    font-family: inherit;
    color: var(--rg-gray-dark);
}

.rg-chat-input:focus {
    outline: none;
}

.rg-chat-input::placeholder {
    color: var(--rg-gray);
}

.rg-chat-send {
    background: linear-gradient(135deg, var(--rg-primary) 0%, var(--rg-primary-dark) 100%);
    border: none;
    color: var(--rg-white);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.rg-chat-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(122, 193, 66, 0.4);
}

.rg-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rg-chat-send svg {
    width: 20px;
    height: 20px;
}

.rg-chat-disclaimer {
    text-align: center;
    font-size: 12px;
    color: var(--rg-gray);
    margin-top: 12px;
}

.rg-chat-disclaimer a {
    color: var(--rg-primary-dark);
    text-decoration: none;
    font-weight: 500;
}

/* Position variants */
.rg-chat-bottom-left .rg-chat-toggle,
.rg-chat-bottom-left .rg-chat-window {
    right: auto;
    left: 24px;
}

/* Mobile */
@media (max-width: 480px) {
    .rg-chat-toggle {
        top: 80px;
        right: 16px;
        padding: 12px 20px;
    }
    
    .rg-chat-window {
        top: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .rg-chat-toggle,
    .rg-ai-sparkle,
    .rg-status-dot,
    .rg-online-badge::before {
        animation: none;
    }
    
    .rg-chat-window.active,
    .rg-message {
        animation: none;
    }
}

.rg-chat-toggle * {
    pointer-events: none;
}

/* Resizable window */
.rg-chat-window {
    resize: both;
    min-width: 320px;
    min-height: 400px;
    max-width: 600px;
    max-height: calc(100vh - 40px);
}

/* Custom resize handle */
.rg-chat-window::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 20px;
    height: 20px;
    cursor: sw-resize;
    background: linear-gradient(135deg, transparent 50%, var(--rg-gray) 50%, var(--rg-gray) 60%, transparent 60%, transparent 70%, var(--rg-gray) 70%, var(--rg-gray) 80%, transparent 80%);
    opacity: 0.3;
    border-bottom-left-radius: var(--rg-radius);
}

.rg-chat-window:hover::after {
    opacity: 0.5;
}

/* Remove native resize */
.rg-chat-window {
    resize: none;
}

/* Resize handles */
.rg-resize-handle {
    position: absolute;
    z-index: 10;
}

.rg-resize-n {
    top: 0;
    left: 10px;
    right: 10px;
    height: 8px;
    cursor: n-resize;
}

.rg-resize-s {
    bottom: 0;
    left: 10px;
    right: 10px;
    height: 8px;
    cursor: s-resize;
}

.rg-resize-e {
    right: 0;
    top: 10px;
    bottom: 10px;
    width: 8px;
    cursor: e-resize;
}

.rg-resize-w {
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 8px;
    cursor: w-resize;
}

.rg-resize-ne {
    top: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: ne-resize;
}

.rg-resize-nw {
    top: 0;
    left: 0;
    width: 16px;
    height: 16px;
    cursor: nw-resize;
}

.rg-resize-se {
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: se-resize;
}

.rg-resize-sw {
    bottom: 0;
    left: 0;
    width: 16px;
    height: 16px;
    cursor: sw-resize;
}

/* Visual indicator on corners */
.rg-resize-se::after,
.rg-resize-sw::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 12px;
    height: 12px;
    opacity: 0.3;
    background: 
        linear-gradient(135deg, transparent 30%, var(--rg-gray) 30%, var(--rg-gray) 40%, transparent 40%),
        linear-gradient(135deg, transparent 50%, var(--rg-gray) 50%, var(--rg-gray) 60%, transparent 60%),
        linear-gradient(135deg, transparent 70%, var(--rg-gray) 70%, var(--rg-gray) 80%, transparent 80%);
}

.rg-resize-se::after {
    right: 4px;
}

.rg-resize-sw::after {
    left: 4px;
    transform: scaleX(-1);
}

.rg-chat-window:hover .rg-resize-se::after,
.rg-chat-window:hover .rg-resize-sw::after {
    opacity: 0.5;
}