/* ═══════════════════════════════════════════════════════════
   AI Assistant — Floating Chat Widget
   Premium glassmorphism design for Canifa Admin Console
   ═══════════════════════════════════════════════════════════ */

/* ── Bubble Button ── */
.ai-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b5998 0%, #2d4a7a 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow:
        0 4px 16px rgba(59, 89, 152, 0.35),
        0 2px 6px rgba(0, 0, 0, 0.12);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: ai-bubble-pulse 3s ease-in-out infinite;
}
.ai-bubble:hover {
    transform: scale(1.1);
    box-shadow:
        0 6px 24px rgba(59, 89, 152, 0.5),
        0 3px 8px rgba(0, 0, 0, 0.15);
}
.ai-bubble:active {
    transform: scale(0.95);
}
.ai-bubble.open {
    animation: none;
    transform: rotate(0deg);
}
.ai-bubble .bubble-icon { transition: transform 0.3s ease; }
.ai-bubble.open .bubble-icon { transform: rotate(45deg); }

@keyframes ai-bubble-pulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(59, 89, 152, 0.35), 0 2px 6px rgba(0, 0, 0, 0.12); }
    50% { box-shadow: 0 4px 24px rgba(59, 89, 152, 0.55), 0 2px 8px rgba(0, 0, 0, 0.18), 0 0 0 8px rgba(59, 89, 152, 0.08); }
}

/* ── Notification dot ── */
.ai-bubble-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}

