/* ========================================
   AI Support Chat Widget
   Launcher button styles are in style.css
   (loaded on every page). This file is
   lazy-loaded when the chat panel opens.
   ======================================== */

/* Shift panel up when cookie banner is visible */
body:has(.cookie-banner) #chat-panel {
    bottom: 158px;
}

/* Chat Panel */
#chat-panel {
    display: none;
    position: fixed;
    bottom: 92px;
    left: 24px;
    width: 380px;
    height: 520px;
    min-width: 300px;
    min-height: 300px;
    z-index: 9990;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    overflow: hidden;
}

#chat-panel.open {
    display: flex;
}

/* Resize handle - top-right corner (panel is on left) */
.chat-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nesw-resize;
    z-index: 10;
}

.chat-resize-handle::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 8px 0;
    border-color: transparent rgba(255, 255, 255, 0.4) transparent transparent;
}

#chat-panel.resizing {
    transition: none;
    user-select: none;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.chat-header-close {
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    padding: 4px;
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.chat-header-close:hover {
    opacity: 1;
}

/* Chat Notice */
.chat-notice {
    padding: 8px 16px;
    background: var(--light-grey);
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
    flex-shrink: 0;
    border-bottom: 1px solid var(--medium-grey);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

/* Message Bubbles */
.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.6;
    word-wrap: break-word;
}

.chat-msg-bot {
    align-self: flex-start;
    background: var(--light-grey);
    color: var(--text-dark);
}

.chat-msg-user {
    align-self: flex-end;
    background: var(--primary);
    color: var(--white);
}

.chat-msg-bot p {
    margin: 0 0 8px;
}

.chat-msg-bot p:last-child {
    margin-bottom: 0;
}

.chat-msg-bot strong {
    color: var(--text-dark);
    font-weight: 600;
}

.chat-msg-bot ul,
.chat-msg-bot ol {
    margin: 6px 0;
    padding-left: 20px;
}

.chat-msg-bot li {
    margin-bottom: 4px;
}

.chat-msg-bot a {
    color: var(--primary);
    text-decoration: underline;
}

.chat-msg-bot a:hover {
    color: var(--primary-dark);
}

/* Feedback Buttons */
.chat-feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.chat-feedback-text {
    font-size: 0.8rem;
    color: var(--text-light);
}

.chat-feedback-btn {
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--medium-grey);
    background: var(--white);
    color: var(--text-medium);
    font-family: inherit;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.chat-feedback-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.chat-feedback-thanks {
    font-size: 0.8rem;
    color: var(--text-light);
    font-style: italic;
}

/* Escalation Button */
.chat-escalate-wrap {
    padding: 4px 0;
}
.chat-escalate-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 8px 18px;
    background: var(--primary);
    color: var(--white) !important;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none !important;
    transition: background 0.2s ease;
}

.chat-escalate-btn:hover {
    background: var(--primary-dark);
    color: var(--white) !important;
}

/* Typing Indicator */
.chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--light-grey);
    border-radius: var(--radius-sm);
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
    animation: chatTyping 1.4s ease-in-out infinite;
}

.chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chatTyping {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* Input Area */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--medium-grey);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-dark);
    background: #f3f4f6;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.chat-input:focus {
    background: var(--white);
    box-shadow: 0 0 0 2px rgba(23, 52, 70, 0.15);
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

.chat-send:hover {
    background: var(--primary-dark);
}

.chat-send:disabled {
    background: var(--medium-grey);
    cursor: not-allowed;
}

.chat-send svg {
    width: 16px;
    height: 16px;
    fill: var(--white);
}

/* ========================================
   Responsive
   ======================================== */
/* On mobile/tablet (<=820px), the launcher redirects to chat-mobile.html
   instead of opening the panel, so no panel styles needed here. */
@media (max-width: 820px) {
    #chat-panel {
        display: none !important;
    }
}
