/* =====================================================
   PTC Chatbot Widget
   ===================================================== */

.ptc-chatbot {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1040;
    font-family: var(--font-family);
}

.ptc-chatbot-launcher {
    position: relative;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--white);
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(15, 45, 82, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.ptc-chatbot-launcher:hover,
.ptc-chatbot-launcher:focus-visible {
    transform: scale(1.06);
    box-shadow: 0 10px 32px rgba(0, 109, 119, 0.35);
    outline: none;
}

.ptc-chatbot-launcher-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ptc-chatbot.is-open .ptc-chatbot-icon-open {
    opacity: 0;
    transform: scale(0.6) rotate(-20deg);
    pointer-events: none;
}

.ptc-chatbot-icon-close {
    opacity: 0;
    transform: scale(0.6) rotate(20deg);
    pointer-events: none;
}

.ptc-chatbot.is-open .ptc-chatbot-icon-close {
    opacity: 1;
    transform: scale(1) rotate(0);
    pointer-events: auto;
}

.ptc-chatbot-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(242, 140, 40, 0.55);
    animation: ptcChatPulse 2.2s ease-out infinite;
    pointer-events: none;
}

.ptc-chatbot.is-open .ptc-chatbot-pulse {
    display: none;
}

@keyframes ptcChatPulse {
    0% { transform: scale(1); opacity: 0.8; }
    70% { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

.ptc-chatbot-panel {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: min(380px, calc(100vw - 28px));
    height: min(560px, calc(100vh - 120px));
    background: var(--white);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(15, 45, 82, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    border: 1px solid var(--gray-200);
}

.ptc-chatbot.is-open .ptc-chatbot-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ptc-chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 55%, var(--secondary) 100%);
    color: var(--white);
}

.ptc-chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.ptc-chatbot-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent-light);
}

.ptc-chatbot-title {
    margin: 0;
    font-size: 0.95rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.ptc-chatbot-status {
    margin: 2px 0 0;
    font-size: 0.75rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ptc-chatbot-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3ddc97;
    box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.25);
}

.ptc-chatbot-close {
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: var(--white);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.ptc-chatbot-close:hover,
.ptc-chatbot-close:focus-visible {
    background: rgba(255, 255, 255, 0.24);
    outline: none;
}

.ptc-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background:
        linear-gradient(180deg, rgba(244, 246, 248, 0.95) 0%, rgba(255, 255, 255, 0.98) 100%);
    scroll-behavior: smooth;
}

.ptc-chat-msg {
    display: flex;
    margin-bottom: 12px;
    animation: ptcChatIn 0.28s ease;
}

@keyframes ptcChatIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ptc-chat-msg--bot { justify-content: flex-start; }
.ptc-chat-msg--user { justify-content: flex-end; }

.ptc-chat-bubble {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.ptc-chat-msg--bot .ptc-chat-bubble {
    background: var(--white);
    color: var(--gray-800);
    border: 1px solid var(--gray-200);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.ptc-chat-msg--user .ptc-chat-bubble {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.ptc-chat-bubble a {
    color: var(--secondary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ptc-chat-msg--user .ptc-chat-bubble a {
    color: #fff;
}

.ptc-chat-typing {
    display: inline-flex;
    gap: 5px;
    padding: 12px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.ptc-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gray-400);
    animation: ptcChatDot 1.2s ease-in-out infinite;
}

.ptc-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.ptc-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ptcChatDot {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
    40% { transform: translateY(-4px); opacity: 1; }
}

.ptc-chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 14px 12px;
    background: transparent;
}

.ptc-chatbot-suggestions:not([hidden]) {
    display: flex;
}

.ptc-chat-chip {
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--primary);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1.3;
}

.ptc-chat-chip:hover,
.ptc-chat-chip:focus-visible {
    border-color: var(--secondary);
    color: var(--secondary);
    background: rgba(0, 109, 119, 0.06);
    outline: none;
}

.ptc-chatbot-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--gray-200);
    background: var(--white);
}

.ptc-chatbot-form input[type="text"] {
    flex: 1;
    border: 1px solid var(--gray-300);
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 0.9rem;
    outline: none;
    background: var(--gray-100);
    color: var(--gray-800);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ptc-chatbot-form input[type="text"]:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(0, 109, 119, 0.12);
    background: var(--white);
}

.ptc-chatbot-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.ptc-chatbot-send:hover,
.ptc-chatbot-send:focus-visible {
    background: var(--accent-dark);
    transform: scale(1.05);
    outline: none;
}

.ptc-chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ptc-chatbot-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    justify-content: center;
    padding: 8px 12px 10px;
    background: var(--gray-100);
    border-top: 1px solid var(--gray-200);
}

.ptc-chatbot-footer-link {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--gray-600);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px;
}

.ptc-chatbot-footer-link:hover {
    color: var(--secondary);
}

/* Keep back-to-top clear of the launcher */
.back-to-top {
    bottom: 100px;
}

/* Mobile */
@media (max-width: 575.98px) {
    .ptc-chatbot {
        bottom: 18px;
        right: 16px;
    }

    .ptc-chatbot-panel {
        position: fixed;
        bottom: 90px;
        right: 12px;
        left: 12px;
        width: auto;
        height: min(70vh, 540px);
    }

    .ptc-chatbot-launcher {
        width: 56px;
        height: 56px;
    }

    .back-to-top {
        bottom: 90px;
        right: 18px;
    }
}
