/* Article Parser Floating Widget */
.article-parser-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: 550px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    font-family: var(--font-ui, inherit);
    resize: both;
}

.article-parser-widget .widget-header {
    background: #0f172a;
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
}

.article-parser-widget .widget-header:active {
    cursor: grabbing;
}

.article-parser-widget .widget-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.05rem;
    color: #ffffff;
}

.article-parser-widget .widget-btn-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.1rem;
    transition: color 0.2s;
    padding: 4px;
}

.article-parser-widget .widget-btn-close:hover {
    color: #ef4444;
}

.article-parser-widget .widget-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8fafc;
}

/* Tabs */
.parser-tabs {
    display: flex;
    background: #e2e8f0;
    padding: 4px;
    gap: 4px;
}

.parser-tab {
    flex: 1;
    text-align: center;
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: #64748b;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.parser-tab:hover {
    color: #334155;
}

.parser-tab.active {
    background: white;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Upload Section */
.parser-upload-section {
    padding: 16px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.parser-upload-section .upload-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 10px;
    background: #f1f5f9;
    color: #334155;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.parser-upload-section .upload-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
    color: #0f172a;
}

.uploaded-file-name {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #e0f2fe;
    color: #0369a1;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
}

.uploaded-file-name .remove-file-btn {
    background: transparent;
    border: none;
    color: #0284c7;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    border-radius: 4px;
}

.uploaded-file-name .remove-file-btn:hover {
    color: #0c4a6e;
    background: rgba(0,0,0,0.05);
}

/* Chat History */
.parser-chat-history {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    position: relative;
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 12px;
    margin: 0.5em 0 0 0;
}

/* Beautiful thin scrollbar for formulas */
.chat-message .katex-display::-webkit-scrollbar {
    height: 6px;
}
.chat-message .katex-display::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}
.chat-message .katex-display::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}
.chat-message.user-message .katex-display::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.4);
}
.chat-message.user-message .katex-display::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.chat-message .msg-delete-btn {
    position: absolute;
    top: 2px;
    right: 4px;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 2px 6px;
    display: none;
    border-radius: 4px;
    transition: all 0.2s;
}

.chat-message.user-message .msg-delete-btn {
    color: rgba(255, 255, 255, 0.6);
}

.chat-message:hover .msg-delete-btn {
    display: block;
}

.chat-message.user-message .msg-delete-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.2);
}

.chat-message.ai-message .msg-delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.chat-message.ai-message {
    align-self: flex-start;
    background: white;
    border: 1px solid #e2e8f0;
    color: #334155;
    border-bottom-left-radius: 2px;
}

.chat-message.user-message {
    align-self: flex-end;
    background: #2563eb;
    color: white;
    border-bottom-right-radius: 2px;
}

/* Dictionary View */
.parser-dict-history {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

.dict-empty-state {
    text-align: center;
    color: #94a3b8;
    margin-top: 20px;
    font-size: 0.95rem;
}

.dict-item {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.dict-item-title {
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 6px;
    font-size: 1.05rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 4px;
}

.dict-item-content {
    font-size: 0.95rem;
    color: #334155;
    line-height: 1.5;
}

/* Input Area */
.parser-input-area {
    padding: 12px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.parser-input-area textarea {
    flex: 1;
    resize: none;
    max-height: 120px;
    min-height: 40px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.parser-input-area textarea:focus {
    border-color: #3b82f6;
}

.parser-input-area .input-actions {
    display: flex;
    gap: 6px;
}

.parser-input-area .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.parser-input-area .voice-btn {
    background: #f1f5f9;
    color: #64748b;
}

.parser-input-area .voice-btn:hover {
    background: #e2e8f0;
    color: #ef4444;
}

.parser-input-area .voice-btn.recording {
    background: #fee2e2;
    color: #ef4444;
    animation: pulse-recording 1.5s infinite;
}

.parser-input-area .send-btn {
    background: #3b82f6;
    color: white;
}

.parser-input-area .send-btn:hover {
    background: #2563eb;
}

@keyframes pulse-recording {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
