/* ============================================
   LLM Chat — App-specific styles
   Extends pibico.css
   ============================================ */

/* Layout */
.chat-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(70,130,180,0.15);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: width 0.25s ease, min-width 0.25s ease, transform 0.3s ease;
}
.sidebar.collapsed {
    width: 0;
    min-width: 0;
    overflow: hidden;
    border-right: none;
}

.sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(70,130,180,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-header .brand {
    font-family: 'Figtree', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #2c5171, #4682B4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-actions {
    display: flex;
    gap: 6px;
}

.btn-new-chat {
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #4682B4, #5a9fd4);
    color: white;
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn-new-chat:hover { opacity: 0.85; }

.btn-collapse-sidebar {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: rgba(70,130,180,0.08);
    color: #4682B4;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.25s;
}
.btn-collapse-sidebar:hover { background: rgba(70,130,180,0.15); }
.sidebar.collapsed .btn-collapse-sidebar { transform: rotate(180deg); }

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conversation-item {
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    background: rgba(70,130,180,0.03);
}
.conversation-item:hover { background: rgba(70,130,180,0.08); box-shadow: 0 0 6px rgba(70,130,180,0.1); }
.conversation-item.active { background: rgba(70,130,180,0.13); box-shadow: 0 0 8px rgba(70,130,180,0.15); }

.conv-top-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.conv-title {
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    color: #333;
    line-height: 1.2;
}

.conv-delete {
    opacity: 0;
    border: none;
    background: none;
    color: #B33A2B;
    cursor: pointer;
    padding: 1px 3px;
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.conversation-item:hover .conv-delete { opacity: 0.6; }
.conv-delete:hover { opacity: 1 !important; }

.conv-badges {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.conv-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.62rem;
    letter-spacing: -0.1px;
    padding: 0px 5px;
    border-radius: 4px;
    background: rgba(70,130,180,0.08);
    color: #6a8fad;
    white-space: nowrap;
    line-height: 1.5;
}
.conv-badge svg {
    width: 9px;
    height: 9px;
    flex-shrink: 0;
}
.conv-badge-rag {
    background: rgba(70,130,180,0.14);
    color: #2c5171;
    font-weight: 600;
}
.conv-badge-file {
    background: rgba(179,58,43,0.08);
    color: #8a4a3f;
    max-width: 140px;
}
.conv-badge-file span,
.conv-badge-file {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #2c5171 0%, #4682b4 50%, #6a9bc3 100%);
    min-width: 0;
    padding: 6px 6px 0;
    gap: 6px;
}

.chat-header {
    padding: 10px 16px;
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 14px;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-header-title {
    font-family: 'Figtree', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    color: #2c5171;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rag-badge {
    display: none;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(70,130,180,0.15);
    color: #2c5171;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}
.rag-badge.visible { display: inline-block; }

.chat-header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-icon {
    border: none;
    background: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    color: #4682B4;
    transition: background 0.15s;
    display: flex;
    align-items: center;
}
.btn-icon:hover { background: rgba(70,130,180,0.1); }

/* Messages Area */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
    min-height: 0;
}

.message {
    max-width: 80%;
    margin-bottom: 6px;
    animation: fadeIn 0.2s ease;
}
.message.assistant {
    max-width: 90%;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
}
.message.user .message-bubble {
    flex-basis: 100%;
    order: 1;
}
.message.user .message-meta {
    order: 2;
}
.message.user .message-avatar {
    order: 3;
    margin-left: 6px;
}

.message.assistant {
    margin-right: auto;
}

.message-bubble {
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: rgba(255,255,255,0.92);
    color: #333;
    border-bottom-right-radius: 4px;
    font-family: 'Raleway', sans-serif;
}

.message.assistant {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
}
.message.assistant .message-bubble {
    flex-basis: 100%;
    order: 1;
}
.message.assistant .message-avatar {
    order: 2;
    margin-right: 8px;
    margin-top: 6px;
}
.message.assistant .message-meta {
    order: 3;
}

.message-avatar {
    width: 26px;
    height: 26px;
    min-width: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
    flex-shrink: 0;
}
.message-avatar svg {
    width: 14px;
    height: 14px;
    color: #fff;
}
.message.assistant .message-avatar {
    background: linear-gradient(135deg, #2c5171, #4682B4);
}
.message.user .message-avatar {
    background: linear-gradient(135deg, #8a6a4a, #b08860);
}

.message.assistant .message-bubble {
    background: rgba(255,255,255,0.97);
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    font-family: system-ui, -apple-system, sans-serif;
}

.message-bubble pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.82rem;
    margin: 4px 0;
}

.message-bubble code {
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
}

.message-bubble p code {
    background: rgba(70,130,180,0.1);
    padding: 1px 5px;
    border-radius: 4px;
}

.message-bubble ul, .message-bubble ol {
    padding-left: 1.4em;
    margin: 4px 0;
}

.message-bubble table {
    border-collapse: collapse;
    margin: 4px 0;
    width: 100%;
}
.message-bubble th, .message-bubble td {
    border: 1px solid #ddd;
    padding: 6px 10px;
    text-align: left;
    font-size: 0.85rem;
}
.message-bubble th {
    background: rgba(70,130,180,0.08);
    font-weight: 600;
}

.message-bubble p { margin: 2px 0; }
.message-bubble p:first-child { margin-top: 0; }
.message-bubble p:last-child { margin-bottom: 0; }

.message-meta {
    font-size: 0.68rem;
    color: rgba(220,225,235,0.7);
    padding: 1px 2px 0;
    flex-basis: auto;
}

.message.user .message-meta {
    text-align: right;
}

/* Thinking indicator */
.thinking-bubble {
    display: inline-flex;
    align-items: center;
    padding: 14px 20px !important;
    min-height: 44px;
}

.thinking-dots {
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4682B4;
    opacity: 0.4;
    animation: thinkingBounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinkingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Streaming indicator */
.streaming-cursor::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 14px;
    background: #4682B4;
    margin-left: 2px;
    animation: blink 0.8s step-end infinite;
    vertical-align: middle;
}
@keyframes blink { 50% { opacity: 0; } }

/* Welcome screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255,255,255,0.7);
    text-align: center;
    padding: 20px;
}
.welcome-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    border: 3px solid rgba(255,255,255,0.3);
}
.welcome-screen h2 {
    font-family: 'Figtree', sans-serif;
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: rgba(255,255,255,0.85);
}
.welcome-screen p {
    font-size: 0.9rem;
    max-width: 400px;
    margin-bottom: 24px;
}

/* Suggestion cards */
.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 520px;
    width: 100%;
}
.suggestion-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: none;
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    text-align: left;
    font-family: 'Raleway', sans-serif;
    font-size: 0.82rem;
    line-height: 1.35;
    transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
}
.suggestion-card:hover {
    background: rgba(255,255,255,0.18);
    box-shadow: 0 0 16px rgba(70,130,180,0.25);
    transform: translateY(-1px);
}
.suggestion-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(70,130,180,0.2);
    color: rgba(255,255,255,0.9);
}
.suggestion-text {
    flex: 1;
}

@media (max-width: 768px) {
    .suggestion-cards {
        grid-template-columns: 1fr;
        max-width: 320px;
    }
}

/* Welcome privacy notice */
.welcome-privacy {
    margin-top: 20px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.45);
    max-width: 420px;
    text-align: center;
    line-height: 1.4;
}
.welcome-privacy a {
    color: rgba(255,255,255,0.65);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.welcome-privacy a:hover {
    color: rgba(255,255,255,0.85);
}

/* Input Area */
.chat-input-area {
    padding: 10px 14px 12px;
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 14px;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
    flex-shrink: 0;
}

/* Attachment badge */
.attachment-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    margin-bottom: 6px;
    border-radius: 8px;
    background: rgba(70,130,180,0.12);
    color: #2c5171;
    font-family: 'Raleway', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    max-width: 100%;
}
.attachment-badge svg { flex-shrink: 0; color: #4682B4; }
.attachment-badge span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attachment-badge button {
    border: none;
    background: none;
    color: #B33A2B;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
}
.attachment-badge button:hover { opacity: 0.7; }

.input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-textarea {
    flex: 1;
    border: 1px solid rgba(70,130,180,0.2);
    border-radius: 12px;
    padding: 10px 14px;
    font-family: 'Raleway', sans-serif;
    font-size: 0.9rem;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    background: white;
    color: #333;
    outline: none;
    transition: border-color 0.2s;
}
.chat-textarea:focus { border-color: #4682B4; }

.btn-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #4682B4, #5a9fd4);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    flex-shrink: 0;
}
.btn-send:hover { opacity: 0.85; }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-attach {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: rgba(70,130,180,0.1);
    color: #4682B4;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.btn-attach:hover { background: rgba(70,130,180,0.18); }

.btn-mic {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: rgba(70,130,180,0.1);
    color: #4682B4;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}
.btn-mic:hover { background: rgba(70,130,180,0.18); }
.btn-mic.recording {
    background: rgba(179,58,43,0.15);
    color: #B33A2B;
    animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(179,58,43,0.3); }
    50% { box-shadow: 0 0 0 6px rgba(179,58,43,0); }
}

/* Emoji picker */
.emoji-wrapper {
    position: relative;
    flex-shrink: 0;
}
.btn-emoji {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: rgba(70,130,180,0.1);
    color: #4682B4;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.btn-emoji:hover { background: rgba(70,130,180,0.18); }
.emoji-picker {
    display: none;
    position: absolute;
    bottom: 48px;
    left: 0;
    width: 280px;
    max-height: 260px;
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    overflow-y: auto;
    z-index: 50;
    padding: 6px;
}
.emoji-picker.open { display: block; }
.emoji-category-title {
    font-family: 'Figtree', sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 4px 2px;
    margin-top: 2px;
}
.emoji-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}
.emoji-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s;
}
.emoji-btn:hover { background: rgba(70,130,180,0.12); }

.input-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 4px 0;
    font-size: 0.7rem;
    color: #888;
}

/* Footer */
.chat-footer {
    padding: 6px 16px;
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 14px;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
    text-align: center;
    font-size: 0.7rem;
    color: #888;
    margin-bottom: 6px;
    flex-shrink: 0;
}
.chat-footer a { color: #4682B4; text-decoration: none; }
.chat-footer .footer-separator { margin: 0 6px; opacity: 0.4; }

/* Sidebar toggle (mobile + collapsed) */
.sidebar-toggle {
    display: none;
    border: none;
    background: none;
    cursor: pointer;
    padding: 6px;
    color: #4682B4;
}
.sidebar.collapsed ~ .chat-main .sidebar-toggle {
    display: flex;
}

/* RAG panel notebook list */
#notebookList {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* RAG panel document list */
.doc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(70,130,180,0.04);
    margin-bottom: 6px;
}
.doc-item-name {
    font-size: 0.83rem;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.doc-item-meta {
    font-size: 0.7rem;
    color: #888;
    margin-left: 8px;
    white-space: nowrap;
}
.doc-item-delete {
    border: none;
    background: none;
    color: #B33A2B;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 0.8rem;
    opacity: 0.5;
}
.doc-item-delete:hover { opacity: 1; }

/* Notebook select in settings */
.notebook-select-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.notebook-select-row select { flex: 1; }

/* Usage stats */
.usage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}
.usage-card {
    background: rgba(70,130,180,0.04);
    border-radius: 8px;
    padding: 12px;
}
.usage-card-title {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.usage-card-value {
    font-family: 'Figtree', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: #2c5171;
    margin-top: 2px;
}
.usage-bar-chart {
    margin-top: 16px;
}
.usage-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.78rem;
}
.usage-bar-label {
    width: 80px;
    text-align: right;
    color: #666;
    font-size: 0.72rem;
}
.usage-bar-track {
    flex: 1;
    height: 14px;
    background: rgba(70,130,180,0.08);
    border-radius: 7px;
    overflow: hidden;
}
.usage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4682B4, #5a9fd4);
    border-radius: 7px;
    transition: width 0.3s ease;
}
.usage-bar-value {
    width: 60px;
    font-size: 0.72rem;
    color: #888;
}

