/*───────────────────────────────────────────────
 🎨 DJOBI – Centre de messagerie client
───────────────────────────────────────────────*/

.djobi-ticket-center {
    background: var(--djobi-wrapper, #f6f8fa);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 14px;
    overflow: hidden;
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 520px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/*───────────────────────────────────────────────
 🧩 Header
───────────────────────────────────────────────*/
.djobi-tc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--djobi-header, #4ea1ff);
    color: #fff;
    padding: 16px 18px;
}

.djobi-tc-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}

.djobi-tc-header p {
    margin: 2px 0 0;
    font-size: 13px;
    opacity: 0.9;
}

/*───────────────────────────────────────────────
 🟦 Bouton principal
───────────────────────────────────────────────*/
.djobi-primary-btn {
    background: #fff;
    color: #0f172a;
    border: none;
    border-radius: 999px;
    padding: 6px 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.djobi-primary-btn:hover {
    background: #e7f3ff;
}

/*───────────────────────────────────────────────
 🧭 Structure
───────────────────────────────────────────────*/
.djobi-tc-body {
    display: flex;
    min-height: 460px;
}

.djobi-tc-list {
    width: 280px;
    border-right: 1px solid rgba(0,0,0,0.05);
    background: #fafbfc;
    overflow-y: auto;
}

.djobi-tc-item {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: background 0.2s ease;
}

.djobi-tc-item:hover {
    background: #f3f9ff;
}

.djobi-tc-item.active {
    background: #e7f3ff;
    border-left: 3px solid #4ea1ff;
}

.djobi-tc-title {
    font-weight: 600;
    font-size: 13.5px;
    color: #0f172a;
}

.djobi-tc-meta {
    font-size: 11px;
    color: #6b7280;
}

.djobi-tc-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    display: inline-block;
    font-weight: 500;
}

.djobi-tc-status.open {
    background: #d1fae5;
    color: #065f46;
}

.djobi-tc-status.closed {
    background: #fee2e2;
    color: #b91c1c;
}

/*───────────────────────────────────────────────
 💬 Zone de chat
───────────────────────────────────────────────*/
.djobi-tc-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.djobi-tc-chat .djobi-am-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #fff;
}

/*───────────────────────────────────────────────
 💭 Bulles de message
───────────────────────────────────────────────*/
.djobi-am-msg {
    margin-bottom: 12px;
    display: flex;
}

.djobi-am-msg.client {
    justify-content: flex-end;
}

.djobi-am-msg.admin {
    justify-content: flex-start;
}

.djobi-am-bubble {
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 70%;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.djobi-am-msg.client .djobi-am-bubble {
    background: var(--djobi-client, #4ea1ff);
    color: #fff;
    border-top-right-radius: 0;
}

.djobi-am-msg.admin .djobi-am-bubble {
    background: var(--djobi-assistant, #eef6ff);
    color: #111;
    border-top-left-radius: 0;
}

/*───────────────────────────────────────────────
 ✍️ Formulaire d’envoi
───────────────────────────────────────────────*/
.djobi-am-form {
    display: flex;
    gap: 10px;
    border-top: 1px solid #eee;
    padding: 10px;
    background: #fff;
}

#djobi-am-input {
    flex: 1;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 14px;
    font-family: inherit;
}

#djobi-am-input:focus {
    border-color: #4ea1ff;
    outline: none;
    box-shadow: 0 0 0 1px #4ea1ff33;
}

#djobi-am-send {
    background: #4ea1ff;
    border: none;
    color: #fff;
    border-radius: 999px;
    padding: 0 18px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

#djobi-am-send:hover {
    background: #64b2ff;
}

/*───────────────────────────────────────────────
 ⚠️ Ticket fermé
───────────────────────────────────────────────*/
.djobi-am-closed {
    background: #fff8e1;
    color: #8a5400;
    padding: 10px;
    text-align: center;
    font-size: 13px;
}

.djobi-secondary-btn {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.05);
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    transition: background 0.2s ease;
}

