/* ═══════════════════════════════════════════════
   Poli Asistan Widget - FiloMind
   polimind.online ile birebir aynı
   ═══════════════════════════════════════════════ */

/* ---- FAB (Sürüklenebilir Robot Butonu) ---- */
.chat-fab {
    position: fixed;
    bottom: 70px;
    right: 16px;
    z-index: 900;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: none;
    border: none;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    transition: transform 0.2s;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.chat-fab:hover {
    transform: scale(1.1);
}

.chat-fab:active {
    cursor: grabbing;
}

.poli-fab-img {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: contain;
    animation: poliFloat 3s ease-in-out infinite;
    pointer-events: none;
    filter: drop-shadow(0 4px 16px rgba(99, 102, 241, 0.5));
}

.chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    animation: badgePulse 2s ease-in-out infinite;
}

.chat-badge:empty,
.chat-badge[data-count="0"] {
    display: none;
}

/* ---- Chat Window (Ana Panel) ---- */
.chat-window {
    position: fixed;
    bottom: 130px;
    right: 16px;
    width: 360px;
    height: 480px;
    background: var(--bg-card, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(79, 70, 229, 0.1);
    z-index: 901;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.3s ease;
}

.chat-window.open {
    display: flex;
}

.chat-window.fullscreen {
    display: flex !important;
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    max-width: 100vw !important;
    bottom: 0 !important;
    right: 0 !important;
    top: 0 !important;
    left: 0 !important;
    border-radius: 0 !important;
    resize: none !important;
    z-index: 9999 !important;
}

/* Resize Handles */
.chat-resizer {
    position: absolute;
    z-index: 10;
}

.chat-resizer.r-top {
    top: 0;
    left: 10px;
    right: 10px;
    height: 6px;
    cursor: n-resize;
}

.chat-resizer.r-left {
    top: 10px;
    left: 0;
    bottom: 10px;
    width: 6px;
    cursor: w-resize;
}

.chat-resizer.r-topleft {
    top: 0;
    left: 0;
    width: 14px;
    height: 14px;
    cursor: nw-resize;
}

.chat-resizer.r-right {
    top: 10px;
    right: 0;
    bottom: 10px;
    width: 6px;
    cursor: e-resize;
}

.chat-resizer.r-bottom {
    bottom: 0;
    left: 10px;
    right: 10px;
    height: 6px;
    cursor: s-resize;
}

.chat-resizer.r-bottomright {
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    cursor: se-resize;
}

.chat-window.fullscreen .chat-resizer {
    display: none;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border, #334155);
    cursor: grab;
    flex-shrink: 0;
    user-select: none;
}

.chat-header:active {
    cursor: grabbing;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-title img {
    height: 28px;
    width: auto;
}

.chat-header-title span {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #f1f5f9);
}

.chat-header-actions {
    display: flex;
    gap: 6px;
}

.chat-header-actions button {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border, #334155);
    background: transparent;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
}

.chat-header-actions button:hover {
    background: var(--bg-card-hover, #263548);
    color: var(--text-primary, #f1f5f9);
    border-color: var(--primary, #6366f1);
}

/* Chat Tabs */
.chat-tabs {
    display: flex;
    border-bottom: 1px solid var(--border, #334155);
    background: rgba(0, 0, 0, 0.1);
}

.chat-tab {
    flex: 1;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 600;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.chat-tab:hover {
    color: var(--text-secondary, #94a3b8);
}

.chat-tab.active {
    color: var(--primary-light, #818cf8);
    border-bottom-color: var(--primary, #6366f1);
}

.tab-badge {
    background: #ef4444;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

/* Chat Body */
.chat-body {
    max-height: none !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    position: relative !important;
    overflow-y: auto;
}

.chat-window.fullscreen .chat-body {
    max-height: none !important;
    flex: 1 1 auto !important;
}

/* iframe sekmeleri (polimesaj, whatsapp) absolute ile parent'i doldurmali */
.chat-tab-content[data-content="polimesaj"],
.chat-tab-content[data-content="whatsapp"] {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: auto !important;
}

/* polimesaj ve whatsapp sekmeleri aktifken chat-input gizle */
.chat-window.tab-polimesaj .chat-input-area,
.chat-window.tab-whatsapp .chat-input-area {
    display: none !important;
}

.chat-tab-content {
    display: none;
    padding: 12px;
}

.chat-tab-content.active {
    display: block;
}

/* Mesajlar iframe tab - ozel layout */
.chat-tab-content[data-content="polimesaj"] {
    padding: 0;
    overflow: hidden;
}

.chat-tab-content[data-content="polimesaj"] iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Chat Messages */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.chat-msg.outgoing {
    flex-direction: row-reverse;
}

.chat-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
}

.chat-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-msg-bubble {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-secondary, #94a3b8);
    line-height: 1.5;
    max-width: 85%;
}

.chat-msg.outgoing .chat-msg-bubble {
    background: rgba(6, 182, 212, 0.12);
    border-color: rgba(6, 182, 212, 0.25);
    color: var(--text-primary, #f1f5f9);
}

.chat-msg-time {
    font-size: 9px;
    color: var(--text-muted, #64748b);
    margin-top: 3px;
    text-align: right;
}

.poli-typing {
    display: flex;
    gap: 4px;
    padding: 8px 14px;
}

.poli-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-light, #818cf8);
    animation: typingBounce 1.2s infinite;
}

.poli-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.poli-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

/* Notification Items */
.notif-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border, #334155);
    margin-bottom: 4px;
    transition: all 0.2s;
    cursor: pointer;
}

.notif-item:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.2);
}

.notif-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.notif-content {
    flex: 1;
    min-width: 0;
}

.notif-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary, #f1f5f9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-desc {
    font-size: 9px;
    color: var(--text-muted, #64748b);
    margin-top: 1px;
}

.notif-time {
    font-size: 9px;
    color: var(--text-muted, #64748b);
    white-space: nowrap;
}

/* Task Items */
.task-empty {
    text-align: center;
    padding: 30px 10px;
}

.task-empty-icon {
    font-size: 40px;
    opacity: 0.3;
}

.task-empty-text {
    font-size: 12px;
    color: var(--text-muted, #64748b);
    margin-top: 8px;
}

/* Chat Input */
.chat-input-area {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid var(--border, #334155);
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--border, #334155);
    background: var(--bg-input, #0f172a);
    color: var(--text-primary, #f1f5f9);
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--primary, #6366f1);
}

.chat-input::placeholder {
    color: var(--text-muted, #64748b);
}

.chat-send {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4F46E5, #06B6D4);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send:hover {
    transform: scale(1.08);
    box-shadow: 0 2px 12px rgba(79, 70, 229, 0.4);
}

/* ---- Poli Bar (Dashboard Karşılama) ---- */
.poli-bar {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(6, 182, 212, 0.08));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-lg, 10px);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
}

.poli-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.05), transparent);
    animation: poliShimmer 3s ease-in-out infinite;
}

.poli-bar-av {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    cursor: pointer;
    animation: poliFloat 3s ease-in-out infinite;
}

.poli-bar-av img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.poli-bar-txt {
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.poli-bar-hi {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #f1f5f9);
    line-height: 1.3;
}

.poli-bar-msg {
    font-size: 11px;
    color: var(--text-secondary, #94a3b8);
    margin-top: 3px;
    line-height: 1.4;
}

.poli-bar-stats {
    display: flex;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.poli-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 14px;
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.15);
}

.poli-stat-num {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary, #f1f5f9);
    line-height: 1;
}

.poli-stat-label {
    font-size: 9px;
    color: var(--text-muted, #64748b);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Poli Greeting Bubble ---- */
.poli-greeting {
    position: fixed;
    z-index: 1000;
    background: #1e293b;
    border: 2px solid #6366f1;
    border-radius: 20px 20px 4px 20px;
    padding: 16px 20px;
    font-size: 13px;
    line-height: 1.6;
    color: #f1f5f9;
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.6), 0 0 20px rgba(99, 102, 241, 0.2);
    max-width: 280px;
    display: none;
    animation: pBounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

/* ---- Poli Greet Overlay (Giriş Animasyonu) ---- */
.poli-greet-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    opacity: 1;
    transition: opacity 0.5s;
}

.poli-greet-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.poli-greet-center {
    text-align: center;
}

.poli-greet-center img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    animation: poliFloat 2s ease-in-out infinite;
}

.poli-greet-center h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary, #f1f5f9);
    margin-top: 12px;
}

.poli-greet-center p {
    font-size: 12px;
    color: var(--text-secondary, #94a3b8);
    margin-top: 4px;
}

/* ---- Animations ---- */
@keyframes poliFloat {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-4px);
    }
}

@keyframes poliShimmer {

    0%,
    100% {
        transform: translateX(-100%);
    }

    50% {
        transform: translateX(100%);
    }
}

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pBounce {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(8px);
    }

    60% {
        transform: scale(1.03) translateY(-2px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes badgePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .chat-fab {
        bottom: 60px;
        right: 12px;
        width: 48px;
        height: 48px;
    }

    .poli-fab-img {
        width: 48px;
        height: 48px;
    }

    .chat-window {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 116px;
        max-height: 60vh;
    }

    .chat-window.fullscreen {
        width: 100vw;
        height: calc(100vh - 52px);
        bottom: 52px;
        right: 0;
    }

    .poli-bar {
        flex-direction: column;
        text-align: center;
        padding: 12px;
        gap: 10px;
    }

    .poli-bar-av {
        width: 44px;
        height: 44px;
    }

    .poli-bar-stats {
        width: 100%;
        justify-content: center;
    }
}

/* ---- Chat Suggestions ---- */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px 8px 52px;
}

.chat-sug-btn {
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid var(--primary, #6366f1);
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary, #6366f1);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.chat-sug-btn:hover {
    background: var(--primary, #6366f1);
    color: #fff;
    transform: translateY(-1px);
}