/* Publia Chatbot Widget Styles */
#publia-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Greeting Bubble */
.pcb-greeting {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 240px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    padding: 16px 18px 14px;
    display: none;
    pointer-events: none;
}

.pcb-greeting.visible {
    display: block;
    animation: pcb-greet-in 0.3s ease;
    pointer-events: auto;
}

@keyframes pcb-greet-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pcb-greeting-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: #9ca3af;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.pcb-greeting-close:hover {
    background: #6b7280;
}

.pcb-greeting-text {
    font-size: 14px;
    line-height: 1.5;
    color: #1f2937;
    margin-right: 20px;
}

.pcb-greeting-name {
    font-size: 12px;
    color: #6b7280;
    margin-top: 8px;
}

/* Toggle Button */
.pcb-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #1f2937;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.pcb-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.pcb-toggle svg {
    width: 28px;
    height: 28px;
}

.pcb-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Window */
.pcb-chat {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

.pcb-chat.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.pcb-header {
    padding: 14px 18px;
    background: #1f2937;
    color: white;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pcb-header-avatar {
    flex-shrink: 0;
}

.pcb-header-avatar img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
    object-fit: cover;
    background: white;
}

.pcb-title {
    flex: 1;
}

.pcb-title strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
}

.pcb-title span {
    font-size: 12px;
    opacity: 0.85;
}

.pcb-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.pcb-close:hover {
    background: rgba(255,255,255,0.2);
}

/* Intro / Lead-first form */
.pcb-intro {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    gap: 16px;
}

.pcb-intro-message {
    background: #f3f4f6;
    border-radius: 16px 16px 16px 4px;
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.6;
    color: #1f2937;
}

.pcb-intro-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pcb-intro-form input {
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.pcb-intro-form input:focus {
    border-color: #6b7280;
}

.pcb-intro-form button {
    padding: 13px;
    background: #1f2937;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.pcb-intro-form button:hover {
    opacity: 0.85;
}

/* Bot message with avatar */
.pcb-message-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.pcb-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: white;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
}

/* Messages */
.pcb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pcb-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.pcb-message.pcb-bot {
    background: #f3f4f6;
    color: #1f2937;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.pcb-message.pcb-bot ul {
    margin: 6px 0 6px 0;
    padding-left: 18px;
    list-style: none;
}

.pcb-message.pcb-bot ul li {
    position: relative;
    padding-left: 12px;
    margin-bottom: 5px;
    line-height: 1.5;
}

.pcb-message.pcb-bot ul li::before {
    content: '·';
    position: absolute;
    left: 0;
    color: #6b7280;
    font-weight: 700;
}

.pcb-message.pcb-bot ul + br {
    display: none;
}

.pcb-message.pcb-user {
    background: #22c55e;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.pcb-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
}

.pcb-typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

/* Input Area */
.pcb-input-area {
    display: flex;
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    gap: 8px;
}

.pcb-input-area input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.pcb-input-area input:focus {
    border-color: #6b7280;
}

.pcb-input-area button {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background: #1f2937;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
}

.pcb-input-area button:hover {
    opacity: 0.85;
}

.pcb-input-area button svg {
    width: 18px;
    height: 18px;
    display: block;
    stroke: white;
}

/* Lead Form */
.pcb-lead-form {
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.pcb-lead-form p {
    margin: 0 0 12px;
    font-size: 14px;
    color: #374151;
}

.pcb-lead-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.pcb-lead-form button {
    width: 100%;
    padding: 12px;
    background: #1f2937;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.pcb-lead-form button:hover {
    opacity: 0.85;
}

.pcb-lead-form button.pcb-skip {
    background: transparent;
    color: #6b7280;
}

.pcb-lead-form button.pcb-skip:hover {
    background: #e5e7eb;
}

/* Mobile Responsive */
@media (max-width: 640px) {
    #publia-chatbot-widget {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        pointer-events: none;
    }
    
    #publia-chatbot-widget > * {
        pointer-events: auto;
    }
    
    .pcb-toggle {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }
    
    .pcb-chat {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
        border-radius: 0;
        bottom: auto;
        right: auto;
    }
    
    .pcb-header {
        border-radius: 0;
        padding: 16px 20px;
        min-height: 60px;
    }
    
    .pcb-header-avatar img {
        width: 42px;
        height: 42px;
    }
    
    .pcb-title strong {
        font-size: 16px;
    }
    
    .pcb-messages {
        padding: 16px;
    }
    
    .pcb-message {
        max-width: 90%;
        font-size: 15px;
    }
    
    .pcb-input-area {
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    
    .pcb-input-area input {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
    
    .pcb-end-chat {
        padding: 14px;
        font-size: 14px;
    }
}

/* Scrollbar styling */
.pcb-messages::-webkit-scrollbar {
    width: 6px;
}

.pcb-messages::-webkit-scrollbar-track {
    background: transparent;
}

.pcb-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.pcb-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Links inside bot messages */
.pcb-message.pcb-bot a {
    color: #2563eb;
    text-decoration: underline;
    word-break: break-all;
}

.pcb-message.pcb-bot a:hover {
    color: #1d4ed8;
}

/* End Chat Button */
.pcb-end-chat {
    width: 100%;
    padding: 12px;
    background: #f3f4f6;
    border: none;
    border-top: 1px solid #e5e7eb;
    color: #6b7280;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.pcb-end-chat:hover {
    background: #e5e7eb;
    color: #374151;
}
