/* ============================================================
   UNO Agent Widget — v3.4
   AgentAI UNO Platform
   Desktop: position:fixed, logo sağında (top:14px, left:282px)
   Mobil:   position:fixed, alt-sol köşe (bottom:20px, left:16px)
   Panel:   desktop=sağa açılır | mobil=yukarı açılır, ekrana sığar
   ============================================================ */

/* ── WIDGET KAPSAYICI ───────────────────────────────────────── */
#uabWidget {
    position: fixed;      /* sayfa nereye scroll edilirse edilsin logo sağında sabit */
    top: 14px;
    left: 282px;          /* logo sağından ~15px boşluk */
    z-index: 9999;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
}

/* ── AVATAR BUTONU ─────────────────────────────────────────── */
#uabAvatarBtn {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex-shrink: 0;
    box-shadow: 0 4px 18px rgba(99, 102, 241, 0.38);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    position: relative;
    border: 3px solid rgba(255, 255, 255, 0.65);
    user-select: none;
    overflow: hidden;
}

#uabAvatarBtn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.55);
}

/* Avatar içi medya */
#uabAvatarBtn .uab-avatar-img,
#uabAvatarBtn .uab-avatar-video {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

#uabAvatarBtn .uab-avatar-initials {
    font-size: 28px;
    font-weight: 700;
    color: white;
    line-height: 1;
    z-index: 1;
}

#uabAvatarBtn .uab-avatar-label {
    font-size: 8px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.88);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    z-index: 1;
}

/* Online göstergesi (yeşil nokta) */
#uabAvatarBtn::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 13px;
    height: 13px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid white;
    z-index: 2;
}

/* ── CHAT PANELİ ───────────────────────────────────────────── */
#uabPanel {
    position: absolute;   /* logo layout'unu bozmaz, avatar sağından açılır */
    top: 0;
    left: 86px;           /* 76px avatar + 10px boşluk */
    width: 420px;
    height: 0;            /* kapalıyken yükseklik yok */
    min-width: 0;
    min-height: 0;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(99, 102, 241, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;

    /* Kapalı: genişlik ve yükseklik 0 */
    max-width: 0;
    opacity: 0;
    pointer-events: none;
    transition: max-width 0.38s cubic-bezier(0.4, 0, 0.2, 1),
                height    0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity   0.25s ease;
    transform-origin: left top;
}

/* Açık state */
#uabPanel.uab-panel-open {
    max-width: 420px;
    height: 220px;
    min-width: 280px;
    min-height: 160px;
    opacity: 1;
    pointer-events: auto;
}

/* Tam ekran */
#uabPanel.uab-panel-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0;
    z-index: 10000;
    opacity: 1;
    pointer-events: auto;
}

/* ── PANEL BAŞLIĞI ─────────────────────────────────────────── */
.uab-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;   /* ince header */
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    flex-shrink: 0;
    cursor: move;        /* drag için */
    user-select: none;
}

.uab-panel-header-info {
    flex: 1;
    min-width: 0;
}

.uab-panel-title {
    color: white;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Subtitle kaldırıldı */
.uab-panel-subtitle {
    display: none;
}

.uab-panel-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.15s;
    flex-shrink: 0;
}

.uab-panel-btn:hover {
    background: rgba(255, 255, 255, 0.28);
    color: white;
}

/* ── MESAJLAR ALANI ────────────────────────────────────────── */
.uab-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    background: #f8f9fe;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12.5px;
    scroll-behavior: smooth;
}

.uab-messages::-webkit-scrollbar { width: 3px; }
.uab-messages::-webkit-scrollbar-track { background: transparent; }
.uab-messages::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.28); border-radius: 2px; }

.uab-msg {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    animation: uabMsgIn 0.2s ease;
}

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

.uab-msg.bot  { flex-direction: row; }
.uab-msg.user { flex-direction: row-reverse; }

.uab-msg-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
    color: white;
    font-weight: 700;
}

.uab-bubble {
    max-width: 82%;
    padding: 7px 11px;
    border-radius: 14px;
    font-size: 12.5px;
    line-height: 1.45;
    word-break: break-word;
}

.uab-msg.bot .uab-bubble {
    background: white;
    color: #1e293b;
    border-radius: 4px 14px 14px 14px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.uab-msg.user .uab-bubble {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border-radius: 14px 4px 14px 14px;
}

/* Yazıyor göstergesi */
.uab-typing .uab-bubble {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 9px 13px;
}

.uab-dot {
    width: 5px;
    height: 5px;
    background: #6366f1;
    border-radius: 50%;
    animation: uabDot 1.3s infinite;
}

.uab-dot:nth-child(2) { animation-delay: 0.2s; }
.uab-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes uabDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-4px); opacity: 1; }
}

/* ── GİRDİ SATIRI ──────────────────────────────────────────── */
.uab-input-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 7px 9px;
    border-top: 1px solid #e2e8f0;
    background: white;
    flex-shrink: 0;
}

.uab-input-row textarea {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 9px;
    font-size: 12.5px;
    color: #1e293b;
    resize: none;
    outline: none;
    font-family: inherit;
    min-height: 30px;
    max-height: 60px;
    line-height: 1.4;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.uab-input-row textarea:focus { border-color: #6366f1; }
.uab-input-row textarea::placeholder { color: #94a3b8; }

.uab-send-btn {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border: none;
    color: white;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
}

.uab-send-btn:hover  { transform: scale(1.08); }
.uab-send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ── RESIZE KOLU (SE köşe) ─────────────────────────────────── */
.uab-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 22px;
    height: 22px;
    cursor: se-resize;
    z-index: 10;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.uab-resize-handle:hover { opacity: 0.9; }

.uab-resize-handle::before {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-right: 2.5px solid #6366f1;
    border-bottom: 2.5px solid #6366f1;
    border-radius: 0 0 3px 0;
}

/* ── MOBİL ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Widget: ekranın alt-solunda sabit */
    #uabWidget {
        top: auto;
        bottom: 20px;
        left: 16px;
    }

    /* Avatar biraz küçük */
    #uabAvatarBtn {
        width: 60px;
        height: 60px;
    }

    #uabAvatarBtn .uab-avatar-initials { font-size: 22px; }

    /* Panel: avatar sağına, YUKARI doğru açılır (bottom:0 ankrajı) */
    #uabPanel {
        top: auto;
        bottom: 0;           /* widget'ın altından yukarı büyür */
        left: 70px;          /* 60px avatar + 10px boşluk */
        margin-left: 0;
        transform-origin: left bottom;
    }

    #uabPanel.uab-panel-open {
        max-width: calc(100vw - 96px); /* 16px sol + 70px + 10px sağ tampon */
        height: 280px;
    }
}
