/* TD Chat IA - feuille de styles rétro années 2000
   Mobile first, breakpoint unique à 1000px.
   Inspirations : MSN Messenger, Yahoo Messenger, Windows XP. */

/* reset minimal */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: Tahoma, Verdana, Geneva, sans-serif;
    font-size: 13px;
    color: #1a1a1a;
    background: #5b9bd5 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40'><circle cx='20' cy='20' r='1' fill='rgba(255,255,255,0.15)'/></svg>") repeat;
    min-height: 100vh;
    padding: 8px;
}

/* fenêtres style XP */
.window {
    background: #ece9d8;
    border: 1px solid #003c74;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
    border-radius: 4px 4px 0 0;
    overflow: hidden;
}

.window-main {
    max-width: 100%;
    margin: 0 auto;
}

.title-bar {
    background: linear-gradient(to bottom, #0997ff 0%, #0058e1 9%, #0058e1 50%, #006edd 51%, #0058e1 91%, #0058e1 100%);
    color: white;
    font-weight: bold;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.4);
    font-size: 12px;
}

.title-bar-text { padding-left: 4px; }

.title-bar-controls {
    display: flex;
    gap: 2px;
}

.btn-mini {
    background: linear-gradient(to bottom, #f1f1f1, #c8c8c8);
    border: 1px solid #003c74;
    color: #000;
    width: 22px;
    height: 20px;
    line-height: 18px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
}

.btn-mini:hover { background: linear-gradient(to bottom, #ffffff, #d8d8d8); }
.btn-mini:active { box-shadow: inset 1px 1px 2px rgba(0,0,0,0.3); }

.window-body {
    padding: 12px;
    background: #ece9d8;
}

/* titres et textes */
.page-title {
    font-size: 18px;
    margin: 0 0 12px 0;
    color: #003c74;
}

h2 {
    font-size: 14px;
    margin: 0 0 10px 0;
    color: #003c74;
    border-bottom: 1px solid #aca899;
    padding-bottom: 4px;
}

h3 { font-size: 13px; margin: 8px 0 6px 0; }

.breadcrumb {
    font-size: 11px;
    color: #555;
    margin: 0 0 10px 0;
}

.breadcrumb a { color: #003c74; }

.empty {
    color: #777;
    font-style: italic;
    padding: 8px 0;
}

.hint {
    color: #666;
    font-size: 11px;
    display: block;
    margin-top: 3px;
}

/* outils sous le textarea de prompt système */
.prompt-tools {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.improve-status {
    font-size: 11px;
    color: #555;
    line-height: 1.4;
}
.improve-status.improve-error   { color: #b00; }
.improve-status.improve-success { color: #1a6b1a; }
.improve-status a { color: #003c74; }
.improve-status a:hover { text-decoration: underline; }

.flash {
    background: #fffacd;
    border: 1px solid #d4c065;
    padding: 6px 10px;
    margin: 0 0 10px 0;
    font-size: 12px;
}
.flash-success { background: #e6ffe6; border-color: #66bb66; }
.flash-error   { background: #ffe6e6; border-color: #cc4444; }

/* layout 2 colonnes home */
.layout-2col {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.panel {
    background: #fdfcf6;
    border: 1px solid #aca899;
    padding: 10px;
}

/* liste des chats */
.chats-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid #aca899;
    background: white;
    max-height: 280px;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
}
.chat-item:last-child { border-bottom: 0; }
.chat-item:hover { background: #f0f7ff; }

.chat-item-link {
    flex: 1;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item-title {
    font-weight: bold;
    color: #003c74;
}

.chat-item-subject {
    color: #666;
    font-size: 11px;
}

.chat-item-date {
    color: #999;
    font-size: 10px;
}

.chat-item-delete { margin: 0; }

.btn-link-danger {
    background: none;
    border: 0;
    color: #c33;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 6px;
}
.btn-link-danger:hover { background: #ffeaea; }

.link-row { margin: 10px 0 0 0; }
.link-add-contact {
    color: #003c74;
    font-weight: bold;
    text-decoration: none;
    font-size: 12px;
}
.link-add-contact:hover { text-decoration: underline; }

/* formulaires */
.field { margin-bottom: 10px; }
.field label {
    display: block;
    font-weight: bold;
    margin-bottom: 3px;
    font-size: 12px;
}

input[type="text"], textarea, select {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #7f9db9;
    background: white;
    font-family: inherit;
    font-size: 13px;
}

input[type="text"]:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #0058e1;
    box-shadow: 0 0 0 1px #0058e1;
}

textarea { resize: vertical; min-height: 50px; }

/* boutons */
.btn {
    background: linear-gradient(to bottom, #f6f6f6, #d4d0c8);
    border: 1px solid #003c74;
    border-radius: 3px;
    padding: 6px 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    color: #1a1a1a;
}

.btn:hover { background: linear-gradient(to bottom, #ffffff, #e0dcd0); }
.btn:active {
    background: linear-gradient(to bottom, #d4d0c8, #f6f6f6);
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.2);
}

.btn-secondary { color: #444; }
.btn-small     { padding: 3px 8px; font-size: 11px; }
.btn-danger    { color: #a00; }
.btn-send      { padding: 6px 18px; }

.actions { margin-top: 12px; display: flex; gap: 8px; }
.actions-row { margin: 0 0 14px 0; display: flex; gap: 8px; }

.inline-form { display: inline; margin: 0; }

/* sélection des participants */
.contacts-group { margin-bottom: 14px; }

.contacts-group-title {
    font-size: 13px;
    color: #003c74;
    margin: 8px 0 6px 0;
    border-bottom: 1px dashed #aca899;
    padding-bottom: 3px;
}

.contacts-pick {
    list-style: none;
    margin: 0;
    padding: 0;
    background: white;
    border: 1px solid #aca899;
}

.contacts-pick li { border-bottom: 1px solid #eee; }
.contacts-pick li:last-child { border-bottom: 0; }

.contact-pick-label {
    display: grid;
    grid-template-columns: auto 32px 1fr;
    grid-template-rows: auto auto;
    gap: 2px 8px;
    align-items: center;
    padding: 6px 8px;
    cursor: pointer;
}
.contact-pick-label:hover { background: #f0f7ff; }
.contact-pick-label input {
    grid-row: 1 / span 2;
    margin: 0;
}
.contact-pick-label .avatar {
    grid-row: 1 / span 2;
}
.contact-pick-name {
    font-weight: bold;
    font-size: 12px;
}
.contact-pick-desc {
    color: #666;
    font-size: 11px;
}

/* avatars */
.avatar {
    border: 1px solid #003c74;
    background: #fff;
    display: inline-block;
    object-fit: cover;
}
.avatar-sm { width: 24px; height: 24px; }
.avatar-md { width: 40px; height: 40px; }
.avatar-lg { width: 56px; height: 56px; }

/* page personas */
.personas-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: white;
    border: 1px solid #aca899;
}

.persona-row {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid #eee;
    align-items: center;
}
.persona-row:last-child { border-bottom: 0; }

.persona-row-main { min-width: 0; }
.persona-row-name {
    font-weight: bold;
    font-size: 13px;
    color: #003c74;
}
.persona-row-status {
    font-size: 10px;
    margin-left: 6px;
    padding: 1px 5px;
    border-radius: 8px;
    font-weight: normal;
}
.status-actif   { background: #dcffd9; color: #1a6b1a; }
.status-inactif { background: #eee; color: #666; }

.persona-row-desc {
    color: #555;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.persona-row-actions {
    grid-column: 1 / span 2;
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.persona-row-inactif { opacity: 0.65; }

/* page chat : layout */
.chat-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    max-width: 100%;
}

/* sidebar contacts */
.contacts-sidebar { order: 2; }
.contacts-sidebar-body { padding: 8px; }

.chat-back { margin: 0 0 8px 0; font-size: 11px; }
.chat-back a { color: #003c74; }

.contacts-online {
    list-style: none;
    margin: 0;
    padding: 0;
}

.contact-online {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-bottom: 1px solid #eee;
    font-size: 12px;
}
.contact-online:last-child { border-bottom: 0; }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    display: inline-block;
}
.status-dot-online { background: #4cc04c; box-shadow: 0 0 3px #4cc04c; }

.contact-online-name { flex: 1; font-weight: bold; }
.contact-online-cat {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
}
.contact-online-self .contact-online-name { color: #c0398b; }

/* fenêtre du chat */
.chat-window { order: 1; min-height: 60vh; display: flex; flex-direction: column; }
.chat-window-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0;
}

.chat-subject {
    background: #fffae6;
    border-bottom: 1px solid #aca899;
    padding: 6px 10px;
    font-size: 11px;
    color: #555;
}

.chat-messages {
    flex: 1;
    background: #ffffff;
    padding: 10px;
    overflow-y: auto;
    min-height: 300px;
    max-height: 60vh;
}

/* messages */
.msg {
    margin-bottom: 12px;
    animation: msg-in 0.25s ease-out;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
    font-size: 11px;
}

.msg-author {
    font-weight: bold;
}

.msg-author-expert  { color: #1a4f8a; }
.msg-author-rebelle { color: #b3361a; }
.msg-author-user    { color: #c0398b; }

.msg-time {
    color: #999;
    font-size: 10px;
}

.msg-bubble {
    padding: 6px 10px;
    background: #f5f8ff;
    border: 1px solid #c8d6e8;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-width: 92%;
}

.msg-rebelle .msg-bubble {
    background: #fff5f0;
    border-color: #ecc8b8;
}

.msg-user {
    text-align: right;
}
.msg-user .msg-header { justify-content: flex-end; }
.msg-user .msg-bubble {
    background: #ffe9f3;
    border-color: #f0bdd5;
    margin-left: auto;
}

.msg-bubble .mention {
    background: #ffeebe;
    padding: 0 3px;
    border-radius: 3px;
    color: #7a5b00;
    font-weight: bold;
}

.msg-bubble code {
    background: rgba(0, 0, 0, 0.07);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
}

.msg-bubble hr.msg-sep {
    border: 0;
    border-top: 1px dashed #b0b0b0;
    margin: 6px 0;
}

.msg-bubble strong { font-weight: bold; }
.msg-bubble em     { font-style: italic; }

/* indicateur "en train d'écrire" */
.chat-typing {
    padding: 4px 10px;
    background: #f7f7e8;
    border-top: 1px solid #aca899;
    font-size: 11px;
    color: #555;
    min-height: 20px;
}

.typing-item { display: inline-block; margin-right: 10px; }
.typing-dots {
    display: inline-block;
    width: 22px;
    text-align: left;
    letter-spacing: 1px;
}

/* zone de saisie */
.chat-form {
    display: flex;
    gap: 6px;
    padding: 8px;
    background: #ece9d8;
    border-top: 1px solid #aca899;
}

.chat-form textarea {
    flex: 1;
    min-height: 38px;
    max-height: 120px;
    resize: vertical;
}

/* responsive : breakpoint unique 1000px */
@media (min-width: 1000px) {

    body { padding: 16px; }

    .window-main { max-width: 980px; }

    .layout-2col {
        grid-template-columns: 1fr 1fr;
    }

    .chat-layout {
        grid-template-columns: 240px 1fr;
        max-width: 880px;
        margin: 0 auto;
    }

    .contacts-sidebar { order: 1; }
    .chat-window { order: 2; min-height: 80vh; }

    .chat-messages { max-height: 70vh; }

    .persona-row {
        grid-template-columns: 56px 1fr auto;
    }
    .persona-row-actions {
        grid-column: 3 / 4;
        margin-top: 0;
    }

    .page-title { font-size: 22px; }
    h2 { font-size: 16px; }
}