/* ── Chat Panel ── */
.ai-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 420px;
    max-width: calc(100vw - 48px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border: 1px solid var(--border, #e7e5e2);
    border-radius: 16px;
    box-shadow:
        0 12px 48px rgba(0, 0, 0, 0.12),
        0 4px 16px rgba(0, 0, 0, 0.06);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.ai-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Panel Header ── */
.ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, #3b5998 0%, #2d4a7a 100%);
    color: #fff;
    flex-shrink: 0;
}
.ai-panel-header .header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-panel-header .header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.ai-panel-header .header-info h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}
.ai-panel-header .header-info span {
    font-size: 11px;
    opacity: 0.8;
}
.ai-panel-header .header-actions {
    display: flex;
    gap: 6px;
}
.ai-panel-header .header-actions button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-panel-header .header-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── Quick Actions Bar ── */
.ai-quick-actions {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    background: #f8f7f4;
    border-bottom: 1px solid var(--border, #e7e5e2);
    flex-shrink: 0;
    overflow-x: auto;
}
.ai-quick-actions::-webkit-scrollbar { height: 0; }
.ai-quick-btn {
    padding: 5px 12px;
    border: 1px solid var(--border, #e7e5e2);
    border-radius: 20px;
    background: #fff;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    color: var(--secondary-fg, #57534e);
    transition: all 0.2s;
}
.ai-quick-btn:hover {
    background: var(--primary, #3b5998);
    color: #fff;
    border-color: var(--primary, #3b5998);
}

/* ── Messages Area ── */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #faf9f7;
    min-height: 0;
}
.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-thumb { background: #d6d3ce; border-radius: 4px; }

/* ── Message Bubble ── */
.ai-msg {
    display: flex;
    gap: 8px;
    max-width: 92%;
    animation: msg-in 0.3s ease;
}
@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.ai-msg.bot { align-self: flex-start; }
.ai-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.ai-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    margin-top: 2px;
}
.ai-msg.bot .ai-msg-avatar {
    background: linear-gradient(135deg, #3b5998, #2d4a7a);
    color: #fff;
}
.ai-msg.user .ai-msg-avatar {
    background: var(--muted, #f0efec);
    color: var(--muted-fg, #78716c);
}

.ai-msg-body {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
}
.ai-msg.bot .ai-msg-body {
    background: #fff;
    color: var(--foreground, #1c1917);
    border: 1px solid var(--border, #e7e5e2);
    border-top-left-radius: 4px;
}
.ai-msg.user .ai-msg-body {
    background: var(--primary, #3b5998);
    color: #fff;
    border-top-right-radius: 4px;
}

/* ── Search Results inside chat ── */
.ai-search-results {
    margin-top: 8px;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border, #e7e5e2);
    border-radius: 10px;
    background: #fff;
}
.ai-search-results::-webkit-scrollbar { width: 3px; }
.ai-search-results::-webkit-scrollbar-thumb { background: #d6d3ce; border-radius: 3px; }

.ai-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid #f0efec;
    cursor: pointer;
    transition: background 0.15s;
}
.ai-result-item:last-child { border-bottom: none; }
.ai-result-item:hover { background: #f8f7f4; }

.ai-result-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary, #3b5998);
    flex-shrink: 0;
    cursor: pointer;
}
.ai-result-item img {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--muted, #f0efec);
    border: 1px solid var(--border, #e7e5e2);
}
.ai-result-info {
    flex: 1;
    min-width: 0;
}
.ai-result-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-result-code {
    font-size: 10px;
    color: var(--muted-fg, #78716c);
    font-family: var(--font-mono, monospace);
}
.ai-result-status {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    flex-shrink: 0;
}
.ai-result-status.done { background: #ecfdf5; color: #16a34a; }
.ai-result-status.pending { background: #fff3cd; color: #856404; }
.ai-result-status.missing { background: #fef2f2; color: #dc2626; }

/* ── Bulk Action Bar (appears after search) ── */
.ai-bulk-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #eef1f8;
    border-top: 1px solid var(--border, #e7e5e2);
    font-size: 12px;
    flex-shrink: 0;
}
.ai-bulk-bar .bulk-count {
    font-weight: 700;
    color: var(--primary, #3b5998);
}
.ai-bulk-bar select {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--border, #e7e5e2);
    border-radius: 6px;
    font-size: 12px;
    background: #fff;
    outline: none;
}
.ai-bulk-bar button {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: var(--primary, #3b5998);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}
.ai-bulk-bar button:hover { background: var(--primary-hover, #2d4a7a); }

/* ── Input Area ── */
.ai-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--border, #e7e5e2);
    background: #fff;
    flex-shrink: 0;
}
.ai-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border, #e7e5e2);
    border-radius: 10px;
    font: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #faf9f7;
}
.ai-input-area input:focus {
    border-color: var(--primary, #3b5998);
    box-shadow: 0 0 0 3px rgba(59, 89, 152, 0.08);
    background: #fff;
}
.ai-input-area input::placeholder { color: #a8a29e; }
.ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: var(--primary, #3b5998);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.ai-send-btn:hover { background: var(--primary-hover, #2d4a7a); transform: scale(1.05); }
.ai-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Typing indicator ── */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    align-self: flex-start;
}
.ai-typing-dot {
    width: 7px;
    height: 7px;
    background: #a8a29e;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ── Bulk Edit Modal (inside chat) ── */
.ai-edit-modal {
    margin-top: 8px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--border, #e7e5e2);
    border-radius: 10px;
}
.ai-edit-modal label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted-fg, #78716c);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ai-edit-modal select,
.ai-edit-modal input,
.ai-edit-modal textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border, #e7e5e2);
    border-radius: 8px;
    font: inherit;
    font-size: 12px;
    outline: none;
    margin-bottom: 8px;
    resize: vertical;
}
.ai-edit-modal textarea { min-height: 60px; }
.ai-edit-modal select:focus,
.ai-edit-modal input:focus,
.ai-edit-modal textarea:focus {
    border-color: var(--primary, #3b5998);
}
.ai-edit-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}
.ai-edit-actions button {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.ai-edit-actions .btn-preview {
    background: #f0efec;
    color: #57534e;
}
.ai-edit-actions .btn-preview:hover { background: #e7e5e2; }
.ai-edit-actions .btn-apply {
    background: #16a34a;
    color: #fff;
}
.ai-edit-actions .btn-apply:hover { background: #15803d; }

/* ── Responsive ── */
@media (max-width: 480px) {
    .ai-panel {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 80px;
        height: calc(100vh - 100px);
        border-radius: 12px;
    }
    .ai-bubble {
        right: 16px;
        bottom: 16px;
        width: 50px;
        height: 50px;
    }
}

/* ── Progress Bar ── */
.ai-progress-bar {
    padding: 10px 14px;
    background: #eef1f8;
    border-top: 1px solid var(--border, #e7e5e2);
    flex-shrink: 0;
}
.ai-progress-bar .progress-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    margin-bottom: 6px;
    color: var(--foreground, #1c1917);
}
.ai-progress-bar .progress-name {
    font-size: 10px;
    color: var(--muted-fg, #78716c);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}
.ai-progress-bar .progress-track {
    width: 100%;
    height: 6px;
    background: #e7e5e2;
    border-radius: 3px;
    overflow: hidden;
}
.ai-progress-bar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b5998, #16a34a);
    border-radius: 3px;
    width: 0%;
    transition: width 0.5s ease;
}

/* ── AI Sinh Button (accent green) ── */
.bulk-ai-btn {
    background: #16a34a !important;
    font-weight: 700 !important;
}
.bulk-ai-btn:hover {
    background: #15803d !important;
}

/* ── AI Filter Tags (Agent search results) ── */
.ai-filter-tags {
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin-bottom: 8px;
}
.ai-filter-explain {
    font-size: 11px;
    color: #64748b;
    font-style: italic;
}
.ai-tag {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.ai-tag.product { background: #dbeafe; color: #1d4ed8; }
.ai-tag.color   { background: #fce7f3; color: #be185d; }
.ai-tag.gender  { background: #f3e8ff; color: #7c3aed; }
.ai-tag.age     { background: #fef3c7; color: #b45309; }
.ai-tag.season  { background: #d1fae5; color: #047857; }
.ai-tag.occasion{ background: #fee2e2; color: #dc2626; }
.ai-tag.keyword { background: #e0e7ff; color: #4338ca; }
