/* ========================================
   Tchat equipe IA - style MSN vintage
   Identite : #001932 / #e2017a / #019ee0 / #ffed00
   Mobile first, breakpoint unique 1000px
   ======================================== */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    color: #001932;
    background: #c7d8e6;
    background-image:
        linear-gradient(135deg, #c7d8e6 0%, #e8f0f7 50%, #c7d8e6 100%);
}

/* Avertissement config */
.tdtc-warning {
    background: #fff3cd;
    border-bottom: 2px solid #ffed00;
    color: #664d03;
    padding: 10px 16px;
    font-size: 13px;
    text-align: center;
}
.tdtc-warning code {
    background: rgba(0,0,0,.08);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: "Consolas", "Courier New", monospace;
}

/* Structure application */
.tdtc-app {
    min-height: 100vh;
    padding: 10px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.tdtc-window {
    width: 100%;
    max-width: 1100px;
    background: #eef2f6;
    border: 1px solid #001932;
    border-radius: 8px 8px 6px 6px;
    box-shadow: 0 6px 20px rgba(0,25,50,.35);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 90vh;
}

/* Barre de titre vintage */
.tdtc-titlebar {
    background: linear-gradient(to bottom, #019ee0 0%, #0073a8 55%, #001932 100%);
    color: #fff;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #001932;
    text-shadow: 0 1px 1px rgba(0,0,0,.4);
}
.tdtc-titlebar-icon {
    font-size: 22px;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,.4));
}
.tdtc-titlebar-text {
    flex: 1;
    line-height: 1.2;
}
.tdtc-titlebar-title {
    font-weight: 700;
    font-size: 15px;
}
.tdtc-titlebar-status {
    font-size: 11px;
    opacity: .85;
}
.tdtc-titlebar-buttons {
    display: flex;
    gap: 3px;
}
.tdtc-titlebar-buttons button {
    width: 26px;
    height: 22px;
    border: 1px solid #001932;
    background: linear-gradient(to bottom, #e8f0f7 0%, #b8cbdd 100%);
    color: #001932;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 3px;
    line-height: 1;
}
.tdtc-titlebar-buttons button:hover {
    background: linear-gradient(to bottom, #ffed00 0%, #ffcc00 100%);
}
.tdtc-btn-close:hover {
    background: linear-gradient(to bottom, #e2017a 0%, #9a0053 100%) !important;
    color: #fff !important;
}

/* Corps : sidebar + chat */
.tdtc-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Sidebar contacts */
.tdtc-sidebar {
    background: linear-gradient(to bottom, #f5f8fb, #e1e8ef);
    border-bottom: 1px solid #a5b7c7;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.tdtc-sidebar-header {
    padding: 8px 10px;
    border-bottom: 1px solid #a5b7c7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(to bottom, #019ee0, #0077ab);
    color: #fff;
    text-shadow: 0 1px 1px rgba(0,0,0,.3);
}
.tdtc-sidebar-title {
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.tdtc-link {
    background: none;
    border: none;
    color: #ffed00;
    cursor: pointer;
    font-size: 12px;
    text-decoration: underline;
    padding: 0;
    font-family: inherit;
}
.tdtc-link:hover {
    color: #fff;
}
.tdtc-contacts {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    overflow-y: auto;
    flex: 1;
}
.tdtc-contact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    border-bottom: 1px dashed transparent;
}
.tdtc-contact:hover {
    background: rgba(1,158,224,.12);
    border-bottom-color: rgba(1,158,224,.3);
}
.tdtc-contact-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.2);
}
.tdtc-contact-info {
    flex: 1;
    min-width: 0;
}
.tdtc-contact-name {
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.tdtc-contact-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #28a745;
    box-shadow: 0 0 3px #28a745;
}
.tdtc-contact-dot.off {
    background: #999;
    box-shadow: none;
}
.tdtc-contact-persona {
    font-size: 11px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tdtc-contact-toggle {
    cursor: pointer;
}

/* Bandeau utilisateur */
.tdtc-sidebar-me {
    padding: 8px 10px;
    border-top: 2px solid #a5b7c7;
    background: linear-gradient(to bottom, #ffed00, #f5c000);
    display: flex;
    align-items: center;
    gap: 8px;
}
.tdtc-me-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #001932;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.3);
}
.tdtc-me-info {
    flex: 1;
    min-width: 0;
    line-height: 1.2;
}
.tdtc-me-name {
    font-weight: 700;
    font-size: 13px;
    color: #001932;
}
.tdtc-me-status {
    font-size: 11px;
    color: #001932;
    opacity: .7;
}

/* Zone de chat */
.tdtc-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    min-height: 0;
}

/* Bandeau sujet */
.tdtc-topic-bar {
    padding: 8px 12px;
    background: linear-gradient(to bottom, #fff8c4, #ffed00);
    border-bottom: 1px solid #d4b800;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    flex-wrap: wrap;
}
.tdtc-topic-label {
    font-weight: 700;
    color: #001932;
}
.tdtc-topic-text {
    flex: 1;
    color: #001932;
    font-style: italic;
    min-width: 0;
}
.tdtc-topic-bar .tdtc-link {
    color: #001932;
    font-style: normal;
}
.tdtc-topic-bar .tdtc-link:hover {
    color: #e2017a;
}

/* Zone des messages */
.tdtc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #fff;
    background-image:
        linear-gradient(to bottom, rgba(1,158,224,.03) 0%, transparent 80px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 200px;
}
.tdtc-message {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    animation: tdtc-msg-in .25s ease-out;
}
@keyframes tdtc-msg-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
.tdtc-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.2);
}
.tdtc-msg-content {
    flex: 1;
    min-width: 0;
}
.tdtc-msg-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
}
.tdtc-msg-author {
    font-weight: 700;
    font-size: 13px;
}
.tdtc-msg-time {
    font-size: 10px;
    color: #999;
}
.tdtc-msg-text {
    font-size: 14px;
    line-height: 1.4;
    color: #001932;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.tdtc-msg-text .tdtc-mention {
    background: #ffed00;
    color: #001932;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 700;
}
.tdtc-msg-text .tdtc-mention.me {
    background: #e2017a;
    color: #fff;
}

