/* TDN AI Chatbot — floating widget styles (TDN brand: crimson + cream) */

.tdn-chatbot-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#tdn-chatbot-bubble {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: #c1272d;
    color: #fff;
    cursor: pointer;
    z-index: 99990;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

#tdn-chatbot-bubble:hover,
#tdn-chatbot-bubble:focus-visible {
    background: #a01f25;
    outline: 3px solid #fff;
    outline-offset: 2px;
}

#tdn-chatbot-panel {
    position: fixed;
    right: 20px;
    bottom: 92px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fffdf8;
    border: 1px solid #e5ddd0;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    z-index: 99991;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: inherit;
}

#tdn-chatbot-panel[hidden] {
    display: none;
}

#tdn-chatbot-header {
    background: #c1272d;
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#tdn-chatbot-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
}

#tdn-chatbot-subtitle {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
}

#tdn-chatbot-header-actions {
    display: flex;
    gap: 6px;
}

#tdn-chatbot-header-actions button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    color: #fff;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#tdn-chatbot-header-actions button:hover,
#tdn-chatbot-header-actions button:focus-visible {
    background: rgba(255, 255, 255, 0.2);
    outline: 2px solid #fff;
}

#tdn-chatbot-autoread[aria-pressed="true"] {
    background: #fff;
    color: #c1272d;
}

#tdn-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tdn-chatbot-msg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.45;
}

.tdn-chatbot-msg-user {
    align-self: flex-end;
    background: #c1272d;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.tdn-chatbot-msg-ai {
    align-self: flex-start;
    background: #f3ede1;
    color: #222;
    border-bottom-left-radius: 4px;
}

/* Rendered AI answer (markdown converted to sanitized HTML). */
.tdn-chatbot-answer p {
    margin: 0 0 8px 0;
}
.tdn-chatbot-answer p:last-child {
    margin-bottom: 0;
}
.tdn-chatbot-answer ul,
.tdn-chatbot-answer ol {
    margin: 0 0 8px 0;
    padding-left: 20px;
}
.tdn-chatbot-answer li {
    margin-bottom: 4px;
}
.tdn-chatbot-answer a {
    color: #c1272d;
    text-decoration: underline;
    word-break: break-word;
}

.tdn-chatbot-sources {
    margin-top: 8px;
    font-size: 12px;
}

.tdn-chatbot-sources a {
    color: #c1272d;
    display: block;
    margin-top: 2px;
}

.tdn-chatbot-read-btn {
    margin-top: 8px;
    background: transparent;
    border: 1px solid #c1272d;
    color: #c1272d;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tdn-chatbot-read-btn:hover,
.tdn-chatbot-read-btn:focus-visible {
    background: #c1272d;
    color: #fff;
    outline: 2px solid #c1272d;
    outline-offset: 1px;
}

.tdn-chatbot-msg-thinking {
    font-style: italic;
    opacity: 0.7;
}

.tdn-chatbot-msg-tts-status {
    font-style: italic;
    opacity: 0.75;
    font-size: 13px;
}

.tdn-chatbot-msg-tts-error {
    font-style: normal;
    color: #c1272d;
    opacity: 1;
}

.tdn-chatbot-suggest-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.tdn-chatbot-suggest-pill {
    background: transparent;
    border: 1px solid #c1272d;
    color: #c1272d;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
}

.tdn-chatbot-suggest-pill:hover,
.tdn-chatbot-suggest-pill:focus-visible {
    background: #c1272d;
    color: #fff;
    outline: 2px solid #c1272d;
    outline-offset: 1px;
}

#tdn-chatbot-form {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e5ddd0;
    background: #fff;
}

#tdn-chatbot-input {
    flex: 1;
    border: 1px solid #d8cfbf;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
}

#tdn-chatbot-input:focus-visible {
    outline: 2px solid #c1272d;
    outline-offset: 1px;
}

#tdn-chatbot-send {
    background: #c1272d;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

#tdn-chatbot-send:hover,
#tdn-chatbot-send:focus-visible {
    background: #a01f25;
    outline: 2px solid #a01f25;
    outline-offset: 1px;
}

#tdn-chatbot-send:disabled {
    opacity: 0.6;
    cursor: wait;
}

#tdn-chatbot-mic {
    background: #f5f0e8;
    color: #5a5248;
    border: 1px solid #d8cfbf;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    align-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

#tdn-chatbot-mic:hover,
#tdn-chatbot-mic:focus-visible {
    background: #ece4d6;
    outline: 2px solid #c1272d;
    outline-offset: 1px;
}

#tdn-chatbot-mic[hidden] {
    display: none;
}

/* Pulsing red ring while listening. */
#tdn-chatbot-mic.tdn-chatbot-mic-listening {
    background: #c1272d;
    border-color: #c1272d;
    color: #fff;
    animation: tdn-chatbot-mic-pulse 1.4s ease-in-out infinite;
}

@keyframes tdn-chatbot-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(193, 39, 45, 0.45); }
    50%      { box-shadow: 0 0 0 8px rgba(193, 39, 45, 0); }
}

@media (prefers-reduced-motion: reduce) {
    #tdn-chatbot-mic.tdn-chatbot-mic-listening {
        animation: none;
    }
}

#tdn-chatbot-footer {
    padding: 6px 12px 10px;
    background: #fff;
}

#tdn-chatbot-footer p {
    margin: 0;
    font-size: 11px;
    color: #8a8177;
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    #tdn-chatbot-panel,
    #tdn-chatbot-bubble {
        transition: none;
    }
}
