/* AI助手样式 */
.ai-assistant {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99;
}

.ai-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition-button);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.ai-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow:
        0 0 0 4px rgba(37, 99, 235, 0.2),
        var(--shadow-lg);
}

.ai-panel {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 350px;
    max-height: 500px;
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.ai-panel.active {
    display: flex;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-header {
    padding: 16px 20px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    color: white;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition-default);
}

.ai-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ai-chat-container {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    max-height: 350px;
}

.ai-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.ai-message.bot {
    align-items: flex-start;
}

.ai-message.user {
    align-items: flex-end;
}

.ai-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.5;
}

.ai-message.bot .ai-message-content {
    background: #f1f5f9;
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.ai-message.user .ai-message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-input-container {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
}

.ai-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    outline: none;
    font-size: 14px;
    transition: var(--transition-default);
}

.ai-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.ai-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-button);
    box-shadow: var(--shadow-sm);
}

.ai-send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.ai-typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ai-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #888;
    animation: typing 1.4s infinite both;
}

.ai-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }

    100% {
        transform: translateY(0);
    }
}

/* 查询区域样式 */
.search-container,
.pesticide-search-container {
    display: flex;
    gap: 12px;
    margin-bottom: 25px;
    flex-direction: column;
}

@media (min-width: 768px) {
    .search-container,
    .pesticide-search-container {
        flex-direction: row;
    }
}

#pestInput,
#pesticideInput {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 16px;
    outline: none;
    transition: var(--transition-default);
    background: var(--surface-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

#pestInput:focus,
#pesticideInput:focus {
    border-color: var(--primary-color);
    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.1),
        var(--shadow-md);
}

#pesticideSearchBtn,
#searchBtn {
    padding: 14px 24px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-button);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
}

#pesticideSearchBtn:hover,
#searchBtn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

#pesticideSearchBtn:active,
#searchBtn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* 拍照识别区域样式 */
.camera-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.camera-preview {
    width: 100%;
    height: 350px;
    background: #0f172a;
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

#cameraFeed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#cameraPlaceholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 16px;
    text-align: center;
    padding: 20px;
}

.camera-btns {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.camera-btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-button);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    flex: 1;
    min-width: 120px;
    max-width: 200px;
}

#startCamera {
    background: var(--primary-color);
    color: #fff;
}

#startCamera:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#takePhoto {
    background: var(--secondary-color);
    color: #fff;
    display: none;
}

#takePhoto:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#confirmRecog {
    background: var(--accent-color);
    color: #fff;
    display: none;
}

#confirmRecog:hover {
    background: #7c3aed;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#resetCamera {
    background: #94a3b8;
    color: #fff;
}

#resetCamera:hover {
    background: #64748b;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* 资料库区域样式 */
.database-container {
    overflow-x: auto;
}

.db-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 800px;
}

.db-table th,
.db-table td {
    border: 1px solid var(--border-color);
    padding: 12px 15px;
    text-align: left;
    vertical-align: top;
}

.db-table th {
    background: #f8fafc;
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
}

.db-table td {
    color: var(--text-primary);
    line-height: 1.6;
}

.db-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.db-pagination button {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-default);
    font-weight: 500;
}

.db-pagination button:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: var(--primary-light);
}

.db-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.db-pagination span {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.edit-btns {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    display: none;
    /* 默认隐藏，开发者模式显示 */
}

.edit-btn {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition-default);
}

.add-data-btn {
    margin: 20px 0;
    padding: 12px 24px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition-button);
    box-shadow: var(--shadow-md);
    display: none;
    /* 默认隐藏，开发者模式显示 */
    font-size: 15px;
}

.add-data-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.edit-btn.edit {
    background: var(--primary-color);
    color: #fff;
}

.edit-btn.delete {
    background: var(--error-color);
    color: #fff;
}
