/* Container view of chat window and chat input */
.ai-interview { 
    margin: 1em auto;
    max-width: 600px;
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    height: 100%; 
}
/* Wrap view of chat window and client Id display */
.ai-chat-wrap{
    position: relative;
    padding-left: 25px;
}

/* Client ID display view (desktop only) */
#ai-client-id-display {
    position: absolute;
    left: 8px;
    top: 10px;
    writing-mode: vertical-rl;
    -webkit-writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 12px;
    line-height: 1;
    color: #999;
    background: #f9f9f9;
    white-space: nowrap;
    /* >>> engedjük a hover/fókuszt, és legyen “fogható” felület */
    display: inline-block;
    padding: 4px 2px;
    border-radius: 2px;
    cursor: help;
    z-index: 10;
}
#ai-client-id-display::after {
    content: attr(data-normal);
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    display: none;
    pointer-events: none; /* tooltip ne fogja a kattintást */
    writing-mode: horizontal-tb;
    -webkit-writing-mode: horizontal-tb;
    text-orientation: mixed;
}
#ai-client-id-display:hover::after,
#ai-client-id-display:focus::after,
#ai-client-id-display:focus-visible::after{
    display: inline-block;
}
/* The view of error messges */
.ai-error-box {
    margin-bottom: 10px;
    padding: 10px 14px;
    border: 1px solid #b00020;
    background: #ffe0e0;
    color: #b00020;
    border-radius: 8px;
    font-size: 14px;
    display: none;
}
/* Style of message views */
.ai-messages { 
    border: 1px solid #ccc;
    padding: 10px;
    flex: 1;
    min-height: 300px;
    overflow-y: auto;
    background-color: #f9f9f9;
    border-radius: 10px;
    position: relative;
    box-sizing: border-box;
    padding-bottom: 64px;
}
/* Style of user, bot, error messages */
.ai-message,
.ai-message.user,
.ai-message.bot {
  display: flex !important;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  margin: 8px 0;
  padding: 0;
  background: transparent;
  /* újak felülírják a régi float/inline-block beállításokat: */
  float: none !important;
  clear: none !important;
  text-align: initial !important;
}
.ai-message.user { 
    flex-direction: row-reverse !important;            /* jobbra igazított sor */
    justify-content: flex-start !important; 
}
.ai-message.bot { 
    flex-direction: row !important;       /* avatar → bubble */
    justify-content: flex-start !important; 
}
.ai-message.error { 
    color: #b00020;
    background-color: #ffe0e0;
    border: 1px solid #b00020; 
}
/* Avatars*/
.ai-avatar {
   flex: 0 0 28px;
   width: 28px;
   height: 28px;
   border-radius: 0px;
   background-size: contain;
   background-position: center;
   background-repeat: no-repeat;
   padding: 2px;
   box-sizing: border-box;
}
/* Bubble + timestamp */
.ai-bubblewrap{
    display: flex;
    flex-direction: column;
    align-items: flex-start;     /* botnál balra */
    flex: 0 1 auto;
    max-width: 80%;
}

