/* AI Panel Container (Floating Window) */
.zib-ai-panel-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 900px;
    height: 600px;
    max-width: 95vw;
    max-height: 90vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    display: none; /* Toggled via JS */
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Dark Mode Support */
body.dark-theme .zib-ai-panel-container {
    background: #2d2d2d;
    border-color: rgba(255,255,255,0.1);
    color: #eee;
}

/* Header (Draggable) */
.zib-ai-header {
    height: 50px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    cursor: move; /* Drag cursor */
    user-select: none;
}

body.dark-theme .zib-ai-header {
    background: #252525;
    border-bottom-color: #333;
}

.zib-ai-title {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

body.dark-theme .zib-ai-title {
    color: #eee;
}

.zib-ai-controls .zib-ai-close {
    font-size: 18px;
    color: #999;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.zib-ai-controls .zib-ai-close:hover {
    background: rgba(0,0,0,0.1);
    color: #ff4081;
}

/* Body (Sidebar + Content) */
.zib-ai-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.zib-ai-sidebar {
    width: 220px;
    background: #fdfdfd;
    border-right: 1px solid #eee;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

body.dark-theme .zib-ai-sidebar {
    background: #222;
    border-right-color: #333;
}

.zib-ai-nav-item {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #666;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

body.dark-theme .zib-ai-nav-item {
    color: #aaa;
}

.zib-ai-nav-item:hover {
    background: rgba(0,0,0,0.02);
    color: var(--focus-color, #0084ff);
}

body.dark-theme .zib-ai-nav-item:hover {
    background: rgba(255,255,255,0.05);
}

.zib-ai-nav-item.active {
    background: rgba(var(--focus-color-rgb, 0, 132, 255), 0.08);
    color: var(--focus-color, #0084ff);
    border-left-color: var(--focus-color, #0084ff);
    font-weight: 500;
}

/* Content Area */
.zib-ai-content {
    flex: 1;
    position: relative;
    background: #fff;
}

body.dark-theme .zib-ai-content {
    background: #2d2d2d;
}

/* Panes */
.zib-ai-pane {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
}

.zib-ai-pane.active {
    display: flex;
}

/* Chat Pane Styles */
#zib-ai-pane-chat .zib-ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.zib-ai-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.zib-ai-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.zib-ai-message .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #666;
}

body.dark-theme .zib-ai-message .avatar {
    background: #444;
    color: #aaa;
}

.zib-ai-message .content {
    background: #f5f5f5;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

body.dark-theme .zib-ai-message .content {
    background: #333;
    color: #eee;
}

.zib-ai-message.user .content {
    background: var(--focus-color, #0084ff);
    color: #fff;
}

/* Chat Input */
.zib-ai-chat-input-wrapper {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background: #fff;
}

body.dark-theme .zib-ai-chat-input-wrapper {
    background: #2d2d2d;
    border-top-color: rgba(255,255,255,0.1);
}

.zib-ai-chat-textarea {
    width: 100%;
    height: 60px;
    border: none;
    resize: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: #333;
}

body.dark-theme .zib-ai-chat-textarea {
    color: #eee;
}

.zib-ai-chat-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.ai-tips {
    font-size: 12px;
    color: #999;
}

.zib-ai-send-btn {
    padding: 6px 15px;
    background: var(--focus-color, #0084ff);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: opacity 0.2s;
}

.zib-ai-send-btn:hover {
    opacity: 0.9;
}

/* Iframe Pane */
#zib-ai-pane-iframe iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
}

.zib-ai-iframe-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    z-index: -1;
}

/* Image Icon Style */
.zib-ai-icon-img {
    width: 20px !important;
    height: 20px !important;
    object-fit: contain;
    border-radius: 4px;
    vertical-align: middle;
    display: inline-block;
}

/* Single Mode (Chat Only) - Hide Sidebar */
.zib-ai-panel-container.zib-ai-single-mode .zib-ai-sidebar {
    display: none !important;
}

/* Single Mode - Full Width Content */
.zib-ai-panel-container.zib-ai-single-mode .zib-ai-content {
    width: 100% !important;
    flex: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .zib-ai-panel-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
    }

    .zib-ai-sidebar {
        width: 60px; /* Icon only on mobile maybe? Or just keep it */
    }
    
    .zib-ai-nav-item span {
        display: none; /* Hide text on small screens */
    }
    
    .zib-ai-nav-item {
        justify-content: center;
        padding: 15px 0;
    }

    .zib-ai-panel-container.zib-ai-single-mode .zib-ai-sidebar {
        display: none !important;
    }
}