/* Message systeme */
.tdtc-msg-system {
    text-align: center;
    color: #888;
    font-size: 11px;
    font-style: italic;
    padding: 4px 0;
    border-bottom: 1px dashed #ccc;
}

/* Indicateur d'ecriture */
.tdtc-typing {
    padding: 4px 12px;
    font-size: 11px;
    color: #666;
    font-style: italic;
    display: none;
    align-items: center;
    gap: 6px;
    border-top: 1px solid #eee;
    background: #fafafa;
}
.tdtc-typing.visible {
    display: flex;
}
.tdtc-typing-name {
    font-weight: 700;
    font-style: normal;
    color: #001932;
}
.tdtc-typing-dots {
    display: inline-flex;
    gap: 3px;
}
.tdtc-typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #019ee0;
    animation: tdtc-typing-bounce 1.2s infinite ease-in-out;
}
.tdtc-typing-dots span:nth-child(2) { animation-delay: .15s; }
.tdtc-typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes tdtc-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Controles */
.tdtc-controls {
    padding: 8px 12px;
    background: linear-gradient(to bottom, #e1e8ef, #c7d3dd);
    border-top: 1px solid #a5b7c7;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.tdtc-speed {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}
.tdtc-speed select {
    padding: 3px 6px;
    font-size: 12px;
    border: 1px solid #a5b7c7;
    border-radius: 3px;
    background: #fff;
    font-family: inherit;
}

/* Boutons */
.tdtc-btn-primary,
.tdtc-btn-secondary,
.tdtc-btn-tertiary,
.tdtc-btn-danger,
.tdtc-btn-send {
    padding: 6px 14px;
    border: 1px solid #001932;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    text-shadow: 0 1px 1px rgba(0,0,0,.2);
    transition: transform .08s ease;
}
.tdtc-btn-primary:active,
.tdtc-btn-secondary:active,
.tdtc-btn-tertiary:active,
.tdtc-btn-danger:active,
.tdtc-btn-send:active {
    transform: translateY(1px);
}
.tdtc-btn-primary {
    background: linear-gradient(to bottom, #019ee0, #0077ab);
    color: #fff;
}
.tdtc-btn-primary:hover {
    background: linear-gradient(to bottom, #22b0f0, #0087c3);
}
.tdtc-btn-primary:disabled {
    background: #b8cbdd;
    color: #eef;
    cursor: not-allowed;
    text-shadow: none;
}
.tdtc-btn-secondary {
    background: linear-gradient(to bottom, #e8f0f7, #b8cbdd);
    color: #001932;
    text-shadow: none;
}
.tdtc-btn-secondary:hover {
    background: linear-gradient(to bottom, #ffed00, #f5c000);
}
.tdtc-btn-secondary:disabled {
    opacity: .5;
    cursor: not-allowed;
}
.tdtc-btn-tertiary {
    background: transparent;
    border: 1px solid transparent;
    color: #555;
    text-shadow: none;
    font-weight: normal;
    text-decoration: underline;
}
.tdtc-btn-tertiary:hover {
    color: #e2017a;
}
.tdtc-btn-danger {
    background: linear-gradient(to bottom, #e2017a, #9a0053);
    color: #fff;
}
.tdtc-btn-danger:hover {
    background: linear-gradient(to bottom, #ff3399, #c4006a);
}
.tdtc-btn-send {
    background: linear-gradient(to bottom, #e2017a, #9a0053);
    color: #fff;
    padding: 6px 18px;
}
.tdtc-btn-send:hover {
    background: linear-gradient(to bottom, #ff3399, #c4006a);
}

/* Zone de saisie */
.tdtc-input-zone {
    display: flex;
    gap: 6px;
    padding: 8px;
    background: linear-gradient(to bottom, #c7d3dd, #a5b7c7);
    border-top: 1px solid #001932;
    align-items: stretch;
}
.tdtc-input-zone textarea {
    flex: 1;
    padding: 8px 10px;
    border: 2px inset #e1e8ef;
    border-radius: 3px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    background: #fff;
}
.tdtc-input-zone textarea:focus {
    outline: 2px solid #019ee0;
    outline-offset: -1px;
}

/* Modales */
.tdtc-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,25,50,.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 10px;
}
.tdtc-modal.visible {
    display: flex;
    animation: tdtc-fade-in .15s ease-out;
}
@keyframes tdtc-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
.tdtc-modal-box {
    background: #eef2f6;
    border: 1px solid #001932;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0,0,0,.4);
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.tdtc-modal-header {
    background: linear-gradient(to bottom, #019ee0, #001932);
    color: #fff;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    text-shadow: 0 1px 1px rgba(0,0,0,.3);
    border-radius: 5px 5px 0 0;
}
.tdtc-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    line-height: 1;
    padding: 0;
}
.tdtc-modal-close:hover {
    background: #e2017a;
    border-radius: 3px;
}
.tdtc-modal-body {
    padding: 14px;
    overflow-y: auto;
}
.tdtc-modal-body label {
    display: block;
    font-weight: 700;
    font-size: 12px;
    margin: 8px 0 4px;
    color: #001932;
}
.tdtc-modal-body label:first-child {
    margin-top: 0;
}
.tdtc-modal-body input[type="text"],
.tdtc-modal-body input[type="color"],
.tdtc-modal-body textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #a5b7c7;
    border-radius: 3px;
    font-family: inherit;
    font-size: 13px;
    background: #fff;
}
.tdtc-modal-body input[type="color"] {
    height: 38px;
    padding: 2px;
    cursor: pointer;
}
.tdtc-modal-body textarea {
    resize: vertical;
    min-height: 80px;
}
.tdtc-hint {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    font-style: italic;
}
.tdtc-modal-footer {
    padding: 10px 14px;
    background: #dbe3eb;
    border-top: 1px solid #a5b7c7;
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    border-radius: 0 0 5px 5px;
    flex-wrap: wrap;
}
.tdtc-modal-footer .tdtc-btn-danger {
    margin-right: auto;
}

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

    .tdtc-app {
        padding: 20px;
        align-items: center;
        min-height: 100vh;
    }

    .tdtc-window {
        min-height: 80vh;
        max-height: 92vh;
    }

    .tdtc-body {
        flex-direction: row;
    }

    .tdtc-sidebar {
        width: 260px;
        border-right: 1px solid #a5b7c7;
        border-bottom: none;
        flex-shrink: 0;
    }

    .tdtc-contacts {
        max-height: none;
    }

    .tdtc-controls {
        flex-wrap: nowrap;
    }

    .tdtc-titlebar-title {
        font-size: 16px;
    }
}
