/* ====================================================
   MESSENGER STILIAUS CHATO LANGAS (Švarūs X mygtukai)
   ==================================================== */

.tf-chat-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); display: none; align-items: center; justify-content: center; z-index: 99999; backdrop-filter: blur(5px); animation: fadeIn 0.2s ease-out; font-family: 'Inter', sans-serif; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tf-chat-modal { background: var(--tf-bg-card); width: 100%; max-width: 450px; height: 85vh; max-height: 600px; border-radius: 20px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4); border: 1px solid var(--tf-border); transform: translateY(20px); animation: slideUp 0.3s ease-out forwards; }
@keyframes slideUp { to { transform: translateY(0); } }

/* Headeris */
.tf-chat-header { background: var(--tf-bg-box); padding: 18px 24px; border-bottom: 1px solid var(--tf-border); display: flex; justify-content: space-between; align-items: center; }
.tf-chat-header h4 { margin: 0; font-size: 16px; font-weight: 800; color: var(--tf-text-heading); letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 85%; }

/* Paprastas, švarus lango uždarymo mygtukas */
.tf-chat-close { 
    background: transparent; 
    border: none; 
    font-size: 24px; /* Padidinome dydį */
    font-weight: 600; /* Šiek tiek suploninome, kad atrodytų moderniau padidinus */
    cursor: pointer; 
    color: var(--tf-text-muted); 
    transition: color 0.2s, transform 0.2s; 
    padding: 4px; /* Pridėjome šiek tiek erdvės aplink, kad būtų lengviau paspausti */
    line-height: 1; 
}
.tf-chat-close:hover { 
    color: #ef4444; 
    transform: scale(1.1); /* Labai minimaliai padidėja užvedus pelę */
}

/* Chato Kūnas (Burbulai) */
.tf-chat-body { flex: 1; padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; background: var(--tf-bg-body); scroll-behavior: smooth; }
.tf-chat-body::-webkit-scrollbar { width: 6px; }
.tf-chat-body::-webkit-scrollbar-thumb { background-color: var(--tf-border); border-radius: 10px; }

.tf-chat-loading, .tf-empty-chat, .tf-chat-error { text-align: center; color: var(--tf-text-muted); font-size: 14px; font-weight: 600; padding: 30px 20px; margin: auto; }
.tf-chat-error { color: #ef4444; }

.tf-chat-bubble { padding: 12px 16px; border-radius: 16px; max-width: 82%; font-size: 14px; line-height: 1.5; position: relative; animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); box-shadow: 0 2px 4px rgba(0,0,0,0.04); transition: all 0.3s; word-break: break-word; }
@keyframes popIn { from { opacity: 0; transform: scale(0.9) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* AŠ (Admin/Buhalteris) */
.bubble-mine { background: var(--tf-primary); color: white; align-self: flex-end; border-bottom-right-radius: 4px; padding-right: 25px; /* Vietos trynimo mygtukui */ }
.bubble-mine .tf-chat-meta { color: rgba(255,255,255,0.7); text-align: right; }

/* KLIENTAS */
.bubble-theirs { background: var(--tf-bg-card); color: var(--tf-text-main); border: 1px solid var(--tf-border); align-self: flex-start; border-bottom-left-radius: 4px; padding-right: 25px; }
.bubble-theirs .tf-chat-meta { color: var(--tf-text-muted); text-align: left; }

.tf-chat-meta { font-size: 11px; margin-bottom: 6px; display: block; font-weight: 600; letter-spacing: 0.3px; }
.tf-chat-text { margin: 0; }

/* Paprastas žinutės trynimo mygtukas (Burbulo viduje kampe) */
.tf-msg-del { 
    position: absolute; 
    top: 10px; 
    right: 10px; 
    background: transparent; 
    color: var(--tf-text-muted); 
    border: none; 
    font-size: 11px; 
    font-weight: 800;
    cursor: pointer; 
    opacity: 0; 
    padding: 0;
    transition: color 0.2s, opacity 0.2s; 
}
.bubble-mine .tf-msg-del { color: rgba(255,255,255,0.6); } 
.tf-chat-bubble:hover .tf-msg-del { opacity: 1; }
.tf-msg-del:hover { color: #ef4444 !important; }

/* Footeris (Įvesties laukas) */
.tf-chat-footer { padding: 15px 20px; background: var(--tf-bg-card); border-top: 1px solid var(--tf-border); display: flex; gap: 12px; align-items: flex-end; }
.tf-chat-footer textarea { flex: 1; padding: 12px 15px; border: 1px solid var(--tf-border); background: var(--tf-input-bg); color: var(--tf-text-main); border-radius: 12px; resize: none; font-size: 14px; font-family: inherit; line-height: 1.5; outline: none; transition: all 0.2s; height: 46px; max-height: 120px; overflow-y: auto; }
.tf-chat-footer textarea:focus { border-color: var(--tf-primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.tf-chat-footer button { background: var(--tf-primary); color: white; border: none; height: 46px; padding: 0 20px; border-radius: 12px; font-weight: 800; font-size: 14px; cursor: pointer; font-family: inherit; transition: all 0.2s; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 6px rgba(37,99,235,0.2); }
.tf-chat-footer button:hover { filter: brightness(0.9); transform: translateY(-1px); box-shadow: 0 6px 10px rgba(37,99,235,0.3); }

/* Pritaikymas telefonams */
@media (max-width: 600px) {
    .tf-chat-modal { width: 100%; height: 100vh; max-height: 100vh; border-radius: 0; transform: translateY(0); }
    .tf-chat-header { padding: 15px; }
    .tf-chat-body { padding: 15px; }
    .tf-chat-footer { padding: 15px; }
}