/* ── Public Ask Watchdog Chat Widget ────────────────────────────────── */
/* All classes prefixed with pa- to avoid conflicts with public.css */

/* ── Theme Variables ──────────────────────────────────────────────── */
:root {
    --pa-primary: #1a5276;
    --pa-primary-hover: #0d3a5c;
    --pa-primary-light: rgba(26, 82, 118, 0.1);
    --pa-bg: #fff;
    --pa-bg-alt: #f0f4f8;
    --pa-bg-input: #fff;
    --pa-text: #1a2332;
    --pa-text-muted: #64748b;
    --pa-text-placeholder: #94a3b8;
    --pa-border: #cbd5e1;
    --pa-border-light: #e2e8f0;
    --pa-border-lightest: #f1f5f9;
    --pa-chip-bg: #fff;
    --pa-chip-hover: #f0f4f8;
    --pa-table-header: #e8eef4;
    --pa-code-bg: rgba(0, 0, 0, 0.06);
    --pa-error-bg: #fef2f2;
    --pa-error-text: #991b1b;
    --pa-error-border: #fecaca;
    --pa-rate-bg: #fefce8;
    --pa-rate-text: #92400e;
    --pa-rate-border: #fde68a;
    --pa-pulse: #3b82f6;
    --pa-shadow: rgba(0, 0, 0, 0.2);
    --pa-shadow-hover: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] {
    --pa-primary: #3b82c4;
    --pa-primary-hover: #5a9fd4;
    --pa-primary-light: rgba(59, 130, 196, 0.15);
    --pa-bg: #1e1e30;
    --pa-bg-alt: #2a2a40;
    --pa-bg-input: #252538;
    --pa-text: #e2e8f0;
    --pa-text-muted: #94a3b8;
    --pa-text-placeholder: #64748b;
    --pa-border: #3d3d55;
    --pa-border-light: #2d2d45;
    --pa-border-lightest: #252538;
    --pa-chip-bg: #252538;
    --pa-chip-hover: #2d2d45;
    --pa-table-header: #2a2a40;
    --pa-code-bg: rgba(255, 255, 255, 0.08);
    --pa-error-bg: #3b1515;
    --pa-error-text: #fca5a5;
    --pa-error-border: #7f1d1d;
    --pa-rate-bg: #3b3010;
    --pa-rate-text: #fbbf24;
    --pa-rate-border: #78350f;
    --pa-pulse: #60a5fa;
    --pa-shadow: rgba(0, 0, 0, 0.4);
    --pa-shadow-hover: rgba(0, 0, 0, 0.5);
}

/* ── FAB (Floating Action Button) ──────────────────────────────────── */
.pa-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--z-public-fab);
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--pa-primary);
    color: #fff;
    border: none;
    border-radius: 28px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    box-shadow: 0 4px 16px var(--pa-shadow);
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.pa-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--pa-shadow-hover);
}

.pa-fab:active {
    transform: translateY(0);
}

.pa-fab-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.pa-fab-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.pa-fab-label {
    white-space: nowrap;
}

/* ── Chat Panel ────────────────────────────────────────────────────── */
.pa-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--z-public-panel);
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 48px);
    background: var(--pa-bg);
    border-radius: 16px;
    box-shadow: 0 8px 40px var(--pa-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.pa-panel-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ────────────────────────────────────────────────────────── */
.pa-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--pa-primary);
    color: #fff;
    flex-shrink: 0;
}

.pa-header-title {
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-sans);
}

.pa-header-subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 1px;
}

.pa-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: 6px;
    transition: background 0.15s;
}

.pa-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ── Messages ──────────────────────────────────────────────────────── */
.pa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.pa-msg {
    display: flex;
    max-width: 90%;
}

.pa-msg-user {
    align-self: flex-end;
}

.pa-msg-assistant,
.pa-msg-error {
    align-self: flex-start;
}

.pa-msg-text {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    font-family: var(--font-sans);
}

