/* AI线索助手 - 网页版组件样式 */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* 侧边栏容器 */
.widget-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.widget-container.open {
    transform: translateX(0);
}

/* 侧边栏头部 */
.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
}

.widget-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.widget-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
    padding: 4px;
    border-radius: 4px;
}

.widget-close-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

/* 标签页 */
.widget-tabs {
    display: flex;
    overflow-x: auto;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 16px;
    gap: 16px;
    flex-wrap: nowrap;
}

.widget-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 0;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #6b7280;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    min-width: fit-content;
}

.tab-btn.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.tab-btn:hover:not(.active) {
    color: #374151;
}

/* 内容区域 */
.widget-content {
    padding: 16px;
    overflow-y: auto;
    flex-shrink: 0; /* 不自动扩展占用空间 */
}

/* 表单样式 */
.search-form {
    display: none;
}

.search-form.active {
    display: block;
}

.form-group {
    margin-bottom: 12px;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.form-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* 按钮样式 */
.btn-primary {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 16px;
    line-height: 1.5;
    white-space: nowrap;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-primary:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

.btn-block {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 14px;
    gap: 8px;
}

/* 加载状态 */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
    color: #6b7280;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 结果展示 */
.results-section {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    margin-top: -16px; /* 减少与上方按钮的间距 */
}

.result-content {
    display: none;
}

.result-content.active {
    display: block;
}

.result-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
}

.result-details {
    font-size: 14px;
}

/* 错误状态 */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background: #fee2e2;
    border-radius: 8px;
    color: #991b1b;
    margin: 16px;
}

.error-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 8px;
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 浮动按钮 */
.widget-toggle-btn {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: #2563eb;
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: all 0.2s ease;
}

.widget-toggle-btn:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

/* 文本选择提示框 */
.selection-tooltip {
    position: absolute;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    opacity: 0;
    transform: translateY(5px);
    transition: all 0.2s ease;
    pointer-events: none;
    min-width: 200px;
}

.selection-tooltip.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.tooltip-content {
    padding: 8px;
}

.tooltip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.tooltip-text {
    font-size: 12px;
    color: #374151;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tooltip-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tooltip-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: white;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tooltip-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.tooltip-btn svg {
    width: 12px;
    height: 12px;
}

/* Markdown Result Styles */
.result-text {
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
}

.result-text h1 {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    margin: 16px 0 8px 0;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 4px;
}

.result-text h2 {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 14px 0 8px 0;
}

.result-text h3 {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    margin: 12px 0 6px 0;
}

.result-text p {
    margin-bottom: 8px;
}

.result-text ul {
    margin: 8px 0 12px 20px;
    padding: 0;
    list-style-type: disc;
}

.result-text li {
    margin-bottom: 4px;
}

.result-text mark {
    background-color: #fef3c7;
    color: #92400e;
    padding: 0 2px;
    border-radius: 2px;
}

.result-text strong {
    font-weight: 600;
    color: #111827;
}

.result-text hr {
    border: 0;
    border-top: 1px dashed #e5e7eb;
    margin: 16px 0;
}

.result-text blockquote {
    border-left: 4px solid #e5e7eb;
    padding-left: 12px;
    color: #4b5563;
    margin: 12px 0;
    font-style: italic;
}

/* Markdown Table Styles */
.table-container {
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.result-text table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.result-text th {
    background-color: #f9fafb;
    font-weight: 600;
    color: #374151;
    padding: 8px 12px;
    border-bottom: 1px solid #e5e7eb;
}

.result-text td {
    padding: 8px 12px;
    border-bottom: 1px solid #e5e7eb;
    color: #4b5563;
}

.result-text tr:last-child td {
    border-bottom: none;
}

.result-text tr:nth-child(even) {
    background-color: #f9fafb;
}

/* 通用滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}