.djobi-secondary-btn:hover {
    background: #f2f7ff;
}

/*───────────────────────────────────────────────
 📱 Responsive
───────────────────────────────────────────────*/
@media (max-width: 900px) {
    .djobi-tc-body {
        flex-direction: column;
    }

    .djobi-tc-list {
        width: 100%;
        display: flex;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }

    .djobi-tc-item {
        min-width: 230px;
        border-right: 1px solid rgba(0,0,0,0.05);
    }
}
/*───────────────────────────────────────────────
 🌟 Design moderne pour la liste des tickets (client)
───────────────────────────────────────────────*/

.djobi-tc-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    background: #fafbfc;
    border-right: 1px solid rgba(0,0,0,0.05);
}

.djobi-tc-ticket {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border-left: 4px solid var(--djobi-header, #4ea1ff);
}

.djobi-tc-ticket:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.08);
}

.djobi-tc-ticket.active {
    border-left: 4px solid var(--djobi-client, #4ea1ff);
    background: #f5faff;
}

.ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.ticket-title {
    font-weight: 600;
    color: #111827;
    font-size: 14px;
}

.ticket-footer {
    font-size: 12px;
    color: #6b7280;
}

.ticket-badge {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 50px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.ticket-badge.open {
    background-color: #16a34a;
}

.ticket-badge.closed {
    background-color: #dc2626;
}

/*───────────────────────────────────────────────
 🗨️ Message “Aucun ticket”
───────────────────────────────────────────────*/
.djobi-tc-empty {
    text-align: center;
    padding: 35px 10px;
    background: #fff;
    border-radius: 10px;
    color: #4b5563;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    margin: 10px;
}

.djobi-tc-empty strong {
    display: block;
    font-size: 15px;
    color: #111827;
}

.djobi-tc-empty small {
    display: block;
    margin-top: 6px;
    color: #6b7280;
}
/*───────────────────────────────────────────────
 💬 DJOBI – Horodatage sous la bulle (aligné)
───────────────────────────────────────────────*/
.djobi-am-msg {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 12px;
}

.djobi-am-msg.client {
    align-items: flex-end; /* bulle + heure à droite */
}

.djobi-am-msg.admin {
    align-items: flex-start; /* bulle + heure à gauche */
}

.djobi-am-bubble {
    max-width: 70%;
}

.djobi-am-time {
    font-size: 11px;
    color: #6b7280;
    opacity: .85;
}
/*───────────────────────────────────────────────
 💬 DJOBI – Correction finale : scroll visible client
───────────────────────────────────────────────*/

.djobi-tc-chat {
    background: #fff;
    display: flex;
    flex-direction: column;
    height: 520px;
    border-top: 1px solid rgba(0,0,0,0.05);
}

/* Le wrapper interne gère la structure verticale */
.djobi-tc-chat-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

/* Zone des messages : scrollable */
#djobi-am-messages {
    flex: 1;
    overflow-y: scroll !important;
    max-height: 420px;
    padding: 15px;
    background: #fff;
    scroll-behavior: smooth;
    box-sizing: border-box;
}

/* Formulaire d’envoi */
#djobi-am-form {
    flex-shrink: 0;
    display: flex;
    gap: 10px;
    border-top: 1px solid #eee;
    padding: 10px;
    background: #fff;
}

/* Stylisation de la scrollbar */
#djobi-am-messages::-webkit-scrollbar {
    width: 8px;
}
#djobi-am-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
}
#djobi-am-messages::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.4);
}
#djobi-am-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

/* Mobile ajusté */
@media (max-width: 900px) {
    .djobi-tc-chat {
        height: 450px;
    }
    #djobi-am-messages {
        max-height: 360px;
    }
}
/*───────────────────────────────────────────────
 ⏳ Animation de chargement moderne
───────────────────────────────────────────────*/
.djobi-tc-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 0;
    color: #555;
    text-align: center;
    font-size: 14px;
    animation: fadeIn 0.3s ease-in-out;
}