.pa-msg-user .pa-msg-text {
    background: var(--pa-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.pa-msg-assistant .pa-msg-text {
    background: var(--pa-bg-alt);
    color: var(--pa-text);
    border-bottom-left-radius: 4px;
}

.pa-msg-error .pa-msg-text {
    background: var(--pa-error-bg);
    color: var(--pa-error-text);
    border: 1px solid var(--pa-error-border);
    border-bottom-left-radius: 4px;
    font-size: 13px;
}

/* Markdown content styles */
.pa-msg-text h3 { font-size: 15px; font-weight: 700; margin: 8px 0 4px; }
.pa-msg-text h4 { font-size: 14px; font-weight: 600; margin: 6px 0 3px; }
.pa-msg-text p { margin: 0 0 8px; }
.pa-msg-text p:last-child { margin-bottom: 0; }
.pa-msg-text ul, .pa-msg-text ol { margin: 4px 0 8px 16px; padding: 0; }
.pa-msg-text li { margin: 2px 0; }
.pa-msg-text code {
    background: var(--pa-code-bg);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
}
.pa-msg-text strong { font-weight: 600; }

/* Tables in responses */
.pa-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin: 8px 0;
}
.pa-table th, .pa-table td {
    padding: 5px 8px;
    text-align: left;
    border-bottom: 1px solid var(--pa-border-light);
}
.pa-table th {
    font-weight: 600;
    background: var(--pa-table-header);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.pa-table tr:last-child td { border-bottom: none; }

/* Bill links */
.pa-bill-link {
    color: var(--pa-primary);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px dotted var(--pa-primary);
}
.pa-bill-link:hover {
    color: var(--pa-primary-hover);
    border-bottom-style: solid;
}

/* ── Thinking indicator ────────────────────────────────────────────── */
.pa-thinking .pa-thinking-text {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--pa-text-muted);
    font-style: italic;
    font-size: 13px;
}

.pa-dot-pulse {
    display: inline-flex;
    gap: 3px;
}
.pa-dot-pulse::before,
.pa-dot-pulse::after,
.pa-dot-pulse {
    position: relative;
}
/* Simple CSS dot animation */
.pa-dot-pulse::before { content: ''; }
.pa-dot-pulse::after { content: ''; }

@keyframes pa-pulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

.pa-thinking-text::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--pa-pulse);
    animation: pa-pulse 1.4s infinite ease-in-out both;
    animation-delay: 0s;
}

/* ── Suggestion Chips ──────────────────────────────────────────────── */
.pa-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

.pa-chip {
    background: var(--pa-chip-bg);
    border: 1px solid var(--pa-border);
    border-radius: 18px;
    padding: 7px 14px;
    font-size: 13px;
    font-family: var(--font-sans);
    color: var(--pa-primary);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.pa-chip:hover {
    background: var(--pa-chip-hover);
    border-color: var(--pa-primary);
}

/* ── Rate limit notice ─────────────────────────────────────────────── */
.pa-rate-notice {
    padding: 6px 16px;
    background: var(--pa-rate-bg);
    color: var(--pa-rate-text);
    font-size: 12px;
    text-align: center;
    border-top: 1px solid var(--pa-rate-border);
}

/* ── Input Area ────────────────────────────────────────────────────── */
.pa-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--pa-border-light);
    background: var(--pa-bg);
    flex-shrink: 0;
}

.pa-input {
    flex: 1;
    border: 1px solid var(--pa-border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--font-sans);
    resize: none;
    outline: none;
    min-height: 44px;
    background: var(--pa-bg-input);
    color: var(--pa-text);
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.15s;
}

.pa-input:focus {
    border-color: var(--pa-primary);
    box-shadow: 0 0 0 2px var(--pa-primary-light);
}

.pa-input::placeholder {
    color: var(--pa-text-placeholder);
}

.pa-send {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: var(--pa-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, opacity 0.15s;
}

.pa-send:hover:not(:disabled) {
    background: var(--pa-primary-hover);
}

.pa-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Footer ────────────────────────────────────────────────────────── */
.pa-footer {
    padding: 8px 16px;
    font-size: 12px;
    color: var(--pa-text-muted);
    text-align: center;
    border-top: 1px solid var(--pa-border-lightest);
    flex-shrink: 0;
}

.pa-footer a {
    color: var(--pa-primary);
    text-decoration: none;
}

/* ── Mobile (full-screen panel) ────────────────────────────────────── */
@media (max-width: 520px) {
    .pa-fab {
        bottom: 16px;
        right: 16px;
        padding: 10px 16px;
        font-size: 14px;
    }

    .pa-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .pa-panel-open {
        transform: translateY(0) scale(1);
    }

    .pa-suggestions {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .pa-chip {
        flex-shrink: 0;
    }
}

/* ── Reduced motion ────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .pa-fab,
    .pa-panel {
        transition: none;
    }
    .pa-thinking-text::before {
        animation: none;
        opacity: 1;
    }
}
