/* ── Text Simplifier: floating button + chat sidebar ───────────── */

#ts-fab,
#ts-sidebar,
#ts-sidebar * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Floating button πάνω στην επιλογή ─────────────────────────── */

#ts-fab {
    position: absolute;
    z-index: 99998;
    display: none;
    cursor: pointer;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
    transition: background .15s;
}
#ts-fab.ts-visible { display: block; }
#ts-fab:hover      { background: #4338ca; }

/* ── Sidebar ───────────────────────────────────────────────────── */

#ts-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 100000;
    width: 380px;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: #fff;
    color: #1a1a2e;
    font-size: 14px;
    line-height: 1.5;
    border-left: 1px solid #d0d5dd;
    box-shadow: -8px 0 28px rgba(0, 0, 0, .12);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
}
#ts-sidebar.ts-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform .22s ease;
}

@media (max-width: 480px) {
    #ts-sidebar { width: 100vw; }
}

/* Header */
.ts-head {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 12px 12px 16px;
    border-bottom: 1px solid #e4e7ec;
    background: #f8f9fb;
}
.ts-head-title {
    flex: 1;
    font-weight: 700;
    font-size: 15px;
}

.ts-icon {
    cursor: pointer;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    font-size: 15px;
    line-height: 1;
    color: #4b5563;
    transition: background .1s;
}
.ts-icon:hover   { background: #eceef2; }
.ts-icon.ts-active { background: #e0e7ff; border-color: #c7d2fe; }

/* ── Chat ──────────────────────────────────────────────────────── */

#ts-chat,
#ts-history {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
#ts-chat[hidden],
#ts-history[hidden] { display: none; }

#ts-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ts-empty {
    margin: auto;
    padding: 24px 12px;
    text-align: center;
    color: #6b7280;
    font-size: 13px;
}

.ts-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    gap: 4px;
}
.ts-msg.ts-user { align-self: flex-end;   align-items: flex-end; }
.ts-msg.ts-bot  { align-self: flex-start; align-items: flex-start; }

.ts-bubble {
    padding: 9px 12px;
    border-radius: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13.5px;
    line-height: 1.55;
}
.ts-user .ts-bubble {
    background: #4f46e5;
    color: #fff;
    border-bottom-right-radius: 4px;
    max-height: 180px;
    overflow-y: auto;
}
.ts-bot .ts-bubble {
    background: #f1f3f7;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
}
.ts-err .ts-bubble {
    background: #fff5f5;
    border: 1px solid #fca5a5;
    color: #b91c1c;
}

.ts-mini {
    cursor: pointer;
    background: none;
    border: none;
    padding: 0 4px;
    font-size: 11.5px;
    color: #6b7280;
}
.ts-mini:hover { color: #4f46e5; text-decoration: underline; }

/* Typing dots */
.ts-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.ts-typing i {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: ts-bounce 1s infinite ease-in-out;
}
.ts-typing i:nth-child(2) { animation-delay: .15s; }
.ts-typing i:nth-child(3) { animation-delay: .30s; }
@keyframes ts-bounce {
    0%, 80%, 100% { transform: translateY(0);  opacity: .5; }
    40%           { transform: translateY(-4px); opacity: 1; }
}

/* Composer */
.ts-composer {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e4e7ec;
    background: #fff;
}
#ts-input {
    flex: 1;
    resize: none;
    max-height: 120px;
    padding: 8px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.4;
    color: #1a1a2e;
    background: #fff;
}
#ts-input:focus { outline: 2px solid #c7d2fe; border-color: #4f46e5; }

#ts-send {
    cursor: pointer;
    align-self: flex-end;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    transition: background .15s;
}
#ts-send:hover:not(:disabled) { background: #4338ca; }
#ts-send:disabled, #ts-input:disabled { opacity: .55; cursor: not-allowed; }

/* ── Ιστορικό ──────────────────────────────────────────────────── */

#ts-search {
    margin: 12px 12px 8px;
    padding: 8px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 13.5px;
    background: #fff;
    color: #1a1a2e;
}
#ts-search:focus { outline: 2px solid #c7d2fe; border-color: #4f46e5; }

#ts-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ts-item {
    display: flex;
    align-items: flex-start;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #fff;
    transition: background .1s, border-color .1s;
}
.ts-item:hover   { background: #f8f9fb; }
.ts-item.ts-current { border-color: #a5b4fc; background: #eef2ff; }

.ts-item-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    cursor: pointer;
    background: none;
    border: none;
    padding: 9px 4px 9px 12px;
    color: inherit;
}
.ts-item-title {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ts-item-prev {
    font-size: 12px;
    color: #4b5563;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ts-item-date { font-size: 11px; color: #9ca3af; }

.ts-item-del { flex-shrink: 0; margin: 4px 4px 0 0; font-size: 13px; }

#ts-clear-all {
    cursor: pointer;
    margin: 0 12px 12px;
    padding: 8px;
    background: none;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    color: #b91c1c;
    font-size: 12.5px;
}
#ts-clear-all:hover { background: #fff5f5; }
#ts-clear-all[hidden] { display: none; }