/**
 * PrivacyGuard WP - AI Chat Widget Styles
 * @since 2.1.0
 */

/* ========================================
   FAB (Floating Action Button)
   ======================================== */
.pgwp-chat-fab {
    position: fixed;
    bottom: 24px;
    z-index: 99998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37,99,235,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pgwp-chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(37,99,235,0.45);
}
.pgwp-chat-fab-visible {
    opacity: 1;
    transform: scale(1);
}
.pgwp-chat-fab svg { pointer-events: none; }
.pgwp-chat-bottom-right .pgwp-chat-fab,
.pgwp-chat-fab.pgwp-chat-bottom-right { right: 24px; }
.pgwp-chat-bottom-left .pgwp-chat-fab,
.pgwp-chat-fab.pgwp-chat-bottom-left { left: 24px; }

/* ========================================
   WIDGET CONTAINER
   ======================================== */
.pgwp-chat-widget {
    position: fixed;
    bottom: 24px;
    z-index: 99999;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 100px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}
.pgwp-chat-widget.pgwp-chat-open {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.pgwp-chat-bottom-right,
.pgwp-chat-widget.pgwp-chat-bottom-right { right: 24px; }
.pgwp-chat-bottom-left,
.pgwp-chat-widget.pgwp-chat-bottom-left { left: 24px; }

/* ========================================
   HEADER
   ======================================== */
.pgwp-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
}
.pgwp-chat-title {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
}
.pgwp-chat-minimize {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    transition: background 0.2s;
    cursor: pointer;
}
.pgwp-chat-minimize:hover {
    background: rgba(255,255,255,0.2);
}

/* ========================================
   BODY (Messages area)
   ======================================== */
.pgwp-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    scroll-behavior: smooth;
}
.pgwp-chat-body::-webkit-scrollbar { width: 5px; }
.pgwp-chat-body::-webkit-scrollbar-track { background: transparent; }
.pgwp-chat-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ========================================
   MESSAGES
   ======================================== */
.pgwp-chat-msg {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    animation: pgwp-msg-in 0.25s ease;
}
@keyframes pgwp-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pgwp-chat-msg-user {
    align-items: flex-end;
}
.pgwp-chat-msg-assistant {
    align-items: flex-start;
}
.pgwp-chat-msg-error {
    align-items: center;
}

.pgwp-chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.pgwp-chat-msg-user .pgwp-chat-bubble {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.pgwp-chat-msg-assistant .pgwp-chat-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.pgwp-chat-msg-error .pgwp-chat-bubble {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    font-size: 13px;
}

.pgwp-chat-bubble a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.pgwp-chat-msg-user .pgwp-chat-bubble a {
    color: #bfdbfe;
}

.pgwp-chat-bubble strong {
    font-weight: 600;
}

.pgwp-chat-li {
    display: block;
    padding-left: 12px;
    position: relative;
}
.pgwp-chat-li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #94a3b8;
}

.pgwp-chat-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 3px;
    padding: 0 4px;
}

/* ========================================
   TYPING INDICATOR
   ======================================== */
.pgwp-chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px !important;
    min-height: auto;
}
.pgwp-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: pgwp-bounce 1.4s infinite ease-in-out;
}
.pgwp-chat-typing span:nth-child(2) { animation-delay: 0.16s; }
.pgwp-chat-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes pgwp-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ========================================
   INPUT AREA
   ======================================== */
.pgwp-chat-input {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
    gap: 8px;
}
.pgwp-chat-input input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: #f8fafc;
    font-family: inherit;
}
.pgwp-chat-input input:focus {
    border-color: #2563eb;
    background: #fff;
}
.pgwp-chat-input input::placeholder {
    color: #94a3b8;
}
.pgwp-chat-input button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}
.pgwp-chat-input button:hover:not(:disabled) {
    background: #1d4ed8;
    transform: scale(1.05);
}
.pgwp-chat-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.pgwp-chat-input button svg {
    pointer-events: none;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 480px) {
    .pgwp-chat-widget {
        width: calc(100vw - 16px);
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
        bottom: 8px;
        right: 8px !important;
        left: 8px !important;
        border-radius: 12px;
    }
    .pgwp-chat-fab {
        bottom: 16px;
    }
    .pgwp-chat-fab.pgwp-chat-bottom-right { right: 16px; }
    .pgwp-chat-fab.pgwp-chat-bottom-left { left: 16px; }
}
