/* ============================================================
   Gregory Virtual Assistant — Chat Widget CSS
   ProtectYourData™ Theme
   ============================================================ */

/* --- CSS Variables injected by PHP/Admin --- */
:root {
    --va-accent: var(--pyd-va-accent, #1a56db);
    --va-accent-dark: #1040b0;
    --va-accent-light: #e8f0fe;
    --va-bg: #ffffff;
    --va-text: #1e293b;
    --va-muted: #64748b;
    --va-border: #e2e8f0;
    --va-radius: 16px;
    --va-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.1);
    --va-bubble-size: 68px;
}

/* --- Floating Bubble Button --- */
#pyd-va-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: var(--va-bubble-size);
    height: var(--va-bubble-size);
    border-radius: 50%;
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    box-shadow: 0 8px 30px rgba(26, 86, 219, 0.45);
    border: none;
    padding: 0;
    background: transparent;
    animation: pyd-bubble-pulse 3s ease-in-out infinite;
}

#pyd-va-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(26, 86, 219, 0.55);
}

#pyd-va-bubble.pyd-va-open {
    animation: none;
    transform: scale(0.92);
}

@keyframes pyd-bubble-pulse {
    0%, 100% { box-shadow: 0 8px 30px rgba(26, 86, 219, 0.45); }
    50% { box-shadow: 0 8px 40px rgba(26, 86, 219, 0.7), 0 0 0 8px rgba(26, 86, 219, 0.1); }
}

#pyd-va-bubble img.va-bubble-avatar {
    width: var(--va-bubble-size);
    height: var(--va-bubble-size);
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    display: block;
}

/* --- Online Indicator Dot --- */
#pyd-va-bubble .va-online-dot {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: pyd-dot-blink 2s ease-in-out infinite;
}

@keyframes pyd-dot-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* --- Greeting Bubble --- */
#pyd-va-greeting {
    position: fixed;
    bottom: 108px;
    right: 28px;
    background: #fff;
    border-radius: 16px 16px 4px 16px;
    padding: 14px 18px;
    max-width: 280px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 99998;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    color: var(--va-text);
    line-height: 1.5;
    border: 1px solid var(--va-border);
    animation: pyd-greeting-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    display: none;
}

#pyd-va-greeting.visible {
    display: block;
}

@keyframes pyd-greeting-in {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

#pyd-va-greeting .va-greeting-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--va-muted);
    font-size: 14px;
    line-height: 1;
    padding: 2px;
}

#pyd-va-greeting .va-greeting-name {
    font-weight: 700;
    color: var(--va-accent);
    display: block;
    margin-bottom: 4px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Chat Panel --- */
#pyd-va-panel {
    position: fixed;
    bottom: 108px;
    right: 28px;
    width: 380px;
    max-height: 600px;
    background: var(--va-bg);
    border-radius: var(--va-radius);
    box-shadow: var(--va-shadow);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--va-border);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    font-family: 'Inter', sans-serif;
}

#pyd-va-panel.pyd-va-visible {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* --- Panel Header --- */
.va-panel-header {
    background: linear-gradient(135deg, var(--va-accent) 0%, var(--va-accent-dark) 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.va-header-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.va-header-avatar-wrap img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.4);
    display: block;
}

.va-header-avatar-wrap .va-online-badge {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid var(--va-accent);
}

.va-header-info {
    flex: 1;
    min-width: 0;
}

.va-header-name {
    font-weight: 700;
    font-size: 1rem;
    display: block;
    margin-bottom: 2px;
}

.va-header-status {
    font-size: 0.75rem;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.va-header-status::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    animation: pyd-dot-blink 2s ease-in-out infinite;
}

.va-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.va-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-size: 14px;
}

.va-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* --- Pre-Chat Form --- */
#pyd-va-prechat {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.va-prechat-intro {
    font-size: 0.875rem;
    color: var(--va-muted);
    line-height: 1.6;
    margin: 0;
}

.va-prechat-intro strong {
    color: var(--va-text);
    display: block;
    margin-bottom: 6px;
    font-size: 1rem;
}

