/* =========================
   CHAT LAUNCHER & INFO BUBBLE
   ========================= */
#chat-launcher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: row-reverse; /* εικονίδιο δεξιά, bubble αριστερά */
  align-items: center;
  gap: 10px;
  z-index: 9999;
}

.chat-toggle {
  width: 65px;
  height: 65px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0078ff, #00c6ff);
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.chat-info-bubble {
  background-color: #124170;
  color: white;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  flex-shrink: 0;
  position: relative;
}

/* Τριγωνάκι προς το εικονίδιο */
.chat-info-bubble::after {
  content: "";
  position: absolute;
  left: 100%; /* δείχνει προς το εικονίδιο */
  top: 50%;
  transform: translateY(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent transparent #124170;
}

/* =========================
   CHAT WIDGET
   ========================= */
#chat-widget {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 360px;
  height: 500px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  display: none;
  flex-direction: column;
  font-family: "Segoe UI", sans-serif;
  z-index: 9999;
}

/* CHAT HEADER */
.chat-header {
  background: linear-gradient(135deg, #0078ff, #00c6ff);
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.chat-header button {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
}

/* CHAT BODY */
/*.chat-body {*/
/*  flex: 1;*/
/*  display: flex;*/
/*  flex-direction: column;*/
/*  padding: 12px;*/
/*  min-height: 0;*/
/*  overflow: hidden;*/
/*}*/
.chat-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0; /* Σημαντικό για σωστό scroll */
}

/*#messages {*/
/*  flex: 1;*/
/*  overflow-y: auto;*/
/*  margin-bottom: 10px;*/
/*  display: flex;*/
/*  flex-direction: column;*/
/*  gap: 8px;*/
/*  padding-right: 4px;*/
/*  scroll-behavior: smooth;*/
/*  min-height: 0;*/
/*}*/

#messages {
  flex: 1 1 auto;       /* γεμίζει τον διαθέσιμο χώρο */
  min-height: 0;         /* Σημαντικό για flex */
  overflow-y: auto;      /* ενεργοποιεί vertical scroll */
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  scroll-behavior: smooth;
}

/* MESSAGES */
.msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.4;
  word-wrap: break-word;
  animation: fadeIn 0.2s ease-in-out;
  margin:10px;
}

.msg.user {
  align-self: flex-end;
  background: #0078ff;
  color: white;
  border-bottom-right-radius: 4px;
}

.msg.agent {
  align-self: flex-start;
  background: #f0f2f5;
  color: #222;
  border-bottom-left-radius: 4px;
}

/* WELCOME SCREEN */
#welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.logo-container img {
  width: 80px;
  margin-bottom: 10px;
}

#welcome-screen input {
  width: 90%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #ccc;
}

#welcome-screen button {
  background: #0078ff;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s;
}

#welcome-screen button:hover {
  background: #005fcc;
}

.error {
  color: red;
  font-size: 13px;
}

#chat-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#message-input {
  resize: none;
  height: 60px;
  border-radius: 8px;
  padding: 8px;
  border: 1px solid #ccc;
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.actions button {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  font-weight: 500;
}

#send-btn {
  background: #0078ff;
  color: white;
}

#send-btn:hover {
  background: #005fcc;
}

.end {
  background: #ccc;
}

.end:hover {
  background: #aaa;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* SCROLLBAR */
#messages::-webkit-scrollbar {
  width: 6px;
}

#messages::-webkit-scrollbar-thumb {
  background: #bbb;
  border-radius: 6px;
}

/* =========================
   MOBILE RESPONSIVE
   ========================= */
@media (max-width: 768px) {
  html,
  body {
    overflow-x: hidden !important;
  }

  #chat-launcher {
    bottom: 16px;
    right: 16px;
    gap: 6px;
  }

  .chat-toggle {
    width: 60px;
    height: 60px;
    font-size: 26px;
  }

  .chat-info-bubble {
    font-size: 14px;
    padding: 8px 14px;
  }

  #chat-widget {
    right: 10px;
    left: 10px;
    width: auto;
    height: 75vh;
    max-width: calc(100% - 20px);
    margin: 0 auto;
    bottom: 90px;
    border-radius: 16px;
    overflow: hidden;
  }
}

/* =========================
   CHAT WIDGET SCROLL FIX
   ========================= */
@media (max-height: 700px) {
  #chat-widget {
    height: 70vh;
  }
}

/* FORCE VERTICAL SCROLL IF WINDOW RESIZE */
#chat-widget.open #messages {
  overflow-y: auto;
}
