/**
 * TTY Smart Assist - Frontend Styles
 * File: assets/css/tty-assist.css
 *
 * House style: Transtoyou teal #005F5F, tty- prefix. All assist CSS is
 * self-contained so it never depends on the search plugin's modal CSS:
 * the .tty-assist-open class carries its own display rules.
 */

/* ============================================================
   Tab bar (inside the modal header)
   ============================================================ */
.tty-assist-tabbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tty-assist-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    background: #fff;
    color: #444;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.tty-assist-tab svg {
    flex-shrink: 0;
}

.tty-assist-tab.active {
    background: #005F5F;
    border-color: #005F5F;
    color: #fff;
}

.tty-assist-tab:not(.active):hover {
    border-color: #005F5F;
    color: #005F5F;
}

/* In assist mode the search form (and its close button) is hidden,
   so the tab bar provides its own close button */
.tty-mode-assist .tty-assist-tabbar .tty-popup-close {
    display: inline-flex;
}

/* ============================================================
   Mode switching
   ============================================================ */
.tty-assist-panel {
    display: none;
}

.tty-mode-assist .tty-assist-panel {
    display: flex;
}

.tty-mode-assist .tty-search-form,
.tty-mode-assist .tty-search-camera-btn,
.tty-mode-assist .tty-search-results {
    display: none !important;
}

/* ============================================================
   Modal display when opened via assist entry points.
   Self-contained: does not rely on the search plugin's open class.
   ============================================================ */
.tty-search-modal.tty-assist-open {
    display: flex !important;
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.45);
    align-items: stretch;
    justify-content: center;
}

body.tty-assist-modal-open {
    overflow: hidden;
}

.tty-search-modal.tty-assist-open .tty-search-modal-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #fff;
    overflow: hidden;
}

@media (min-width: 769px) {
    .tty-search-modal.tty-assist-open {
        padding: 24px;
    }
    
    .tty-search-modal.tty-assist-open .tty-search-modal-content {
        width: 420px;
        height: min(680px, calc(100vh - 48px));
        border-radius: 30px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
        margin: auto;
    }
    
    /* On desktop the panel is Ask AI only: searching happens through
       the header search bar, so the Search tab is not offered */
    .tty-assist-tab[data-mode="search"] {
        display: none;
    }
}

/* The modal body must allow the panel to fill remaining height */
.tty-mode-assist.tty-search-modal-content,
.tty-search-modal .tty-search-modal-content.tty-mode-assist {
    display: flex;
    flex-direction: column;
}

.tty-mode-assist .tty-search-modal-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* ============================================================
   Chat panel
   ============================================================ */
.tty-assist-panel {
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.tty-assist-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tty-assist-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.tty-assist-msg-user {
    align-self: flex-end;
    background: #005F5F;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.tty-assist-msg-assistant {
    align-self: flex-start;
    background: #f2f6f6;
    color: #222;
    border-bottom-left-radius: 4px;
}

.tty-assist-msg-assistant a {
    color: #005F5F;
    font-weight: 600;
    text-decoration: underline;
}

.tty-assist-notice {
    align-self: center;
    padding: 6px 14px;
    border-radius: 14px;
    background: #fff6e8;
    color: #8a5a00;
    font-size: 12.5px;
    text-align: center;
}

/* Typing indicator */
.tty-assist-typing {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 16px;
    background: #f2f6f6;
    font-size: 12.5px;
    color: #555;
}

.tty-assist-typing-dots {
    display: inline-flex;
    gap: 3px;
}

.tty-assist-typing-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #005F5F;
    opacity: 0.4;
    animation: tty-assist-blink 1.2s infinite;
}

.tty-assist-typing-dots i:nth-child(2) {
    animation-delay: 0.2s;
}

.tty-assist-typing-dots i:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes tty-assist-blink {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .tty-assist-typing-dots i {
        animation: none;
        opacity: 0.7;
    }
}

/* ============================================================
   Source cards
   ============================================================ */
.tty-assist-sources {
    align-self: stretch;
    margin-top: 2px;
}

.tty-assist-sources-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #777;
    margin: 4px 0 8px 2px;
}

.tty-assist-sources-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tty-assist-source-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e6e6e6;
    border-radius: 12px;
    background: #fff;
    text-decoration: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tty-assist-source-card:hover {
    border-color: #005F5F;
    box-shadow: 0 2px 10px rgba(0, 95, 95, 0.12);
}

.tty-assist-source-img {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    overflow: hidden;
    background: #f4f4f4;
}

.tty-assist-source-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tty-assist-source-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.tty-assist-source-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tty-assist-source-meta {
    font-size: 12px;
    color: #005F5F;
    font-weight: 600;
}

.tty-assist-source-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

.tty-assist-source-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 7px;
    border-radius: 9px;
    background: #eef4f4;
    color: #005F5F;
}

.tty-assist-badge-prescription {
    background: #fdeeee;
    color: #b33a3a;
}

.tty-assist-badge-addictive {
    background: #fff3e0;
    color: #a8650a;
}

/* ============================================================
   Composer
   ============================================================ */
.tty-assist-composer {
    flex-shrink: 0;
    border-top: 1px solid #ececec;
    padding: 10px 12px 25px 12px;
    background: #fff;
}

.tty-assist-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.tty-assist-input {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    line-height: 1.4;
    font-family: inherit;
    max-height: 120px;
    background: #fafafa;
}

.tty-assist-input:focus {
    outline: none;
    border-color: #005F5F;
    background: #fff;
}

.tty-assist-send {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: #005F5F;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.tty-assist-send:hover {
    background: #004a4a;
}

.tty-assist-send:disabled {
    background: #b9cfcf;
    cursor: not-allowed;
}

.tty-assist-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
}

.tty-assist-new-conversation {
    flex-shrink: 0;
    border: none;
    background: none;
    padding: 0;
    font-size: 11.5px;
    font-weight: 600;
    color: #005F5F;
    cursor: pointer;
    text-decoration: underline;
}

.tty-assist-disclaimer {
    font-size: 10.5px;
    line-height: 1.35;
    color: #999;
    text-align: right;
}

/* ============================================================
   Floating action button (Support Board position)
   ============================================================ */
.tty-assist-fab {
    position: fixed;
    right: 20px;
    bottom: 24px;
    z-index: 99990;
    width: 50px;
    height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: #005F5F;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease, background-color 0.2s ease;
}

.tty-assist-fab:hover {
    background: #004a4a;
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .tty-assist-fab {
        right: 15px;
        bottom: 195px;
        width: 45px;
        height: 45px;
        z-index: 9;
    }
}

/* Hide the FAB while the modal is open */
body.tty-assist-modal-open .tty-assist-fab {
    display: none;
}

/* ============================================================
   Font Awesome duotone icon sizing
   ============================================================ */
.tty-assist-fab i {
    font-size: 21px;
}

.tty-assist-tab i {
    font-size: 13px;
}

.tty-assist-send i {
    font-size: 16px;
}

.tty-assist-trigger i {
    font-size: 17px;
}

/* ============================================================
   Search bar trigger button (desktop entry point)
   ============================================================ */
.tty-assist-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
     border: none;
    border-radius: 50%;
    background: none;
    color: #005F5F;
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: absolute;
    top: 10px;
    left: 5px;
}

.tty-assist-trigger:hover {
    background: #eef4f4;
}