/* Slide panels — consistent frosted glass */
.pibico-panel {
    background: rgba(255,255,255,0.95) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
}
/* Panel overrides for chat app */
.pibico-panel-header {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(70,130,180,0.1);
}
.pibico-panel-body {
    padding: 10px 16px;
}
.pibico-panel-body .panel-section {
    padding: 8px 0;
    border-bottom: 1px solid rgba(70,130,180,0.06);
}
.pibico-panel-body .panel-section:last-child {
    border-bottom: none;
}
.pibico-panel-body .panel-section-title {
    font-family: 'Figtree', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    color: #2c5171;
    margin-bottom: 6px;
}

/* Form elements inside panels */
.pibico-panel-body .pibico-input,
.pibico-panel-body .pibico-select {
    padding: 6px 10px;
    font-size: 0.85rem;
    border-radius: 8px;
    border: 1px solid rgba(70,130,180,0.15);
    background: #f8f9fb;
}
.pibico-panel-body .pibico-input:focus,
.pibico-panel-body .pibico-select:focus {
    border-color: #4682B4;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(70,130,180,0.12);
}
.pibico-panel-body .pibico-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234682B4' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.pibico-panel-body .form-group {
    margin-bottom: 0;
}
.pibico-panel-body small.text-muted {
    font-size: 0.72rem;
    margin-top: 3px;
    display: block;
    color: #888;
}