.va-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.va-field label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--va-text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.va-field input {
    padding: 10px 14px;
    border: 1.5px solid var(--va-border);
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    color: var(--va-text);
    background: #f8fafc;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.va-field input:focus {
    border-color: var(--va-accent);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
    background: #fff;
}

.va-field input::placeholder {
    color: #94a3b8;
}

.va-start-btn {
    background: var(--va-accent);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: background 0.2s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.va-start-btn:hover {
    background: var(--va-accent-dark);
    transform: translateY(-1px);
}

/* --- Chat Messages Area --- */
#pyd-va-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    display: none;
}

#pyd-va-messages::-webkit-scrollbar {
    width: 4px;
}

#pyd-va-messages::-webkit-scrollbar-track {
    background: transparent;
}

#pyd-va-messages::-webkit-scrollbar-thumb {
    background: var(--va-border);
    border-radius: 4px;
}

/* --- Message Bubbles --- */
.va-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 88%;
    animation: pyd-msg-in 0.3s ease forwards;
}

@keyframes pyd-msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.va-msg.va-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.va-msg.va-msg-bot {
    align-self: flex-start;
}

.va-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1.5px solid var(--va-border);
}

.va-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--va-text);
}

.va-msg-bot .va-msg-bubble {
    background: #f1f5f9;
    border-bottom-left-radius: 4px;
}

.va-msg-user .va-msg-bubble {
    background: var(--va-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* --- Typing Indicator --- */
.va-typing-indicator {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    align-self: flex-start;
    animation: pyd-msg-in 0.3s ease forwards;
}

.va-typing-dots {
    background: #f1f5f9;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.va-typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--va-muted);
    border-radius: 50%;
    animation: pyd-bounce 1.2s ease-in-out infinite;
}

.va-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.va-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pyd-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* --- System Messages --- */
.va-msg-system {
    text-align: center;
    font-size: 0.75rem;
    color: var(--va-muted);
    background: #f8fafc;
    border: 1px solid var(--va-border);
    border-radius: 20px;
    padding: 6px 14px;
    align-self: center;
    font-style: italic;
}

/* --- Panel Footer / Input --- */
.va-panel-footer {
    border-top: 1px solid var(--va-border);
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
    background: #fff;
}

#pyd-va-input-area {
    display: none;
}

#pyd-va-input-area.visible {
    display: flex;
    width: 100%;
    gap: 10px;
    align-items: center;
}

#pyd-va-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--va-border);
    border-radius: 24px;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    color: var(--va-text);
    resize: none;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    height: 44px;
    max-height: 120px;
    overflow-y: auto;
    background: #f8fafc;
}

#pyd-va-input:focus {
    border-color: var(--va-accent);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
    background: #fff;
}

#pyd-va-input::placeholder {
    color: #94a3b8;
}

#pyd-va-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--va-accent);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}

#pyd-va-send:hover {
    background: var(--va-accent-dark);
    transform: scale(1.08);
}

#pyd-va-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* --- Quick Actions Bar --- */
.va-quick-actions {
    padding: 8px 16px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.va-quick-btn {
    background: var(--va-accent-light);
    color: var(--va-accent);
    border: 1px solid rgba(26, 86, 219, 0.2);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    white-space: nowrap;
}

.va-quick-btn:hover {
    background: var(--va-accent);
    color: #fff;
    transform: translateY(-1px);
}

/* --- Escalation Banner --- */
.va-escalation-banner {
    margin: 8px 16px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.8rem;
    color: #92400e;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.va-escalation-btn {
    background: #f97316;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    transition: background 0.2s;
}

.va-escalation-btn:hover { background: #ea580c; }

/* --- Footer Branding --- */
.va-panel-branding {
    padding: 6px 16px 10px;
    text-align: center;
    font-size: 0.68rem;
    color: #94a3b8;
    flex-shrink: 0;
}

.va-panel-branding a {
    color: var(--va-accent);
    text-decoration: none;
    font-weight: 600;
}

/* --- Responsive Mobile --- */
@media (max-width: 480px) {
    #pyd-va-panel {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 90px;
        max-height: 80vh;
    }

    #pyd-va-bubble {
        bottom: 16px;
        right: 16px;
    }

    #pyd-va-greeting {
        right: 16px;
        max-width: calc(100vw - 120px);
    }
}
