/* =====================================================================
   ChatGPT WordPress Plugin — style.css  v6.1
   ===================================================================== */

/* --- Chatbox container --- */
#chatgpt-chatbox {
    width: 100%;
    max-width: 720px;
    margin: 20px auto;
    border: 1px solid #e0e0e0;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    /* Висина: messages + form. overflow:hidden за заоблени рабови */
    height: 560px;
    overflow: hidden;
    font-family: Arial, Helvetica, sans-serif;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    background: #fff;
}

/* --- Scrollable messages area --- */
#chatgpt-messages {
    flex: 1;               /* зазема сè над form-wrap */
    padding: 18px 16px;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(180deg, #f8f9fb 0%, #f2f3f5 100%);
    /* Спречи messages да ги истиска бутоните надолу */
    min-height: 0;
}

/* --- Form wrap: textarea + копчиња во една лента --- */
#chatgpt-form-wrap {
    display: flex;
    flex-direction: row;
    align-items: flex-end;   /* рамни по дното кога textarea расте */
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid #e8e8e8;
    background: #fff;
    /* НЕ смее да расте — фиксна лента на дно */
    flex-shrink: 0;
    flex-grow: 0;
    /* Минимална висина за да не се скрати на мали екрани */
    min-height: 64px;
}

/* --- Textarea --- */
#chatgpt_prompt {
    flex: 1;
    min-width: 0;          /* клучно: спречи flex item да расте надвор */
    border: 1px solid #d0d0d0;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 42px;
    max-height: 120px;
    line-height: 1.45;
    transition: border-color .2s;
    overflow-y: auto;
}
#chatgpt_prompt:focus {
    border-color: #0073aa;
}

/* --- Група на копчиња --- */
#chatgpt-btn-group {
    display: flex;
    flex-direction: row;
    gap: 5px;
    align-items: flex-end;
    flex-shrink: 0;
}

/* --- Копчиња --- */
#chatgpt_send_btn,
#chatgpt_stop_btn,
#chatgpt_clear_btn {
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .18s, transform .1s;
    padding: 0;
}
#chatgpt_send_btn  { background: #0073aa; }
#chatgpt_send_btn:hover  { background: #005a87; transform: scale(1.06); }
#chatgpt_send_btn:disabled { background: #9ec6de; cursor: not-allowed; transform: none; }

#chatgpt_stop_btn  { background: #d9534f; }
#chatgpt_stop_btn:hover  { background: #b52b27; transform: scale(1.06); }

#chatgpt_clear_btn { background: #888; }
#chatgpt_clear_btn:hover { background: #555; transform: scale(1.06); }

/* =====================================================================
   Chat bubbles
   ===================================================================== */
.chat-row {
    display: flex;
    align-items: flex-end;
    margin-bottom: 14px;
    gap: 0;
}
.chat-row.user { justify-content: flex-end; }
.chat-row.bot  { justify-content: flex-start; }

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.chat-row.user .avatar { margin-left: 8px; order: 2; }
.chat-row.bot  .avatar { margin-right: 8px; order: 1; }

.bubble {
    padding: 10px 14px;
    border-radius: 18px;
    max-width: 72%;
    word-wrap: break-word;
    word-break: break-word;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    position: relative;
    line-height: 1.5;
    font-size: 14px;
}
.chat-row.user .bubble { order: 1; }
.chat-row.bot  .bubble { order: 2; }

.user-bubble {
    background: #0078fe;
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}
.bot-bubble {
    background: #f0f0f0;
    color: #1a1a1a;
    border-radius: 18px 18px 18px 4px;
}

.meta-time {
    font-size: 10px;
    color: #bbb;
    margin-top: 5px;
    text-align: right;
}
.chat-row.bot .meta-time { color: #aaa; text-align: left; }
.user-bubble .meta-time  { color: rgba(255,255,255,0.65); }

/* Typing dots */
.typing-dots span {
    animation: cgpt-blink 1.2s infinite;
    font-size: 22px;
    margin-right: 2px;
    color: #888;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes cgpt-blink {
    0%,20%  { opacity: 0; }
    50%     { opacity: 1; }
    100%    { opacity: 0; }
}

/* =====================================================================
   Welcome state
   ===================================================================== */
.welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #64748b;
    text-align: center;
    padding: 30px 20px;
    user-select: none;
}
.welcome-state .icon {
    font-size: 3.4em;
    margin-bottom: 16px;
}
.welcome-state h3 {
    font-size: 1.35em;
    margin: 0 0 10px;
    color: #475569;
}
.welcome-state p {
    font-size: 1em;
    opacity: .8;
    max-width: 320px;
    line-height: 1.55;
}

/* =====================================================================
   Login warning
   ===================================================================== */
.chatgpt-login-warning {
    text-align: center;
    padding: 20px;
    color: #c0392b;
    font-weight: bold;
}

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 520px) {
    #chatgpt-chatbox {
        height: 75vh;
        border-radius: 10px;
        margin: 10px auto;
    }
    .bubble     { max-width: 85%; font-size: 13px; }
    .avatar     { width: 30px; height: 30px; }
    #chatgpt_prompt { font-size: 13px; }
}