/* Panel buttons — all rounded and consistent */
.pibico-panel-body .pibico-btn-primary {
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
}
.pibico-panel-body .pibico-btn-ghost {
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid rgba(70,130,180,0.2);
    background: rgba(70,130,180,0.04);
    color: #4682B4;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.pibico-panel-body .pibico-btn-ghost:hover {
    background: rgba(70,130,180,0.1);
    border-color: rgba(70,130,180,0.35);
}
/* Danger ghost variant */
.pibico-panel-body .pibico-btn-ghost[style*="color:#B33A2B"],
.pibico-panel-body .pibico-btn-ghost[style*="color: #B33A2B"] {
    border-color: rgba(179,58,43,0.2);
    background: rgba(179,58,43,0.04);
}
.pibico-panel-body .pibico-btn-ghost[style*="color:#B33A2B"]:hover,
.pibico-panel-body .pibico-btn-ghost[style*="color: #B33A2B"]:hover {
    background: rgba(179,58,43,0.1);
    border-color: rgba(179,58,43,0.35);
}

/* Icon-only action buttons in panels */
.panel-icon-btn {
    width: 28px;
    height: 28px;
    border: 1px solid rgba(70,130,180,0.18);
    border-radius: 6px;
    background: rgba(70,130,180,0.04);
    color: #4682B4;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.panel-icon-btn:hover {
    background: rgba(70,130,180,0.12);
    border-color: rgba(70,130,180,0.35);
    transform: scale(1.05);
}
.panel-icon-btn-danger {
    color: #B33A2B;
    border-color: rgba(179,58,43,0.18);
    background: rgba(179,58,43,0.03);
}
.panel-icon-btn-danger:hover {
    background: rgba(179,58,43,0.1);
    border-color: rgba(179,58,43,0.35);
}

