/**
 * Lucky Puppy Animal Rescue - Visitor LiveChat Widget Styles (/assets/css/chat.css)
 * Fixed-position, zero layout shift, accessible 44px touch targets, responsive mobile sheet.
 */

.lp-chat-widget {
    position: fixed;
    bottom: calc(var(--cookie-offset, 0px) + env(safe-area-inset-bottom, 0px) + 1.25rem + 44px + 12px);
    right: 1.25rem;
    z-index: 1040;
    font-family: var(--font-system, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
    transition: bottom 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
    .lp-chat-widget {
        transition: none;
    }
}

.lp-chat-launcher {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
    min-width: 48px;
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: 50rem;
    background-color: var(--color-primary, #b45309);
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.22);
    transition: background-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.lp-chat-launcher:hover,
.lp-chat-launcher:focus {
    background-color: var(--color-primary-hover, #92400e);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.28);
}

.lp-chat-launcher:focus-visible {
    outline: 3px solid #1e293b;
    outline-offset: 2px;
}

.lp-chat-launcher-icon {
    font-size: 1.15rem;
    line-height: 1;
}

.lp-chat-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 50rem;
    background-color: #dc2626;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Chat Panel Dialog */
.lp-chat-panel {
    position: fixed;
    bottom: calc(var(--cookie-offset, 0px) + env(safe-area-inset-bottom, 0px) + 1.25rem + 44px + 12px + 52px);
    right: 1.25rem;
    width: 370px;
    max-width: calc(100% - 2.5rem);
    box-sizing: border-box;
    height: 540px;
    max-height: calc(100vh - 6.5rem);
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 1rem;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1065;
    transition: bottom 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
    .lp-chat-panel {
        transition: none;
    }
}

/* Full-screen sheet on phones */
@media (max-width: 575.98px) {
    .lp-chat-panel {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
    }
}

.lp-chat-header {
    background-color: var(--color-primary, #b45309);
    color: #ffffff;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-shrink: 0;
}

.lp-chat-header-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
}

.lp-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.lp-chat-reconnecting {
    font-size: 0.75rem;
    background-color: rgba(0, 0, 0, 0.25);
    color: #fef3c7;
    padding: 0.15rem 0.5rem;
    border-radius: 50rem;
    font-weight: 600;
}

.lp-chat-minimize-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.lp-chat-minimize-btn:hover,
.lp-chat-minimize-btn:focus {
    background-color: rgba(255, 255, 255, 0.18);
}

.lp-chat-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: #faf8f5;
    min-height: 0;
}

.lp-chat-form-wrap {
    padding: 1rem;
    overflow-y: auto;
    flex: 1 1 auto;
}

.lp-chat-offline-banner {
    background-color: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: 0.5rem;
    padding: 0.65rem 0.85rem;
    font-size: 0.825rem;
    margin-bottom: 0.85rem;
}

.lp-chat-submit-btn {
    min-height: 44px;
    font-weight: 600;
}

/* Conversation Area */
.lp-chat-conversation {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.lp-chat-notified-bar {
    background-color: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    color: #475569;
    font-size: 0.78rem;
    text-align: center;
    padding: 0.4rem 0.75rem;
    font-weight: 500;
    flex-shrink: 0;
}

.lp-chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-height: 0;
}

.lp-chat-msg {
    max-width: 85%;
    display: flex;
    flex-direction: column;
}

.lp-chat-msg-visitor {
    align-self: flex-end;
}

.lp-chat-msg-admin {
    align-self: flex-start;
}

.lp-chat-msg-system {
    align-self: center;
    max-width: 94%;
}

.lp-chat-bubble {
    padding: 0.55rem 0.8rem;
    border-radius: 0.85rem;
    font-size: 0.875rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.lp-chat-msg-visitor .lp-chat-bubble {
    background-color: var(--color-primary, #b45309);
    color: #ffffff;
    border-bottom-right-radius: 0.2rem;
}

.lp-chat-msg-admin .lp-chat-bubble {
    background-color: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 0.2rem;
}

.lp-chat-msg-system .lp-chat-bubble {
    background-color: #e2e8f0;
    color: #334155;
    font-size: 0.78rem;
    font-style: italic;
    padding: 0.35rem 0.75rem;
    border-radius: 50rem;
    text-align: center;
}

.lp-chat-msg-meta {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 0.15rem;
    padding: 0 0.2rem;
}

.lp-chat-msg-visitor .lp-chat-msg-meta {
    text-align: right;
}

.lp-chat-footer {
    background-color: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 0.65rem 0.75rem;
    flex-shrink: 0;
}

.lp-chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.lp-chat-input {
    flex: 1 1 auto;
    resize: none;
    max-height: 96px;
    font-size: 0.875rem;
}

.lp-chat-send-btn {
    min-width: 48px;
    min-height: 44px;
    font-weight: 600;
    flex-shrink: 0;
}

.lp-chat-footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.35rem;
}

.lp-chat-end-btn {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0.25rem 0.5rem;
    border: none;
    background: transparent;
    color: #dc2626;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.lp-chat-end-btn:hover,
.lp-chat-end-btn:focus {
    color: #991b1b;
}

.lp-chat-new-btn {
    min-height: 44px;
    font-weight: 600;
}

@media print {
    .lp-chat-widget,
    .lp-chat-panel {
        display: none !important;
    }
}

