/* ============================================================
   ASK IH — Floating Chat Widget Styles
   ============================================================
   Companion to ai-chat.js + AskIH.ashx (this folder).
   Uses CSS custom properties --red and --dark-red from the host
   site. If those are not defined, the chat falls back to the
   defaults below.
   ============================================================ */
:root {
    --ih-chat-red: var(--red, #a11e23);
    --ih-chat-dark-red: var(--dark-red, #7d1419);
}

@keyframes ihChatBtnFadeIn { to { opacity: 1; } }
#ih-chat-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9998;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--ih-chat-red);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    opacity: 0;
    animation: ihChatBtnFadeIn 0.4s ease 1.5s forwards;
    transition: background 0.2s, transform 0.2s, opacity 0.25s;
}
#ih-chat-btn:hover,
#ih-chat-btn.ih-chat-visible {
    opacity: 1;
}
#ih-chat-btn:hover { background: var(--ih-chat-dark-red); transform: scale(1.07); }
#ih-chat-btn .ih-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #fff;
    color: var(--ih-chat-red);
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    padding: 2px 5px;
    border-radius: 10px;
    line-height: 1.4;
    text-transform: uppercase;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

#ih-chat-panel {
    position: fixed;
    bottom: 100px;
    right: 28px;
    z-index: 9999;
    width: 340px;
    max-width: calc(100vw - 40px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.92) translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
#ih-chat-panel.ih-chat-open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

#ih-chat-header {
    background: var(--ih-chat-red);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
#ih-chat-header .ih-chat-avatar {
    width: 34px;
    height: 34px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
#ih-chat-header .ih-chat-title { font-size: 0.9rem; font-weight: 700; }
#ih-chat-header .ih-chat-subtitle { font-size: 0.72rem; opacity: 0.85; }
#ih-chat-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.8;
    padding: 4px;
    line-height: 1;
}
#ih-chat-close:hover { opacity: 1; }

#ih-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 220px;
    max-height: 340px;
    background: #fafafa;
}

.ih-chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
}
.ih-chat-msg--bot { align-self: flex-start; }
.ih-chat-msg--user { align-self: flex-end; }

.ih-chat-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.5;
}
.ih-chat-msg--bot .ih-chat-bubble {
    background: #fff;
    color: #1a1a1a;
    border: 1px solid rgba(0,0,0,0.08);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.ih-chat-msg--user .ih-chat-bubble {
    background: #2d3748;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ih-chat-msg--bot .ih-chat-bubble a { color: var(--ih-chat-red); text-decoration: underline; }
.ih-chat-bubble ul, .ih-chat-bubble ol { margin: 4px 0; padding-left: 18px; }
.ih-chat-bubble li { margin-bottom: 2px; }
.ih-chat-bubble p { margin: 0 0 6px; }
.ih-chat-bubble p:last-child { margin-bottom: 0; }

.ih-chat-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}
.ih-chat-typing span {
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    animation: ihTyping 1.2s infinite;
}
.ih-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.ih-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ihTyping {
    0%, 60%, 100% { transform: translateY(0); background: #ccc; }
    30% { transform: translateY(-5px); background: var(--ih-chat-red); }
}

#ih-chat-footer {
    padding: 12px;
    border-top: 1px solid rgba(0,0,0,0.08);
    display: flex;
    gap: 8px;
    background: #fff;
}
#ih-chat-input {
    flex: 1;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.85rem;
    outline: none;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s;
}
#ih-chat-input:focus { border-color: var(--ih-chat-red); }
#ih-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ih-chat-red);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: background 0.2s;
}
#ih-chat-send:hover { background: var(--ih-chat-dark-red); }
#ih-chat-send:disabled { background: #ccc; cursor: default; }

/* Input wrap + character counter */
#ih-chat-input-wrap { flex: 1; position: relative; }
#ih-chat-input { flex: none; width: 100%; box-sizing: border-box; padding-right: 44px; font-size: 1rem; }
#ih-chat-charcount {
    position: absolute;
    right: 12px; top: 50%; transform: translateY(-50%);
    font-size: 0.62rem;
    color: #ccc;
    pointer-events: none;
    transition: color 0.2s;
}
#ih-chat-charcount.near-limit { color: var(--ih-chat-red); font-weight: 600; }

/* Quick-start chips (shown on fresh open) */
.ih-chat-quickstart { padding: 4px 12px 8px; }
.ih-chat-qs-label {
    font-size: 0.68rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}
.ih-chat-qs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ih-chat-qs-chip {
    background: #fff;
    border: 1.5px solid var(--ih-chat-red);
    color: var(--ih-chat-red);
    border-radius: 999px;
    padding: 5px 13px;
    font-size: 0.75rem;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: background 0.15s, color 0.15s;
    line-height: 1.3;
    white-space: normal;
    word-break: break-word;
    max-width: 100%;
    text-align: left;
}
.ih-chat-qs-chip:hover { background: var(--ih-chat-red); color: #fff; }

/* Follow-up suggestion chips (after each bot reply) */
.ih-chat-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-left: 2px; max-width: 100%; }
.ih-chat-suggestion-chip {
    background: #fff;
    border: 1px solid #ddd;
    color: #666;
    border-radius: 999px;
    padding: 4px 11px;
    font-size: 0.72rem;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.15s, color 0.15s;
    line-height: 1.3;
    white-space: normal;
    word-break: break-word;
    max-width: 100%;
    text-align: left;
}
.ih-chat-suggestion-chip:hover { border-color: var(--ih-chat-red); color: var(--ih-chat-red); }

/* AI disclaimer (bottom of chat panel) */
#ih-chat-disclaimer {
    text-align: center;
    font-size: 0.6rem;
    color: #999;
    padding: 4px 12px 6px;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.04);
    line-height: 1.4;
}

@media (max-width: 480px) {
    #ih-chat-panel { right: 12px; bottom: 90px; width: calc(100vw - 24px); max-height: calc(100vh - 110px); }
    #ih-chat-messages { max-height: 50vh; }
    #ih-chat-btn { right: 16px; bottom: 20px; }
}

/* ── PWA standalone: lift chat button above the bottom nav bar ── */
@media (display-mode: standalone) {
    #ih-chat-btn {
        bottom: calc(62px + env(safe-area-inset-bottom, 0px) + 16px);
    }
    #ih-chat-panel {
        bottom: calc(62px + env(safe-area-inset-bottom, 0px) + 80px);
    }
}