/* Notebook select row compact */
.notebook-select-row {
    gap: 6px;
}
.notebook-select-row select {
    flex: 1;
    min-width: 0;
}

/* Citation badges */
.cite-badge {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    padding: 0 5px;
    margin: 0 1px;
    font-size: 0.68rem;
    font-weight: 600;
    font-family: 'Figtree', system-ui, sans-serif;
    line-height: 1.6;
    border-radius: 4px;
    background: rgba(70,130,180,0.1);
    color: #2c5171;
    cursor: help;
    vertical-align: baseline;
    white-space: nowrap;
    transition: background 0.15s;
}
.cite-badge:hover {
    background: rgba(70,130,180,0.22);
}
.cite-badge .cite-doc {
    font-weight: 700;
}
.cite-badge .cite-chunk {
    font-size: 0.6rem;
    opacity: 0.7;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    min-width: 260px;
    max-width: 400px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.12), 0 0 0 1px rgba(70,130,180,0.08);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.84rem;
    line-height: 1.35;
    color: #333;
    animation: toastIn 0.25s ease;
    transition: opacity 0.2s, transform 0.2s;
}
.toast.removing {
    opacity: 0;
    transform: translateX(20px);
}
.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}
.toast-icon svg { width: 12px; height: 12px; }
.toast-success .toast-icon { background: rgba(42,170,110,0.12); color: #2a7; }
.toast-error .toast-icon { background: rgba(179,58,43,0.12); color: #B33A2B; }
.toast-info .toast-icon { background: rgba(70,130,180,0.12); color: #4682B4; }
.toast-warn .toast-icon { background: rgba(200,150,30,0.12); color: #b8860b; }
.toast-body { flex: 1; word-break: break-word; }
.toast-close {
    flex-shrink: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #999;
    font-size: 1rem;
    padding: 0 2px;
    line-height: 1;
}
.toast-close:hover { color: #555; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Dialog overlay */
.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: dialogFadeIn 0.15s ease;
}
.dialog-box {
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(20px);
    border-radius: 14px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
    width: 340px;
    max-width: 90vw;
    padding: 20px;
    animation: dialogScaleIn 0.2s ease;
}
.dialog-title {
    font-family: 'Figtree', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    color: #2c5171;
    margin-bottom: 10px;
}
.dialog-message {
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 16px;
    line-height: 1.4;
}
.dialog-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(70,130,180,0.2);
    border-radius: 8px;
    font-size: 0.85rem;
    background: #f8f9fb;
    margin-bottom: 16px;
    outline: none;
    box-sizing: border-box;
}
.dialog-input:focus {
    border-color: #4682B4;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(70,130,180,0.12);
}
.dialog-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.dialog-btn {
    padding: 7px 18px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}
.dialog-btn-cancel {
    background: rgba(70,130,180,0.06);
    color: #666;
}
.dialog-btn-cancel:hover { background: rgba(70,130,180,0.12); }
.dialog-btn-confirm {
    background: linear-gradient(135deg, #2c5171, #4682B4);
    color: #fff;
}
.dialog-btn-confirm:hover { filter: brightness(1.1); }
.dialog-btn-danger {
    background: linear-gradient(135deg, #8a3020, #B33A2B);
    color: #fff;
}
.dialog-btn-danger:hover { filter: brightness(1.1); }
@keyframes dialogFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes dialogScaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Admin panel — wider */
#adminPanel { width: 60% !important; }

.admin-filters {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(70,130,180,0.08);
    margin-bottom: 16px;
}
.admin-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}
.admin-filter-group label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #2c5171;
    font-family: 'Figtree', sans-serif;
}
.admin-filter-group input,
.admin-filter-group select {
    width: 100%;
    box-sizing: border-box;
}
.admin-filter-btn {
    flex-shrink: 0;
    height: 34px;
    padding: 0 20px !important;
    font-size: 0.8rem !important;
}
.admin-table-wrap {
    overflow-x: auto;
    margin: 0 -16px;
    padding: 0 16px;
}
.admin-table-wrap .pibico-table {
    font-size: 0.78rem;
    white-space: nowrap;
}
.admin-table-wrap .pibico-table th {
    font-size: 0.72rem;
    padding: 8px 10px;
}
.admin-table-wrap .pibico-table td {
    padding: 7px 10px;
}
.admin-table-wrap .pibico-table tr {
    cursor: pointer;
    transition: background 0.15s;
}
.admin-table-wrap .pibico-table tbody tr:hover td {
    background: rgba(70,130,180,0.1);
}
.admin-cell-title {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-cell-ip {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
}
.admin-cell-origin {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-cell-ua {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
    color: #666;
}
.admin-cell-date {
    font-size: 0.72rem;
    color: #666;
    white-space: nowrap;
}
.admin-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    margin-top: 12px;
    border-top: 1px solid rgba(70,130,180,0.08);
}
.admin-pagination-info {
    font-size: 0.75rem;
    color: #888;
}
.admin-pagination-btns {
    display: flex;
    gap: 8px;
}
.admin-pagination-btns button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Admin detail dialog */
.admin-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.admin-detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.admin-detail-item.full-width {
    grid-column: 1 / -1;
}
.admin-detail-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-family: 'Figtree', sans-serif;
}
.admin-detail-value {
    font-size: 0.85rem;
    color: #333;
    word-break: break-all;
    line-height: 1.35;
}
.admin-detail-value.mono {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    background: rgba(70,130,180,0.05);
    padding: 3px 6px;
    border-radius: 4px;
}

/* Keys table in admin panel */
#keysContent .pibico-table {
    font-size: 0.76rem;
}
#keysContent .pibico-table th {
    font-size: 0.7rem;
    padding: 6px 8px;
}
#keysContent .pibico-table td {
    padding: 5px 8px;
}
#keysContent .panel-icon-btn {
    width: 24px;
    height: 24px;
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        z-index: 100;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: flex; }
    .btn-collapse-sidebar { display: none; }
    .chat-main { padding: 4px 4px 0; gap: 4px; }
    .chat-header { padding: 8px 10px; border-radius: 10px; gap: 6px; }
    .chat-header-actions { gap: 2px; }
    .chat-input-area { padding: 8px 10px 10px; border-radius: 10px; }
    .input-row { gap: 4px; }
    .btn-attach, .btn-mic, .btn-emoji, .btn-send { width: 36px; height: 36px; }
    .chat-footer { padding: 5px 10px; border-radius: 10px; margin-bottom: 4px; }
    .message { max-width: 92%; }
    .pibico-panel { width: 100% !important; }
}