.ai-bubble {
    width: 100%;
    display: block;
    background: #f1f1f1;
    border-radius: 12px;
    padding: 10px 14px;
    position: relative;
    white-space: pre-wrap;       /* sortörések megőrzése, normál tördelés */
    overflow-wrap: break-word;   /* csak szükség esetén tördeljen hosszú szót/URL-t */
    word-break: normal;
}
.ai-message.user .ai-bubblewrap{ 
    align-items: flex-end; 
}
.ai-message.user .ai-bubble {
    background: #f9f9f9; /*#d8ebff;*/
}
.ai-timestamp {
    background: transparent;
    display: block;
    font-size: 11px;
    color: #888;
    margin-top: 4px;
    padding: 0 2px;
    width: 100%;
    text-align: left;
}
.ai-message.user .ai-timestamp { 
    text-align: right;
}
/* Waiting animation */
.ai-message.bot.ai-typing {
    float: none;      
    display: inline-block;
    margin: 8px 0;              
    min-width: 60px;
    text-align: center;
    background: #f1f1f1;
    border-radius: 16px;
    padding: 10px 14px;
    color: #666;
    font-style: italic;
    position: relative;
}
.ai-message.bot.ai-typing::after {
    content: "● ● ●";
    font-size: 14px;
    letter-spacing: 4px;
    animation: blink 1s infinite;
}
/* View of chat input */
.ai-input-container {
    margin-top: 12px;
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 30px;
    padding: 6px 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    background: #fff;
    width: 100%;              
    box-sizing: border-box;
}
.ai-input-container input[type="text"] {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    padding: 8px 10px;
    background: transparent;
}
.ai-input-container textarea#ai-user-message {
    flex: 1 1 auto;
    width: 100%;
    min-height: 40px;
    max-height: 6em;              /* kb. 6 sor (JS auto-height mellett) */
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    line-height: 1.4;
    padding: 8px 10px;
    resize: none;
    overflow-y: auto;
    box-sizing: border-box;
    -webkit-appearance: none;
}
 .ai-input-container button {
    background: #0073e6;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}
.ai-input-container button:hover {
    background: #005bb5;
}
.ai-input-container button:disabled,
.ai-input-container button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}
.ai-input-container .btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.6);
    border-right-color: transparent;
    border-radius: 50%;
    animation: ai-spin .8s linear infinite;
    vertical-align: -2px;
}
.ai-input-container:focus-within {
     box-shadow: 0 0 0 2px rgba(0,115,230,0.25);
     border-color: #0073e6;
}
/* View of language selector */
.ai-lang-row{
    display:flex;
    align-items:center;
    gap:8px;
    margin-top:12px;
}

.ai-lang-select{
    position:relative;
    flex:1 1 auto;
}

.ai-lang-select select{
    flex: 1 1 auto;
    width:100%;
    padding:8px 28px 8px 10px; /* hely a nyílnak */
    border:none;
    outline: none;
    font-size: 14px;
    line-height: 1.4;
    background:transparent;
    box-sizing:border-box;
    cursor:pointer;
    appearance:none;
    -webkit-appearance:none;
    -moz-appearance:none;
}

.ai-lang-select::after{
    content:"▾";
    position:absolute;
    right:14px;
    top:50%;
    transform:translateY(-50%);
    font-size:14px;
    color:#666;
    pointer-events:none;
}

.ai-lang-btn{
    background:#0073e6;
    color:#fff;
    border:none;
    border-radius:20px;
    padding:8px 16px;
    font-size:14px;
    cursor:pointer;
    transition:background .2s ease;
    line-height:1;
    height:38px;                 /* optika: megegyező magasság */
    display:inline-flex;
    align-items:center;
}
.ai-lang-btn:hover{ 
    background:#005bb5; 
}
.ai-lang-btn[disabled]{ 
    opacity:.6; cursor:not-allowed; 
}
/* Chat input view extending at longer text */
#ai-user-message {
    resize: none;
    overflow: hidden;
    max-height: 6em; /* kb 6 sor */
}
/* Sticky - chat input */
#ai-message-form.ai-input-container {
    position: sticky;
    bottom: 0;
    background: #fff;
    z-index: 1;
    margin-left: 25px;
    width: calc(100% - 25px);
    box-sizing: border-box;
}

@keyframes ai-spin {
    to { transform: rotate(360deg); }
}

@media (max-width:420px){
  .ai-lang-row{ flex-wrap:wrap; }
  .ai-lang-row .ai-select{ flex-basis:100%; }
}

@supports not (animation: name) {
    .ai-message.bot.ai-typing::after {
    content: "Írom a választ…";  /* szöveges fallback */
    font-size: 14px;
    letter-spacing: normal;
    animation: none;
  }
}

@keyframes blink {
    0%   { opacity: 0.2; }
    50%  { opacity: 1; }
    100% { opacity: 0.2; }
}

@media (max-width: 768px) {
    .ai-chat-wrap { padding-left: 0; }
    #ai-client-id-display { display: none !important; }
    #ai-message-form.ai-input-container { margin-left: 0; width: 100%; }
}