.djobi-tc-loading .spinner {
    width: 34px;
    height: 34px;
    border: 3px solid #e0e0e0;
    border-top: 3px solid #4ea1ff;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}
/*───────────────────────────────────────────────
 ⚙️ DJOBI – Masquer le message vide avant chargement JS
───────────────────────────────────────────────*/
#djobi-tc-list .djobi-tc-empty {
    display: none;
}

/* Une fois les tickets chargés, JS affichera dynamiquement si besoin */
#djobi-tc-list.loaded .djobi-tc-empty {
    display: block;
}
/*───────────────────────────────────────────────
 ✨ Animation fluide (fade-in/out) du chargement DJOBI
───────────────────────────────────────────────*/
.djobi-tc-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 260px;
    color: #555;
    text-align: center;
    font-size: 14px;
}

.djobi-tc-loading .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #ddd;
    border-top: 3px solid #4ea1ff;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin-bottom: 10px;
}

.fade-in {
    animation: fadeIn 0.4s ease-in-out forwards;
}
.fade-out {
    animation: fadeOut 0.3s ease-in-out forwards;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(3px); }
}

/* Évite l'affichage du message "aucun ticket" avant JS */
#djobi-tc-list .djobi-tc-empty { display: none; }
#djobi-tc-list.loaded .djobi-tc-empty { display: block; }

/*───────────────────────────────────────────────
 💬 Animation "quelqu’un écrit..."
───────────────────────────────────────────────*/
.typing-bubble {
    background: #e9f0ff;
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
}

.typing-bubble span {
    width: 6px;
    height: 6px;
    background: #4ea1ff;
    border-radius: 50%;
    animation: typing 1.3s infinite ease-in-out;
}

.typing-bubble span:nth-child(2) {
    animation-delay: 0.2s;
}
.typing-bubble span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-4px); opacity: 1; }
}

/*───────────────────────────────────────────────
 💬 Animation "en train d'écrire..." façon Messenger
───────────────────────────────────────────────*/
.typing-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--assistant-bg, #e9f0ff);
  border-radius: 18px;
  padding: 8px 14px;
  min-width: 50px;
  height: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.typing-bubble span {
  width: 6px;
  height: 6px;
  background: var(--text-color, #333);
  border-radius: 50%;
  margin: 0 3px;
  opacity: 0.4;
  animation: typingDot 1.5s infinite ease-in-out;
}

.typing-bubble span:nth-child(1) {
  animation-delay: 0s;
}
.typing-bubble span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-bubble span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingDot {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.4;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}
/*───────────────────────────────────────────────
 🧑‍💻 Variante admin : client en train d'écrire
───────────────────────────────────────────────*/
.djobi-am-msg.client .typing-bubble {
  background: var(--client-bg, #2196f3);
}

.djobi-am-msg.client .typing-bubble span {
  background: #fff;
}

/* un peu de marge pour bien séparer les bulles */
.djobi-am-msg.admin .typing-bubble,
.djobi-am-msg.client .typing-bubble {
  margin: 4px 0;
}
/*───────────────────────────────────────────────
🎟️ DJOBI – Liste des tickets (scroll vertical)
───────────────────────────────────────────────*/
#djobi-tc-list {
    max-height: 400px; /* Ajuste la hauteur selon ton design */
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #999 #f2f2f2;
    padding-right: 5px; /* évite que le scroll bouffe le texte */
}

/* Scrollbar Webkit (Chrome, Edge, Safari) */
#djobi-tc-list::-webkit-scrollbar {
    width: 6px;
}
#djobi-tc-list::-webkit-scrollbar-track {
    background: #f2f2f2;
}
#djobi-tc-list::-webkit-scrollbar-thumb {
    background-color: #999;
    border-radius: 3px;
}
#djobi-tc-list::-webkit-scrollbar-thumb:hover {
    background-color: #666;
}
#djobi-tc-list {
    transition: opacity 0.3s ease;
}
/*───────────────────────────────────────────────
 🎨 DJOBI – Focus du champ de recherche
───────────────────────────────────────────────*/
#djobi-admin-search:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.25);
}
